static String formIdMismatch(IComponent form, int mismatchIndex, String expectedId, String actualId, IComponent component) { return _formatter.format("form-id-mismatch", new Object[] { form.getExtendedId(), new Integer(mismatchIndex + 1), expectedId, actualId, component.getExtendedId() }); }
/** * Accesses the specified localized string. Never returns null. */ public Object getObject() { return _component.getMessages().getMessage(_description); }
public Object getObject() { IAsset asset = component.getAsset(_description); if (asset == null) throw new BindingException("Component " + component.getExtendedId() + " does not contain an asset named ''" + _description + "''.", component, getLocation(), this, null); return new AbsoluteAsset(asset, absoluteURLBuilder); }
public void connect() { IBinding binding = _component.getContainer().getBinding( _containerParameterName); if (binding == null) return; // In many cases, a default parameter binding will have been set on the // child component // parameter, which // gets overwritten by this inherited binding. There's still a lot of // ambiquity concerning // binding // an alias this way. _component.setBinding(_parameterName, binding); } }
/** * Creates a new ComponentAddress object that carries the identification information of the * given component (the page name and the ID path). * * @param component * the component to get the address of */ public ComponentAddress(IComponent component) { this(component.getPage().getPageName(), component.getIdPath()); }
public void connect() { IComponent container = _component.getContainer(); for(Iterator it = container.getBindingNames().iterator(); it.hasNext();) { String bindingName = (String) it.next(); connectInformalBinding(container, _component, bindingName); } }
Map events = component.getSpecification().getComponentEvents(); Set keySet = events.keySet(); String[] compIds = (String[]) keySet.toArray(new String[keySet.size()]); comp = findComponent(compId, component.getPage()); String idPath = comp.getExtendedId(); component.getSpecification().rewireComponentId(compId, idPath, component.getIdPath()); _invoker.addEventListener(idPath, component.getSpecification()); wireFormEvents(comp, component.getSpecification()); events = component.getSpecification().getElementEvents(); Iterator it = events.keySet().iterator(); wireElementFormEvents(listener, component, component.getSpecification());
/** * Copys all informal {@link IBinding bindings}from a source component to the destination * component. Informal bindings are bindings for informal parameters. This will overwrite * parameters (formal or informal) in the destination component if there is a naming conflict. */ public static void copyInformalBindings(IComponent source, IComponent destination) { Collection names = source.getBindingNames(); if (names == null) return; IComponentSpecification specification = source.getSpecification(); Iterator i = names.iterator(); while (i.hasNext()) { String name = (String) i.next(); // If not a formal parameter, then copy it over. if (specification.getParameter(name) == null) { IBinding binding = source.getBinding(name); destination.setBinding(name, binding); } } }
public Object getObject() { try { List clientIds = new ArrayList(_componentIds.length); for (int i=0; i < _componentIds.length; i++) { if (_targets[i] == null) { if (_target.getComponents().containsKey(_componentIds[i])) { _targets[i] = _target.getComponent(_componentIds[i]); } else if (_target.getPage() != null) { _targets[i] = _target.getPage().getComponent(_componentIds[i]); } // if not found we're in trouble if (_targets[i] == null) throw new ApplicationRuntimeException(BindingMessages.unknownComponent(_target, _componentIds[i]), getLocation(), null); } clientIds.add(_targets[i].getClientId()); } return clientIds; } catch (Exception ex) { throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex); } }
/** * @see org.apache.tapestry.pageload.IComponentVisitor#visitComponent(org.apache.tapestry.IComponent) */ public void visitComponent(IComponent component) { IComponentSpecification spec = component.getSpecification(); Iterator i = spec.getRequiredParameters().iterator(); while (i.hasNext()) { IParameterSpecification parameterSpec = (IParameterSpecification) i.next(); String name = parameterSpec.getParameterName(); if (component.getBinding(name) == null) throw new ApplicationRuntimeException(PageloadMessages.requiredParameterNotBound( name, component), component, component.getLocation(), null); } }
private void connectInformalBinding(IComponent container, IComponent component, String bindingName) { IComponentSpecification componentSpec = component.getSpecification(); IComponentSpecification containerSpec = container.getSpecification(); // check if binding already exists in the component if (component.getBinding(bindingName) != null) return; // check if parameter is informal for the component if (componentSpec.getParameter(bindingName) != null || componentSpec.isReservedParameterName(bindingName)) return; // check if parameter is informal for the container if (containerSpec.getParameter(bindingName) != null || containerSpec.isReservedParameterName(bindingName)) return; // if everything passes, establish binding IBinding binding = container.getBinding(bindingName); component.setBinding(bindingName, binding); } }
IComponent component, Locale locale) IAsset templateAsset = component.getAsset(TEMPLATE_ASSET_NAME); locale); if (result == null && component.getSpecification().isPageSpecification() && component.getNamespace().isApplicationNamespace()) result = findPageTemplateInApplicationRoot( cycle,
/** * {@inheritDoc} */ public boolean explicitlyContains(IComponent target) { if (target == null) return false; return _parts.contains(target.getId()); } }
/** @since 3.0 * */ public static BindingException createRequiredParameterException(IComponent component, String parameterName) { return new BindingException(format("required-parameter", parameterName, component.getExtendedId()), component, null, component.getBinding(parameterName), null); }
public Object getObject() { try { return _component.getComponent(_componentId); } catch (Exception ex) { throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex); } }
void discoverPageForms(IComponent parent) { if (IForm.class.isInstance(parent)) _forms.add(parent); Iterator it = parent.getComponents().values().iterator(); while (it.hasNext()) { IComponent comp = (IComponent)it.next(); discoverPageForms(comp); } }
public boolean getAllowBody(String componentId, Location location) { IComponent embedded = _component.getComponent(componentId); if (embedded == null) throw Tapestry.createNoSuchComponentException(_component, componentId, location); return embedded.getSpecification().getAllowBody(); }
public Object getObject() { try { return _component.getComponent(_componentId).getClientId(); } catch (Exception ex) { throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex); } }
/** * Adds a binding to the component, checking to see if there's a name * conflict (an existing binding for the same parameter ... possibly because * parameter names can be aliased). * * @param component * to which the binding should be added * @param parameterName * the name of the parameter to bind, which should be a true * name, not an alias * @param binding * the binding to add * @throws ApplicationRuntimeException * if a binding already exists * @since 4.0 */ static void addBindingToComponent(IComponent component, String parameterName, IBinding binding) { IBinding existing = component.getBinding(parameterName); if (existing != null) throw new ApplicationRuntimeException(PageloadMessages.duplicateParameter(parameterName, existing), component, binding.getLocation(), null); component.setBinding(parameterName, binding); }
/** * Returns the {@link IBinding} corresponding to the value of the parameterName property. */ public IBinding getBinding() { return _inspectedComponent.getBinding(_parameterName); }