protected void setProperties(UIComponent component) { if (_binding != null) component.setValueExpression("binding", _binding); if (_rendered != null) component.setValueExpression("rendered", _rendered); String type = getRendererType(); if (type != null) component.setRendererType(type); }
public void applyMetadata(FaceletContext ctx, Object instance) { UIComponent c = (UIComponent) instance; c.setValueExpression( "value", attr.getValueExpression( ctx, ((c instanceof UISelectBoolean) ? Boolean.class : Object.class))); }
@Override public void processEvent(ComponentSystemEvent event) throws AbortProcessingException { if (event instanceof PostRestoreStateEvent) { String forValue = (String) getAttributes().get("for"); if (!isEmpty(forValue)) { UIComponent forComponent = findComponentRelatively(this, forValue); if (forComponent == null) { throw new IllegalArgumentException( String.format(ERROR_FOR_COMPONENT_NOT_FOUND, forValue, getId())); } // To be sure, check if the target component doesn't have a label already. This // is unlikely, since otherwise people have no need to use this outputLabel component // but check to be sure. if (getOptionalLabel(forComponent) == null) { ValueExpression valueExpression = getValueExpression("value"); if (valueExpression != null) { forComponent.setValueExpression("label", valueExpression); } else { forComponent.getAttributes().put("label", getValue()); } } } } }
public void setParentProperties(UIComponent parent) { ValueExpression valueBinding; if (null != getEvent()) { if (log.isDebugEnabled()) { log.debug(Messages.getMessage(Messages.SET_VALUE_BINDING_FOR_EVENT, getEvent())); } // for non action/data components, or for non-default events - build // listener for this instance. valueBinding = getEventValueBinding(); parent.setValueExpression(getEvent(), valueBinding); } }
/** * Copies attributes and value expressions with given name from parent component to child * component. */ public static void copyValues(UIComponent parent, UIComponent child, String[] valueNames) { Map<String, Object> parentAttributes = parent.getAttributes(); Map<String, Object> childAttributes = child.getAttributes(); for (String name : valueNames) { // attributes if (parentAttributes.containsKey(name)) { childAttributes.put(name, parentAttributes.get(name)); } // value expressions ValueExpression ve = parent.getValueExpression(name); if (ve != null) { child.setValueExpression(name, ve); } } }
@Override protected UIComponent createComponent(FacesContext context, String newId) throws JspException { Application app = context.getApplication(); UIComponent component; if (_binding != null) { component = app.createComponent(_binding, context, getComponentType()); component.setValueExpression("binding", _binding); } else component = app.createComponent(getComponentType()); component.setId(getId()); setProperties(component); return component; }
public void applyMetadata(FaceletContext ctx, Object instance) { ValueExpression ve = attr.getValueExpression(ctx, type); UIComponent cc = (UIComponent) instance; assert (UIComponent.isCompositeComponent(cc)); Map<String, Object> attrs = cc.getAttributes(); BeanInfo componentMetadata = (BeanInfo) attrs.get(UIComponent.BEANINFO_KEY); BeanDescriptor desc = componentMetadata.getBeanDescriptor(); Collection<String> attributesWithDeclaredDefaultValues = (Collection<String>) desc.getValue(RIConstants.ATTRS_WITH_DECLARED_DEFAULT_VALUES); if (null != attributesWithDeclaredDefaultValues && attributesWithDeclaredDefaultValues.contains(name)) { // It is necessary to remove the value from the attribute // map because the ELexpression transparancy doesn't know // about the value's existence. attrs.remove(name); } cc.setValueExpression(name, ve); }
/** * If the binding attribute was specified, use that in conjuction with our componentType String * variable to call createComponent on the Application, otherwise just pass the componentType * String. * * <p>If the binding was used, then set the ValueExpression "binding" on the created UIComponent. * * @see Application#createComponent(javax.faces.el.ValueBinding, javax.faces.context.FacesContext, * java.lang.String) * @see Application#createComponent(java.lang.String) * @param ctx FaceletContext to use in creating a component * @return */ private UIComponent createComponent(FaceletContext ctx) { if (null != createCompositeComponentDelegate) { return createCompositeComponentDelegate.createComponent(ctx); } UIComponent c; FacesContext faces = ctx.getFacesContext(); Application app = faces.getApplication(); if (this.binding != null) { ValueExpression ve = this.binding.getValueExpression(ctx, Object.class); c = app.createComponent(ve, faces, this.componentType, this.rendererType); if (c != null) { // Make sure the component supports 1.2 c.setValueExpression("binding", ve); } } else { c = app.createComponent(faces, this.componentType, this.rendererType); } return c; }
public void applyMetadata(FaceletContext ctx, Object instance) { ((UIComponent) instance) .setValueExpression(this.name, this.attr.getValueExpression(ctx, this.type)); }
/* (non-Javadoc) * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent) */ protected void setProperties(UIComponent component) { // TODO Auto-generated method stub super.setProperties(component); HtmlSpan comp = (HtmlSpan) component; if (this._style != null) { if (this._style.isLiteralText()) { try { java.lang.String __style = (java.lang.String) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._style.getExpressionString(), java.lang.String.class); comp.setStyle(__style); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("style", this._style); } } if (this._styleClass != null) { if (this._styleClass.isLiteralText()) { try { java.lang.String __styleClass = (java.lang.String) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._styleClass.getExpressionString(), java.lang.String.class); comp.setStyleClass(__styleClass); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("styleClass", this._styleClass); } } if (this._title != null) { if (this._title.isLiteralText()) { try { java.lang.String __title = (java.lang.String) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._title.getExpressionString(), java.lang.String.class); comp.setTitle(__title); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("title", this._title); } } }
/* (non-Javadoc) * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent) */ protected void setProperties(UIComponent component) { // TODO Auto-generated method stub super.setProperties(component); HtmlSelection comp = (HtmlSelection) component; if (this._dataModel != null) { if (this._dataModel.isLiteralText()) { try { java.lang.String __dataModel = (java.lang.String) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._dataModel.getExpressionString(), java.lang.String.class); comp.setDataModel(__dataModel); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("dataModel", this._dataModel); } } if (this._name != null) { if (this._name.isLiteralText()) { try { java.lang.String __name = (java.lang.String) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._name.getExpressionString(), java.lang.String.class); comp.setName(__name); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("name", this._name); } } if (this._value != null) { if (this._value.isLiteralText()) { try { java.lang.Object __value = (java.lang.Object) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._value.getExpressionString(), java.lang.Object.class); comp.setValue(__value); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("value", this._value); } } if (this._var != null) { if (this._var.isLiteralText()) { try { java.lang.String __var = (java.lang.String) getFacesContext() .getApplication() .getExpressionFactory() .coerceToType(this._var.getExpressionString(), java.lang.String.class); comp.setVar(__var); } catch (ELException e) { throw new FacesException(e); } } else { component.setValueExpression("var", this._var); } } }
public void applyMetadata(FaceletContext ctx, Object instance) { ((UIComponent) instance) .setValueExpression("converter", attr.getValueExpression(ctx, Converter.class)); }