@Override public String getEventName() { if (event == null) { return null; } if (event.isLiteral()) { return event.getValue(); } else { FaceletContext faceletContext = getFaceletContext(FacesContext.getCurrentInstance()); ValueExpression expression = event.getValueExpression(faceletContext, String.class); return (String) expression.getValue(faceletContext); } }
@Override protected AjaxBehavior createBehavior(FaceletContext ctx, String eventName, UIComponent parent) { Application application = ctx.getFacesContext().getApplication(); AjaxBehavior behavior = (AjaxBehavior) application.createBehavior(AjaxBehavior.BEHAVIOR_ID); this.listener.getMethodExpression(ctx, Void.class, EMPTY_PARAMS), this.listener.getMethodExpression(ctx, Void.class, ARG_PARAMS))); this.listener.getMethodExpression(ctx, Void.class, EMPTY_PARAMS), this.listener.getMethodExpression(ctx, Void.class, ARG_PARAMS), this.listener.getMethodExpression(ctx, Void.class, new Class[]{eventMappingClass})));
@Override public void apply(FaceletContext faceletContext, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { boolean disabled = false; if (disabledAttribute != null) { disabled = disabledAttribute.getBoolean(faceletContext); } AutoUpdateListener.subscribe(parent, disabled); } }
protected void setBehaviorAttribute(FaceletContext ctx, E behavior, TagAttribute attr, Class<?> type) { if (attr != null) { String attributeName = attr.getLocalName(); if (attr.isLiteral()) { behavior.setLiteral(attributeName, attr.getObject(ctx, type)); } else { behavior.setValueExpression(attributeName, attr.getValueExpression(ctx, type)); } } }
@Override public void apply(FaceletContext faceletContext, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { if (ComponentHandler.isNew(parent)) { ValueExpression targetVE = target.getValueExpression(faceletContext, Object.class); ValueExpression typeVE = type.getValueExpression(faceletContext, Object.class); ValueExpression fileNameVE = fileName.getValueExpression(faceletContext, Object.class); ValueExpression pageOnlyVE = null; ValueExpression selectionOnlyVE = null; encodingVE = encoding.getValueExpression(faceletContext, Object.class); pageOnlyVE = pageOnly.getValueExpression(faceletContext, Object.class); selectionOnlyVE = selectionOnly.getValueExpression(faceletContext, Object.class); preProcessorME = preProcessor.getMethodExpression(faceletContext, null, new Class[]{Object.class}); postProcessorME = postProcessor.getMethodExpression(faceletContext, null, new Class[]{Object.class}); repeatVE = repeat.getValueExpression(faceletContext, Object.class); optionsVE = options.getValueExpression(faceletContext, Object.class); onTableRenderME = onTableRender.getMethodExpression(faceletContext, null, new Class[]{Object.class, Object.class}); customExporterVE = customExporter.getValueExpression(faceletContext, Object.class);
public void applyAttachedObject(FacesContext context, UIComponent parent) { FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); // cast to a ValueHolder ValueHolder vh = (ValueHolder) parent; ValueExpression ve = null; Converter c = null; if (owner.getBinding() != null) { ve = owner.getBinding().getValueExpression(ctx, Converter.class); c = (Converter) ve.getValue(ctx); } if (c == null) { c = this.createConverter(ctx); if (ve != null) { ve.setValue(ctx, c); } } if (c == null) { throw new TagException(owner.getTag(), "No Converter was created"); } owner.setAttributes(ctx, c); vh.setConverter(c); Object lv = vh.getLocalValue(); FacesContext faces = ctx.getFacesContext(); if (lv instanceof String) { vh.setValue(c.getAsObject(faces, parent, (String) lv)); } }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException { assert(ctx.getFacesContext().getAttributes().containsKey(FaceletViewHandlingStrategy.IS_BUILDING_METADATA)); (null == (parent = parent.getParent())) || !(ComponentHandler.isNew(parent))) { return; parent.getAttributes().get(UIComponent.BEANINFO_KEY); if (null == componentBeanInfo) { throw new TagException(this.tag, "Error: I have an EditableValueHolder tag, but no enclosing composite component"); throw new TagException(this.tag, "Error: I have an EditableValueHolder tag, but no enclosing composite component"); targetList.add(target); ValueExpression ve = name.getValueExpression(ctx, String.class); String strValue = (String) ve.getValue(ctx); if (null != strValue) { target.setName(strValue); ve = targets.getValueExpression(ctx, String.class); target.setTargetsList(ve); this.nextHandler.apply(ctx, parent);
protected Class<? extends SystemEvent> getEventClass(FaceletContext ctx) { String eventType = (String) this.type.getValueExpression(ctx, String.class).getValue(ctx); if (eventType == null) { throw new FacesException("Attribute 'type' can not be null"); } return ApplicationAssociate.getInstance(ctx.getFacesContext().getExternalContext()) .getNamedEventManager().getNamedEvent(eventType); }
private String getAttributeValue(FaceletContext faceletContext, TagAttribute tagAttribute, boolean evaluate) { String value = null; if (tagAttribute != null) { if (evaluate) { ValueExpression expression = tagAttribute.getValueExpression(faceletContext, String.class); value = (String) expression.getValue(faceletContext.getFacesContext().getELContext()); } else { value = tagAttribute.getValue(); } } return value; }
public void applyMetadata(FaceletContext ctx, Object instance) { AbstractDataScroller datascroller = (AbstractDataScroller) instance; ValueExpression ve = page.getValueExpression(ctx, int.class); if (ve.isLiteralText()) { Integer value = (Integer) ve.getValue(ctx.getFacesContext().getELContext()); datascroller.setPage(value); } else { datascroller.setValueExpression("page", ve); } } }
@Override public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent) { if (parent.getParent() == null) { Map<String,Object> passThroughAttrs = c.getPassThroughAttributes(true); Object attrValue; attrValue = (this.elementName.isLiteral()) ? this.elementName.getValue(ctx) : this.elementName.getValueExpression(ctx, Object.class); passThroughAttrs.put(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY, attrValue); } }
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException { FacesContext facesContext = FacesContext.getCurrentInstance(); Class<?> type = getClassFromAttribute(typeTagAttribute, ctx); Map<String, Object> enumValues = getEnumValues(facesContext, type, allSuffixTagAttribute == null ? null : allSuffixTagAttribute.getValue(ctx)); // Create alias/var expression String var; if (varTagAttribute == null) { var = type.getSimpleName(); // fall back to class name } else { var = varTagAttribute.getValue(ctx); } ctx.setAttribute(var, enumValues); }
@Override public void onComponentPopulated(FaceletContext ctx, UIComponent c, UIComponent parent) { if (!((AbstractFaceletContext)ctx).isBuildingCompositeComponentMetadata()) { UIComponent parentCompositeComponent = FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack(); String facetName = _name.getValue(ctx); if (_required != null && _required.getBoolean(ctx) && parentCompositeComponent.getFacet(facetName) == null) { throw new TagException(this.tag, "Cannot find facet with name "+facetName+" in composite component " +parentCompositeComponent.getClientId(ctx.getFacesContext())); } c.getAttributes().put(UIComponent.FACETS_KEY, facetName); } } }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException { if (parent == null) { throw new TagException(this.tag, "Parent UIComponent was null"); } // only process if the parent is new to the tree if (parent.getParent() == null) { String n = getAttributeName(ctx); if (!parent.getAttributes().containsKey(n)) { if (this.value.isLiteral()) { parent.getAttributes().put(n, this.value.getValue()); } else { parent.setValueExpression(n, this.value.getValueExpression(ctx, Object.class)); } } } }
public static void copyPassthroughAttributes(FaceletContext ctx, UIComponent c, Tag t) { if (null == c || null == t) { return; } TagAttribute[] passthroughAttrs = t.getAttributes().getAll(PassThroughAttributeLibrary.Namespace); if (null != passthroughAttrs && 0 < passthroughAttrs.length) { Map<String, Object> componentPassthroughAttrs = c.getPassThroughAttributes(true); Object attrValue = null; for (TagAttribute cur : passthroughAttrs) { attrValue = (cur.isLiteral()) ? cur.getValue(ctx) : cur.getValueExpression(ctx, Object.class); componentPassthroughAttrs.put(cur.getLocalName(), attrValue); } } }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException { if (parent == null) { throw new TagException(this.tag, "Parent UIComponent was null"); } // only process if the parent is new to the tree if (parent.getParent() == null) { Map<String, Object> componentPassThroughAttrs = parent.getPassThroughAttributes(true); Map<String, Object> tagPassThroughAttrs = (Map<String, Object>) this.value.getObject(ctx, Map.class); for (Map.Entry<String, Object> cur : tagPassThroughAttrs.entrySet()) { componentPassThroughAttrs.put(cur.getKey(), cur.getValue()); } } }
private static String print(Tag tag, TagAttribute attr) { return tag.getLocation() + " <" + tag.getQName() + " " + attr.getQName() + "=\"" + attr.getValue() + "\">"; } }
public void applyMetadata(FaceletContext ctx, Object instance) { ((UIComponent) instance).getAttributes().put(_name, _attr.getObject(ctx, _type)); } }
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException { boolean b = this.test.getBoolean(ctx); if (this.var != null) { ctx.setAttribute(var.getValue(ctx), b); } if (b) { this.nextHandler.apply(ctx, parent); } }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException { try { this.nextHandler.apply(ctx, parent); } catch (Exception e) { if (this.var != null) { ctx.setAttribute(this.var.getValue(ctx), e); } } }