/** * Constructor. * * @param value Object to store. * @param role Asociated role. */ public Attribute(Object value, String role) { this.value = value; setRole(role); }
/** * Constructor. * * @param value Object to store. * @param role Asociated role. */ public Attribute(Object value, String role) { this.value = value; setRole(role); }
/** * Constructor. * * @param value Object to store. If specified, the <code>expression</code> * parameter will be ignored. * @param expression The expression to be evaluated. Ignored if the * <code>value</code> is not null. * @param role Associated role. * @param rendererName The renderer name. * @since 2.2.0 */ public Attribute(Object value, Expression expression, String role, String rendererName) { this.value = value; this.expressionObject = expression; this.renderer = rendererName; setRole(role); }
/** * Constructor. * * @param value Object to store. If specified, the <code>expression</code> * parameter will be ignored. * @param expression The expression to be evaluated. Ignored if the * <code>value</code> is not null. * @param role Associated role. * @param rendererName The renderer name. * @since 2.1.2 */ public Attribute(Object value, String expression, String role, String rendererName) { this.value = value; this.expression = expression; this.renderer = rendererName; setRole(role); }
/** * Sets the value of the role property. * * @param role the new value of the role property * @deprecated Use {@link #getTemplateAttribute()}. */ @Deprecated public void setRole(String role) { if (templateAttribute == null) { templateAttribute = Attribute.createTemplateAttribute(null); } templateAttribute.setRole(role); }
/** * Constructor. * * @param value Object to store. * @param role Associated role. * @param type Attribute type. * @deprecated Use {@link Attribute#Attribute(Object, String, String, String)}. */ @Deprecated public Attribute(Object value, String role, AttributeType type) { this.value = value; setType(type); setRole(role); }
/** * Constructor. * * @param name name of the attribute * @param value Object to store. * @param role Asociated role. * @param type Attribute type. * @deprecated Use * {@link Attribute#Attribute(Object, String, String)))}. */ public Attribute(String name, Object value, String role, AttributeType type) { this.name = name; this.value = value; setType(type); setRole(role); }
/** {@inheritDoc} */ @Override public void begin(String namespace, String name, Attributes attributes) throws Exception { Attribute attribute = (Attribute) digester.peek(); attribute.setValue(attributes.getValue("value")); attribute.setExpression(attributes.getValue("expression")); attribute.setRole(attributes.getValue("role")); attribute.setRenderer(attributes.getValue("type")); } }
/** {@inheritDoc} */ @Override public void begin(String namespace, String name, Attributes attributes) { Attribute attribute = (Attribute) digester.peek(); attribute.setValue(attributes.getValue("value")); String expression = attributes.getValue("expression"); attribute.setExpressionObject(Expression .createExpressionFromDescribedExpression(expression)); attribute.setRole(attributes.getValue("role")); attribute.setRenderer(attributes.getValue("type")); } }
/** {@inheritDoc} */ @Override public void begin(String namespace, String name, Attributes attributes) throws Exception { Definition definition = (Definition) digester.peek(); definition.setName(attributes.getValue("name")); definition.setPreparer(attributes.getValue("preparer")); definition.setExtends(attributes.getValue("extends")); String template = attributes.getValue("template"); Attribute attribute = Attribute.createTemplateAttribute(template); attribute.setExpression(attributes.getValue("templateExpression")); attribute.setRole(attributes.getValue("role")); String templateType = attributes.getValue("templateType"); if (templateType != null) { attribute.setRenderer(templateType); } definition.setTemplateAttribute(attribute); } }
/** {@inheritDoc} */ @Override protected void render() throws IOException { Attribute templateAttribute = Attribute .createTemplateAttribute(template); templateAttribute.setRole(role); attributeContext.setPreparer(preparer); attributeContext.setTemplateAttribute(templateAttribute); renderContext(); }
/** {@inheritDoc} */ public Attribute computeAttribute(TilesContainer container, Attribute attribute, String name, String role, boolean ignore, Object defaultValue, String defaultValueRole, String defaultValueType, Request request) { if (attribute == null) { AttributeContext evaluatingContext = container .getAttributeContext(request); attribute = evaluatingContext.getAttribute(name); if (attribute == null) { attribute = computeDefaultAttribute(defaultValue, defaultValueRole, defaultValueType); if (attribute == null && !ignore) { throw new NoSuchAttributeException("Attribute '" + name + "' not found."); } } } if (attribute != null && role != null && !"".equals(role.trim())) { attribute = new Attribute(attribute); attribute.setRole(role); } return attribute; }
/** {@inheritDoc} */ @Override public void begin(String namespace, String name, Attributes attributes) { Definition definition = (Definition) digester.peek(); definition.setName(attributes.getValue("name")); definition.setPreparer(attributes.getValue("preparer")); String extendsAttribute = attributes.getValue("extends"); definition.setExtends(extendsAttribute); String template = attributes.getValue("template"); Attribute attribute = Attribute.createTemplateAttribute(template); attribute.setExpressionObject(Expression .createExpressionFromDescribedExpression(attributes .getValue("templateExpression"))); attribute.setRole(attributes.getValue("role")); String templateType = attributes.getValue("templateType"); if (templateType != null) { attribute.setRenderer(templateType); } else if (extendsAttribute != null && templateType == null) { attribute.setRenderer(null); } definition.setTemplateAttribute(attribute); } }
/** * Creates a template attribute, starting from the name of the template. * * @param template The template that will be rendered. * @param templateExpression The template expression that will be evaluated * to a template. * @param templateType The type, or renderer, of the template. If null, the * default <code>template</code> will be used. * @param role The comma-separated roles for which the template is * authorized to be rendered. * @return The template attribute. * @since 2.2.2 */ public static Attribute createTemplateAttribute(String template, String templateExpression, String templateType, String role) { Attribute templateAttribute = createTemplateAttribute(template); templateAttribute.setRole(role); if (templateType != null) { templateAttribute.setRenderer(templateType); } templateAttribute .setExpressionObject(Expression .createExpressionFromDescribedExpression(templateExpression)); return templateAttribute; }
/** * Creates the definition to store. * * @param name The name of the definition to create. If not specified, an * anonymous definition will be created. * @param template The template of this definition. * @param role A comma-separated list of roles. If present, the definition * will be rendered only if the current user belongs to one of the roles. * @param extendsParam The definition name that this definition extends. * @param preparer The preparer to use to invoke before the definition is * rendered. * @return The created definition. */ private Definition createDefinition(String name, String template, String role, String extendsParam, String preparer) { Definition definition = new Definition(); definition.setName(name); Attribute templateAttribute = Attribute .createTemplateAttribute(template); templateAttribute.setRole(role); definition.setTemplateAttribute(templateAttribute); definition.setExtends(extendsParam); definition.setPreparer(preparer); return definition; }
/** {@inheritDoc} */ public int doStartTag() throws TilesJspException { definition = new Definition(); definition.setName(name); Attribute templateAttribute = Attribute .createTemplateAttribute(template); templateAttribute.setRole(role); definition.setTemplateAttribute(templateAttribute); definition.setExtends(extend); definition.setPreparer(preparer); TilesContainer c = JspUtil.getCurrentContainer(pageContext); if (c == null) { throw new TilesJspException("TilesContainer not initialized"); } if (!(c instanceof MutableTilesContainer)) { throw new TilesJspException( "Unable to define definition for a " + "container which does not implement MutableTilesContainer"); } container = (MutableTilesContainer) c; return EVAL_BODY_INCLUDE; }
/** * Replaces variables into an attribute. * * @param attr The attribute to be used as a basis, containing placeholders * for variables. * @param vars The variables to replace. * @return A new instance of an attribute, whose properties have been * replaced with variables' values. */ private Attribute replaceVarsInAttribute(Attribute attr, Map<Integer, String> vars) { Attribute nuattr = new Attribute(); nuattr.setRole(replace(attr.getRole(), vars)); nuattr.setRenderer(attr.getRenderer()); nuattr.setExpression(attr.getExpression()); Object value = attr.getValue(); if (value instanceof String) { value = replace((String) value, vars); } nuattr.setValue(value); return nuattr; }
protected Attribute buildPutAttribute(TilesPutAttribute putAttribute) { Attribute attribute = new Attribute(); attribute.setValue(getValueOrNull(putAttribute.value())); String expression = getValueOrNull(putAttribute.expression()); attribute.setExpressionObject(Expression.createExpressionFromDescribedExpression(expression)); attribute.setRole(getValueOrNull(putAttribute.role())); attribute.setRenderer(getValueOrNull(putAttribute.type())); return attribute; }
protected Attribute buildAddAttribute(TilesAddAttribute addAttribute) { Attribute attribute = new Attribute(); attribute.setValue(getValueOrNull(addAttribute.value())); String expression = getValueOrNull(addAttribute.expression()); attribute.setExpressionObject(Expression.createExpressionFromDescribedExpression(expression)); attribute.setRole(getValueOrNull(addAttribute.role())); attribute.setRenderer(getValueOrNull(addAttribute.type())); return attribute; }
protected Attribute buildTemplateAttribute(TilesDefinition tilesDef) { // see tiles DigesterDefinitionsReader Attribute attribute = Attribute.createTemplateAttribute(getValueOrNull(tilesDef.template())); String templateExpression = getValueOrNull(tilesDef.templateExpression()); Expression expression = Expression.createExpressionFromDescribedExpression(templateExpression); attribute.setExpressionObject(expression); attribute.setRole(getValueOrNull(tilesDef.role())); String templateType = getValueOrNull(tilesDef.templateType()); if (templateType != null) { attribute.setRenderer(templateType); } else if (getValueOrNull(tilesDef.extend()) != null && templateType == null) { attribute.setRenderer(null); } return attribute; }