/** * Returns the {@link IBinding} corresponding to the value of the parameterName property. */ public IBinding getBinding() { return _inspectedComponent.getBinding(_parameterName); }
/** * 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); } } }
/** * Provides access to the invoking component's parameters. * * @since 4.0 */ public Object getParameter(String name) { return _invoker.getBinding(name).getObject(); }
/** * 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); } } }
/** * Provides access to the invoking component's parameters. * * @since 4.0 */ public Object getParameter(String name) { return _invoker.getBinding(name).getObject(); }
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); } }
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); } }
/** @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); }
/** @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); }
/** * @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); } }
/** * @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); } }
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); } }
/** * 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); }
/** * 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); }
&& component.getBinding(TemplateSource.TEMPLATE_TAG_PARAMETER_NAME) == null)
if (component.getBinding(name) == null)
if (component.getBinding(name) == null)
/** * Converts a parameter of an {@link IComponent} to an instance of {@link JSONObject}. * * @param component * @param parameterName * @return The parameter parsed into a json structure. */ public static JSONObject parseJSONParameter(IComponent component, String parameterName) { IBinding binding = component.getBinding(parameterName); if (binding == null || binding.getObject() == null) return new JSONObject(); try { return new JSONObject((String) binding.getObject(String.class)); } catch (ParseException ex) { throw new ApplicationRuntimeException( DojoMessages.mustUseValidJsonInParameter(parameterName), binding.getLocation() , ex); } } }
/** * Converts a parameter of an {@link IComponent} to an instance of {@link JSONObject}. * * @param component * @param parameterName * @return The parameter parsed into a json structure. */ public static JSONObject parseJSONParameter(IComponent component, String parameterName) { IBinding binding = component.getBinding(parameterName); if (binding == null || binding.getObject() == null) return new JSONObject(); try { return new JSONObject((String) binding.getObject(String.class)); } catch (ParseException ex) { throw new ApplicationRuntimeException( DojoMessages.mustUseValidJsonInParameter(parameterName), binding.getLocation() , ex); } } }