/** * Creates an attribute that represents a template. * * @param template The template. * @return The attribute. * @since 2.2.0 */ public Attribute createTemplateAttribute(String template) { return Attribute.createTemplateAttribute(template); }
/** * Constructor. * @param name The name of the definition. * @param template The template of the definition. * @param attributes The attribute map of the definition. * @deprecated Use {@link #Definition(String, Attribute, Map)}. */ public Definition(String name, String template, Map<String, Attribute> attributes) { this(name, Attribute.createTemplateAttribute(template), attributes); }
/** * Access method for the template property. * * @return the current value of the template property * @deprecated Use {@link #getTemplateAttribute()}. */ @Deprecated public String getTemplate() { if (templateAttribute == null) { templateAttribute = Attribute.createTemplateAttribute(null); } return (String) templateAttribute.getValue(); }
/** * Access method for the role property. * * @return the current value of the role property * @deprecated Use {@link #getTemplateAttribute()}. */ @Deprecated public String getRole() { if (templateAttribute == null) { templateAttribute = Attribute.createTemplateAttribute(null); } return templateAttribute.getRole(); }
/** * Sets the value of the template property. * * @param template the new value of the path property * @deprecated Use {@link #getTemplateAttribute()}. */ @Deprecated public void setTemplate(String template) { if (templateAttribute == null) { templateAttribute = Attribute.createTemplateAttribute(template); } else { templateAttribute.setValue(template); } }
/** * 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); }
/** {@inheritDoc} */ public Object mapRow(ResultSet rs, int row) throws SQLException { DbDefinition definition = new DbDefinition(); definition.setId(numberToLong((Number) rs.getObject("ID"))); definition.setName(rs.getString("NAME")); definition.setTemplateAttribute(Attribute .createTemplateAttribute(rs.getString("TEMPLATE"))); definition.setPreparer(rs.getString("PREPARER")); definition.setExtends(rs.getString("PARENT_NAME")); return definition; }
/** {@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} */ @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; }
AttributeContext attributeContext = container .getAttributeContext(request); Attribute templateAttribute = Attribute.createTemplateAttribute(template, templateExpression, templateType, role); attributeContext.setPreparer(preparer);
AttributeContext attributeContext = container .getAttributeContext(request); Attribute templateAttribute = Attribute.createTemplateAttribute(template, templateExpression, templateType, role); attributeContext.setPreparer(preparer);
/** * 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; }
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; }