List of usage examples for javax.el ExpressionFactory createValueExpression
public abstract ValueExpression createValueExpression(Object instance, Class<?> expectedType);
From source file:com.flexive.faces.components.content.Jsf2FxValueHandler.java
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException { final String var; try {/* w w w . ja v a 2s .c o m*/ if (this.getAttribute("var") == null) { // no variable name specified, use enclosing content view if (!(parent instanceof FxContentView)) { throw new FacesException( "Facelet parent is no FxContentView instance and \"var\" attribute not specified."); } var = ((FxContentView) parent).getVar(); } else { // use a custom variable name var = this.getAttribute("var").getValue(ctx); } } catch (FxRuntimeException e) { throw new FacesException("The fx:value component must be embedded in a fx:content instance."); } final boolean isNewValue = this.getAttribute("new") != null && Boolean.valueOf(this.getAttribute("new").getValue(ctx)); final VariableMapper origMapper = ctx.getVariableMapper(); final VariableMapperWrapper mapper = new VariableMapperWrapper(origMapper); try { ctx.setVariableMapper(mapper); // get property attribute final String property; final TagAttribute propertyAttribute = this.getAttribute("property"); if (propertyAttribute != null) { final ValueExpression propertyExpression = propertyAttribute.getValueExpression(ctx, String.class); property = (String) propertyExpression.getValue(ctx); } else { property = null; } FxJsfComponentUtils.requireAttribute("fx:value", "property", property); // assign id, label/labelKey and value based on the enclosing FxContentView instance final ExpressionFactory expressionFactory = ctx.getExpressionFactory(); mapper.setVariable("id", expressionFactory.createValueExpression(StringUtils.replace(property, "/", "_"), String.class)); if (this.getAttribute("labelKey") == null) { // use property label mapper.setVariable("label", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, "label"), FxString.class)); } else { // use provided message key assignAttribute(ctx, mapper, "labelKey", String.class); } // retrieve content from content view mapper.setVariable("value", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, isNewValue ? "new" : null), FxValue.class)); // passthrough other template attributes assignAttribute(ctx, mapper, "inputMapper", InputMapper.class); assignAttribute(ctx, mapper, "onchange", String.class); assignAttribute(ctx, mapper, "readOnly", Boolean.class); assignAttribute(ctx, mapper, "decorate", Boolean.class); assignAttribute(ctx, mapper, "filter", Boolean.class); assignAttribute(ctx, mapper, "forceLineInput", Boolean.class); assignAttribute(ctx, mapper, "valueFormatter", FxValueFormatter.class); assignAttribute(ctx, mapper, "containerDivClass", String.class); assignAttribute(ctx, mapper, "autocompleteHandler", String.class); assignAttribute(ctx, mapper, "disableMultiLanguage", Boolean.class); assignAttribute(ctx, mapper, "disableLytebox", Boolean.class); assignAttribute(ctx, mapper, "tooltip", String.class); assignAttribute(ctx, mapper, "tooltipKey", String.class); // TODO: cache templates/use a facelet ResourceResolver to encapsulate this ctx.includeFacelet(parent, Thread.currentThread().getContextClassLoader().getResource(TEMPLATE_ROOT + template)); } finally { ctx.setVariableMapper(origMapper); } }
From source file:com.flexive.faces.components.content.FxValueHandler.java
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException { final String var; try {//from w ww . ja v a2 s.com if (this.getAttribute("var") == null) { // no variable name specified, use enclosing content view if (!(parent instanceof FxContentView)) { throw new FacesException( "Facelet parent is no FxContentView instance and \"var\" attribute not specified."); } var = ((FxContentView) parent).getVar(); } else { // use a custom variable name var = this.getAttribute("var").getValue(ctx); } } catch (FxRuntimeException e) { throw new FacesException("The fx:value component must be embedded in a fx:content instance."); } final boolean isNewValue = this.getAttribute("new") != null && Boolean.valueOf(this.getAttribute("new").getValue(ctx)); final VariableMapper origMapper = ctx.getVariableMapper(); final VariableMapperWrapper mapper = new VariableMapperWrapper(origMapper); try { ctx.setVariableMapper(mapper); // get property attribute final String property; final TagAttribute propertyAttribute = this.getAttribute("property"); if (propertyAttribute != null) { final ValueExpression propertyExpression = propertyAttribute.getValueExpression(ctx, String.class); property = (String) propertyExpression.getValue(ctx); } else { property = null; } FxJsfComponentUtils.requireAttribute("fx:value", "property", property); // assign id, label/labelKey and value based on the enclosing FxContentView instance final ExpressionFactory expressionFactory = ctx.getExpressionFactory(); mapper.setVariable("id", expressionFactory.createValueExpression(StringUtils.replace(property, "/", "_"), String.class)); if (this.getAttribute("labelKey") == null) { // use property label mapper.setVariable("label", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, "label"), FxString.class)); } else { // use provided message key assignAttribute(ctx, mapper, "labelKey", String.class); } // retrieve content from content view mapper.setVariable("value", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, isNewValue ? "new" : null), FxValue.class)); // passthrough other template attributes assignAttribute(ctx, mapper, "inputMapper", InputMapper.class); assignAttribute(ctx, mapper, "onchange", String.class); assignAttribute(ctx, mapper, "readOnly", Boolean.class); assignAttribute(ctx, mapper, "decorate", Boolean.class); assignAttribute(ctx, mapper, "filter", Boolean.class); assignAttribute(ctx, mapper, "forceLineInput", Boolean.class); assignAttribute(ctx, mapper, "newLine", Boolean.class); assignAttribute(ctx, mapper, "valueFormatter", FxValueFormatter.class); assignAttribute(ctx, mapper, "containerDivClass", String.class); assignAttribute(ctx, mapper, "autocompleteHandler", String.class); assignAttribute(ctx, mapper, "disableMultiLanguage", Boolean.class); assignAttribute(ctx, mapper, "disableLytebox", Boolean.class); assignAttribute(ctx, mapper, "tooltip", String.class); assignAttribute(ctx, mapper, "tooltipKey", String.class); // TODO: cache templates/use a facelet ResourceResolver to encapsulate this ctx.includeFacelet(parent, Thread.currentThread().getContextClassLoader().getResource(TEMPLATE_ROOT + template)); } finally { ctx.setVariableMapper(origMapper); } }
From source file:de.openknowledge.extensions.jsf.model.ModelMethod.java
private Object[] findParameters(FacesContext context, SimpleMethodExpression methodExpression, ExpressionFactory expressionFactory, UIInput[] parameterComponents, Class<?>[] parameterTypes) { Object[] parameters = new Object[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { if (parameterComponents[i] != null) { parameters[i] = parameterComponents[i].getSubmittedValue(); if (parameters[i] == null) { parameters[i] = parameterComponents[i].getValue(); }/*from w w w . j av a 2 s .co m*/ } else { parameters[i] = expressionFactory .createValueExpression(methodExpression.getParameters()[i], Object.class) .getValue(context.getELContext()); } } return parameters; }
From source file:com.flexive.faces.components.ToolbarPluginHandler.java
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { // run toolbar plugins final Executor executor = new Executor(FxJsfUtils.getRequest().getRequestURIWithoutContext()); PluginRegistryBean.getInstance().execute(AdmExtensionPoints.ADM_TOOLBAR_PLUGINS, executor); if (LOG.isDebugEnabled()) { LOG.debug("Added " + executor.getButtons().size() + " buttons for " + executor.uri); }/* w w w . jav a 2s . co m*/ final VariableMapper origMapper = ctx.getVariableMapper(); try { ctx.pushClient(this); // register ourselve to serve ui:insert requests by the template final ExpressionFactory factory = ctx.getExpressionFactory(); for (ToolbarPluginExecutor.Button button : executor.getButtons()) { VariableMapperWrapper mapper = new VariableMapperWrapper(origMapper); ctx.setVariableMapper(mapper); if (button.isSeparator()) { // include template ctx.includeFacelet(parent, SEPARATOR_TEMPLATE); } else { // set options for commandElement mapper.setVariable("id", factory.createValueExpression(button.getId(), String.class)); mapper.setVariable("label", factory.createValueExpression(button.getLabel(), String.class)); mapper.setVariable("bean", factory.createValueExpression(ctx, "#{" + button.getBean() + "}", Object.class)); mapper.setVariable("action", factory.createValueExpression(button.getAction(), String.class)); mapper.setVariable("icon", factory.createValueExpression(button.getIcon(), String.class)); mapper.setVariable("iconUrl", factory.createValueExpression(button.getIconUrl(), String.class)); mapper.setVariable("location", factory.createValueExpression("toolbar", String.class)); // include template ctx.includeFacelet(parent, COMMAND_TEMPLATE); } } } finally { ctx.popClient(this); ctx.setVariableMapper(origMapper); } }
From source file:de.openknowledge.extensions.jsf.model.ModelMethod.java
private Class<?>[] findParameterTypes(FacesContext context, SimpleMethodExpression methodExpression, ExpressionFactory expressionFactory, UIInput[] parameterComponents) { Class<?>[] parameterTypes = new Class[methodExpression.getParameters().length]; for (int i = 0; i < parameterTypes.length; i++) { if (parameterComponents[i] != null) { Object value = parameterComponents[i].getSubmittedValue(); if (value != null) { parameterTypes[i] = value.getClass(); } else { value = parameterComponents[i].getValue(); if (value != null) { parameterTypes[i] = value.getClass(); }// w w w. j a v a 2s . c om } } if (parameterTypes[i] == null) { Object paramterValue = expressionFactory .createValueExpression(methodExpression.getParameters()[i], Object.class) .getValue(context.getELContext()); parameterTypes[i] = paramterValue != null ? paramterValue.getClass() : null; } } return parameterTypes; }
From source file:org.nuxeo.ecm.platform.actions.facelets.ActionTagHandler.java
/** * Renders given widget resolving its {@link FaceletHandler} from {@link WebLayoutManager} configuration. * <p>//ww w .j a v a2 s . co m * Variables exposed: {@link RenderVariables.globalVariables#value}, same variable suffixed with "_n" where n is the * widget level, and {@link RenderVariables.globalVariables#document}. */ public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException { long start = FaceletDebugTracer.start(); Action actionInstance = null; try { if (action != null) { actionInstance = (Action) action.getObject(ctx, Action.class); } if (actionInstance == null) { return; } VariableMapper orig = ctx.getVariableMapper(); try { BlockingVariableMapper vm = new BlockingVariableMapper(orig); ctx.setVariableMapper(vm); // build corresponding widget and adjust properties String wtype = actionInstance.getType(); if (StringUtils.isBlank(wtype)) { wtype = "link"; } String wcat = "jsfAction"; String modeValue = null; if (mode != null) { modeValue = mode.getValue(ctx); } if (StringUtils.isBlank(modeValue)) { modeValue = BuiltinWidgetModes.VIEW; } Map<String, Serializable> props = new HashMap<>(); // put all action properties props.putAll(actionInstance.getProperties()); if ("template".equals(wtype)) { // avoid erasing template value from widget type configuration, and match template String templateName = "template"; String modeTemplateName = "template" + "_" + modeValue; if (BuiltinWidgetModes.VIEW.equals(modeValue) && props.containsKey(templateName)) { props.put("action_template", props.get(templateName)); } else if (props.containsKey(modeTemplateName)) { props.put("action_template", props.get(modeTemplateName)); props.remove(modeTemplateName); } props.remove(templateName); } // handle onclick StringBuilder fullOnclick = new StringBuilder(); if (BuiltinWidgetModes.VIEW.equals(modeValue) && props.containsKey("confirmMessage")) { String confirmMessage = (String) props.get("confirmMessage"); if (!StringUtils.isEmpty(confirmMessage)) { fullOnclick.append( "var message = \"#{nxu:translate(widgetProperty_confirmMessage, widgetProperty_confirmMessageArgs)}\";if (message != \"\" && !confirm(message)) {return false;};"); } } String confirm = actionInstance.getConfirm(); if (!StringUtils.isEmpty(confirm)) { fullOnclick.append(confirm).append(";"); } String onclick = (String) actionInstance.getProperties().get("onclick"); if (!StringUtils.isEmpty(onclick)) { fullOnclick.append(onclick).append(";"); } props.put("immediate", actionInstance.isImmediate()); props.put("icon", actionInstance.getIcon()); props.put("onclick", actionInstance.getConfirm()); props.put("accessKey", actionInstance.getAccessKey()); props.put("link", actionInstance.getLink()); props.put("actionId", actionInstance.getId()); props.put("action", actionInstance); if (useAjaxForm != null && !props.containsKey("useAjaxForm")) { props.put("useAjaxForm", useAjaxForm.getValue()); } String valueName = value.getValue(); String bareValueName = valueName; if (ComponentTagUtils.isStrictValueReference(valueName)) { bareValueName = ComponentTagUtils.getBareValueName(valueName); } // add filtering method if needed if (!actionInstance.isFiltered()) { // make sure variables are in the context for this filter resolution ExpressionFactory eFactory = ctx.getExpressionFactory(); ValueExpression actionVe = eFactory.createValueExpression(actionInstance, Action.class); vm.setVariable("action", actionVe); vm.addBlockedPattern("action"); String bindingValue = bareValueName; boolean bindingDone = false; if (props.containsKey("actionContextDocument")) { Object val = props.get("actionContextDocument"); if (val instanceof String && ComponentTagUtils.isStrictValueReference((String) val)) { bindingValue = ComponentTagUtils.getBareValueName((String) val); ValueExpression bindingVe = eFactory.createValueExpression(ctx, (String) val, Object.class); vm.setVariable("actionContextDocument", bindingVe); vm.addBlockedPattern("actionContextDocument"); bindingDone = true; } } if (!bindingDone) { // just bound current value to make expressions consistent vm.setVariable("actionContextDocument", value.getValueExpression(ctx, DocumentModel.class)); vm.addBlockedPattern("actionContextDocument"); } String method = null; if (postFilterMethod != null) { method = postFilterMethod.getValue(ctx); } if (StringUtils.isBlank(method)) { method = "webActions.isAvailableForDocument"; } String filterExpr = "#{" + method + "(" + bindingValue + ", action)}"; props.put("available", filterExpr); props.put("enabled", filterExpr); } else { props.put("available", actionInstance.getAvailable()); props.put("enabled", "true"); } // add all extra props passed to the tag String widgetPropertyMarker = RenderVariables.widgetVariables.widgetProperty.name() + "_"; List<String> reservedVars = Arrays.asList(reservedVarsArray); for (TagAttribute var : vars) { String localName = var.getLocalName(); if (!reservedVars.contains(localName)) { if (localName != null && localName.startsWith(widgetPropertyMarker)) { localName = localName.substring(widgetPropertyMarker.length()); } props.put(localName, var.getValue()); } } String widgetNameValue = null; if (widgetName != null) { widgetNameValue = widgetName.getValue(ctx); } if (StringUtils.isBlank(widgetNameValue)) { widgetNameValue = actionInstance.getId(); } // avoid double markers if (widgetNameValue != null && widgetNameValue.startsWith(FaceletHandlerHelper.WIDGET_ID_PREFIX)) { widgetNameValue = widgetNameValue.substring(FaceletHandlerHelper.WIDGET_ID_PREFIX.length()); } WidgetDefinitionImpl wDef = new WidgetDefinitionImpl(widgetNameValue, wtype, actionInstance.getLabel(), actionInstance.getHelp(), true, null, null, props, null); wDef.setTypeCategory(wcat); wDef.setDynamic(true); WebLayoutManager layoutService = Framework.getService(WebLayoutManager.class); Widget widgetInstance = layoutService.createWidget(ctx, wDef, modeValue, bareValueName, null); if (widgetInstance == null) { return; } // set unique id on widget before exposing it to the context FaceletHandlerHelper helper = new FaceletHandlerHelper(config); WidgetTagHandler.generateWidgetId(ctx, helper, widgetInstance, false); // expose widget variables WidgetTagHandler.exposeWidgetVariables(ctx, vm, widgetInstance, null, false); // create widget handler TagAttributes wattrs = FaceletHandlerHelper.getTagAttributes(); wattrs = FaceletHandlerHelper.addTagAttribute(wattrs, helper.createAttribute(RenderVariables.widgetVariables.widget.name(), "#{" + RenderVariables.widgetVariables.widget.name() + "}")); wattrs = FaceletHandlerHelper.addTagAttribute(wattrs, helper.createAttribute("value", value.getValue())); TagConfig wconfig = TagConfigFactory.createTagConfig(config, config.getTagId(), wattrs, nextHandler); FaceletHandler handler = new WidgetTagHandler(wconfig); // expose ajax render props to the context String reRender = (String) props.get("ajaxReRender"); if (!StringUtils.isEmpty(reRender)) { ExpressionFactory eFactory = ctx.getExpressionFactory(); ValueExpression ve = eFactory.createValueExpression( "#{nxu:joinRender(ajaxReRender, " + reRender + ")}", String.class); vm.setVariable("ajaxReRender", ve); } // create form handler if needed boolean doAddForm = false; if (addForm != null) { doAddForm = addForm.getBoolean(ctx); } if (!doAddForm) { // check if addForm information held by the action configuration doAddForm = helper .createAttribute("addForm", String.valueOf(widgetInstance.getProperty("addForm"))) .getBoolean(ctx); } if (doAddForm) { // resolve form related attributes early boolean discard = helper .createAttribute("discardSurroundingForm", String.valueOf(widgetInstance.getProperty("discardSurroundingForm"))) .getBoolean(ctx); boolean doUseAjaxForm = helper.createAttribute("useAjaxForm", String.valueOf(widgetInstance.getProperty("useAjaxForm"))).getBoolean(ctx); if (!discard || doUseAjaxForm) { List<TagAttribute> fattrs = new ArrayList<>(); if (doUseAjaxForm) { Object ajaxProp = widgetInstance.getProperty("ajaxSupport"); if (ajaxProp == null) { ajaxProp = widgetInstance.getProperty("supportAjax"); } fattrs.add(helper.createAttribute("useAjaxForm", String.valueOf(ajaxProp))); } fattrs.add(helper.createAttribute("disableMultipartForm", String.valueOf(widgetInstance.getProperty("disableMultipartForm")))); fattrs.add(helper.createAttribute("disableDoubleClickShield", String.valueOf(widgetInstance.getProperty("disableDoubleClickShield")))); fattrs.add(helper.createAttribute("styleClass", formStyleClass != null ? formStyleClass.getValue() : null)); fattrs.add(helper.createAttribute("id", widgetInstance.getId() + "_form")); TagConfig fconfig = TagConfigFactory.createTagConfig(config, config.getTagId(), new TagAttributesImpl(fattrs.toArray(new TagAttribute[] {})), handler); handler = new FormTagHandler(fconfig); } } handler.apply(ctx, parent); } finally { ctx.setVariableMapper(orig); } } finally { FaceletDebugTracer.trace(start, config.getTag(), actionInstance == null ? null : actionInstance.getId()); } }
From source file:org.nuxeo.ecm.platform.forms.layout.facelets.LayoutRowTagHandler.java
protected void applyOptimized(FaceletContext ctx, UIComponent parent, FaceletHandlerHelper helper) throws IOException, FacesException, ELException { String rowCountVarName = RenderVariables.layoutVariables.layoutRowCount.name(); TagAttribute rowCountAttr = helper.createAttribute(rowCountVarName, "#{" + rowCountVarName + "}"); int rowCount = rowCountAttr.getInt(ctx); if (rowCount == 0) { return;/*from www.j a v a2 s . c o m*/ } VariableMapper orig = ctx.getVariableMapper(); try { for (int i = 0; i < rowCount; i++) { BlockingVariableMapper vm = new BlockingVariableMapper(orig); ctx.setVariableMapper(vm); // expose row variables ExpressionFactory eFactory = ctx.getExpressionFactory(); ValueExpression ve = eFactory.createValueExpression( "#{" + RenderVariables.layoutVariables.layout.name() + ".rows[" + i + "]}", String.class); ValueExpression rowVe = new MetaValueExpression(ve, ctx.getFunctionMapper(), vm, LayoutRow.class); ValueExpression rowIndexVe = eFactory.createValueExpression(i, Integer.class); String instanceName = getInstanceName(); String indexName = getIndexName(); vm.setVariable(instanceName, rowVe); vm.addBlockedPattern(instanceName); vm.setVariable(indexName, rowIndexVe); vm.addBlockedPattern(indexName); nextHandler.apply(ctx, parent); } } finally { ctx.setVariableMapper(orig); } }
From source file:org.nuxeo.ecm.platform.forms.layout.facelets.LayoutRowWidgetTagHandler.java
protected void applyCompat(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { // resolve widgets from row in context LayoutRow row = null;/*from w ww . j a va 2 s . c o m*/ String rowVariableName = RenderVariables.rowVariables.layoutRow.name(); FaceletHandlerHelper helper = new FaceletHandlerHelper(config); TagAttribute rowAttribute = helper.createAttribute(rowVariableName, "#{" + rowVariableName + "}"); if (rowAttribute != null) { row = (LayoutRow) rowAttribute.getObject(ctx, LayoutRow.class); } if (row == null) { log.error("Could not resolve layout row " + rowAttribute); return; } Widget[] widgets = row.getWidgets(); if (widgets == null || widgets.length == 0) { return; } boolean recomputeIdsBool = false; if (recomputeIds != null) { recomputeIdsBool = recomputeIds.getBoolean(ctx); } int widgetCounter = 0; for (Widget widget : widgets) { // set unique id on widget before exposing it to the context, but assumes iteration could be done several // times => do not generate id again if already set, unless specified by attribute "recomputeIds" if (widget != null && (widget.getId() == null || recomputeIdsBool)) { WidgetTagHandler.generateWidgetId(ctx, helper, widget, false); } // expose widget variables Map<String, ValueExpression> variables = new HashMap<String, ValueExpression>(); ExpressionFactory eFactory = ctx.getExpressionFactory(); ValueExpression widgetVe = eFactory.createValueExpression(widget, Widget.class); variables.put(RenderVariables.widgetVariables.widget.name(), widgetVe); Integer level = null; String tagConfigId = null; if (widget != null) { level = Integer.valueOf(widget.getLevel()); tagConfigId = widget.getTagConfigId(); } variables.put(RenderVariables.widgetVariables.widget.name() + "_" + level, widgetVe); ValueExpression widgetIndexVe = eFactory.createValueExpression(Integer.valueOf(widgetCounter), Integer.class); variables.put(RenderVariables.widgetVariables.widgetIndex.name(), widgetIndexVe); variables.put(RenderVariables.widgetVariables.widgetIndex.name() + "_" + level, widgetIndexVe); // XXX: expose widget controls too, need to figure out // why controls cannot be references to widget.controls like // properties are in TemplateWidgetTypeHandler if (widget != null) { for (Map.Entry<String, Serializable> ctrl : widget.getControls().entrySet()) { String key = ctrl.getKey(); String name = RenderVariables.widgetVariables.widgetControl.name() + "_" + key; Serializable value = ctrl.getValue(); variables.put(name, eFactory.createValueExpression(value, Object.class)); } } List<String> blockedPatterns = new ArrayList<String>(); blockedPatterns.add(RenderVariables.widgetVariables.widget.name() + "*"); blockedPatterns.add(RenderVariables.widgetVariables.widgetIndex.name() + "*"); blockedPatterns.add(RenderVariables.widgetVariables.widgetControl.name() + "_*"); FaceletHandler handler = helper.getAliasFaceletHandler(tagConfigId, variables, blockedPatterns, nextHandler); // apply handler.apply(ctx, parent); widgetCounter++; } }
From source file:org.nuxeo.ecm.platform.forms.layout.facelets.LayoutTagHandler.java
protected void fillVariablesForLayoutBuild(FaceletContext ctx, ExpressionFactory eFactory, BlockingVariableMapper vm, String modeValue) { ValueExpression valueExpr = value.getValueExpression(ctx, Object.class); vm.setVariable(RenderVariables.globalVariables.value.name(), valueExpr); vm.setVariable(RenderVariables.globalVariables.layoutValue.name(), valueExpr); ValueExpression modeVe = eFactory.createValueExpression(modeValue, String.class); vm.setVariable(RenderVariables.globalVariables.layoutMode.name(), modeVe); // mode as alias to layoutMode vm.setVariable(RenderVariables.globalVariables.mode.name(), modeVe); }
From source file:org.nuxeo.ecm.platform.forms.layout.facelets.LayoutTagHandler.java
/** * Computes variables for rendering, making available the layout instance and its properties to the context. *//*from w w w . j av a2 s . c o m*/ protected void fillVariablesForLayoutRendering(FaceletContext ctx, ExpressionFactory eFactory, WebLayoutManager layoutService, BlockingVariableMapper vm, Layout layoutInstance) { // expose layout value ValueExpression layoutVe = eFactory.createValueExpression(layoutInstance, Layout.class); vm.setVariable(RenderVariables.layoutVariables.layout.name(), layoutVe); vm.addBlockedPattern(RenderVariables.layoutVariables.layout.name()); // expose layout properties too for (Map.Entry<String, Serializable> prop : layoutInstance.getProperties().entrySet()) { String key = prop.getKey(); String name = RenderVariables.layoutVariables.layoutProperty.name() + "_" + key; vm.setVariable(name, eFactory.createValueExpression(prop.getValue(), Object.class)); } vm.addBlockedPattern(RenderVariables.layoutVariables.layoutProperty.name() + "_*"); // expose layout row count for row variables reference Integer rowCount = null; if (layoutInstance.getRows() != null) { rowCount = layoutInstance.getRows().length; } vm.setVariable(RenderVariables.layoutVariables.layoutRowCount.name(), eFactory.createValueExpression(rowCount, Integer.class)); vm.addBlockedPattern(RenderVariables.layoutVariables.layoutRowCount.name()); }