/** * Iterate over dynamically added Tiles attributes (see "Runtime Composition" * in the Tiles documentation) and add them to the output Map passed as input. * * @param container the Tiles container * @param tilesRequest the Tiles request * @param resultMap the output Map where attributes of interest are added to. */ protected void addRuntimeAttributes(BasicTilesContainer container, Request tilesRequest, Map<String, Attribute> resultMap) { AttributeContext attributeContext = container.getAttributeContext(tilesRequest); Set<String> attributeNames = new HashSet<>(); if (attributeContext.getLocalAttributeNames() != null) { attributeNames.addAll(attributeContext.getLocalAttributeNames()); } if (attributeContext.getCascadedAttributeNames() != null) { attributeNames.addAll(attributeContext.getCascadedAttributeNames()); } for (String name : attributeNames) { Attribute attr = attributeContext.getAttribute(name); resultMap.put(name, attr); } } }
if (definition.getLocalAttributeNames() != null) { attributeNames.addAll(definition.getLocalAttributeNames()); if (definition.getCascadedAttributeNames() != null) { attributeNames.addAll(definition.getCascadedAttributeNames()); Attribute attribute = definition.getAttribute(attributeName); if (attribute.getValue() == null || !(attribute.getValue() instanceof String)) { continue; String value = attribute.getValue().toString(); if (value.startsWith("/")) { resultMap.put(attributeName, attribute); } else if (container.isValidDefinition(value, tilesRequest)) { resultMap.put(attributeName, attribute); Definition nestedDefinition = container.getDefinitionsFactory().getDefinition(value, tilesRequest); Assert.isTrue(nestedDefinition != definition, "Circular nested definition: " + value); flattenAttributeMap(container, tilesRequest, resultMap, nestedDefinition);
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { Definition def = (Definition) obj; return nullSafeEquals(name, def.name) && nullSafeEquals(inherit, def.inherit) && super.equals(def); }
ApplicationContext tilesAppContext = tilesRequest.getApplicationContext(); BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesAppContext); JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext)); Definition compositeDefinition = container.getDefinitionsFactory().getDefinition(getUrl(), tilesRequest); tilesRequest.getContext("request").put(ServletRequest.FORCE_INCLUDE_ATTRIBUTE_NAME, true); + "' could be found for the current view: " + this); container.startContext(tilesRequest).inheritCascadedAttributes(compositeDefinition); container.render(attributeToRender, tilesRequest); container.endContext(tilesRequest);
/** {@inheritDoc} */ public void mutate(AttributeContext ctx, ServletRequest req) { Attribute attr = new Attribute(); attr.setRenderer("template"); attr.setValue(getRequestBase(req)); ctx.putAttribute(definitionAttributeName, attr); } }
/** * Creates an attribute that is a copy of the one passed as a parameter. * * @param attribute The attribute to copy. * @return The copied attribute. * @since 2.2.0 */ public Attribute clone(Attribute attribute) { return new Attribute(attribute); }
/** * Returns the list of the attributes that are elements of this attribute. * * @return The attributes. * @since 3.0.0 */ @SuppressWarnings("unchecked") @Override public List<Attribute> getValue() { return (List<Attribute>) super.getValue(); }
@Override public AttributeContext startContext(Request request) { return container.startContext(request); } }
/** * Ends the context when exiting the tag. * * @param context The page context to use. */ protected void endContext(PageContext context) { if (attributeContext != null && container != null) { container.endContext(pageContext); } } }
/** {@inheritDoc} */ @Override public int hashCode() { return nullSafeHashCode(name) + nullSafeHashCode(inherit) + super.hashCode(); }
/** * Constructor. * Create a context and set specified attributes. * * @param attributes Attributes to initialize context. * @since 2.1.0 */ public BasicAttributeContext(Map<String, Attribute> attributes) { if (attributes != null) { this.attributes = deepCopyAttributeMap(attributes); } }
/** * Returns the original servlet context. * * @param context The application context. * @return The original servlet context, if found. * @deprecated Use {@link TilesApplicationContext#getContext()}. */ protected ServletContext getServletContext(TilesApplicationContext context) { return (ServletContext) context.getContext(); } }
/** * Constructor. * * @param value List. * @since 2.1.0 */ public ListAttribute(List<Attribute> value) { setValue(value); }
/** {@inheritDoc} */ @Override public int hashCode() { return nullSafeHashCode(expression) + nullSafeHashCode(language); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { ListAttribute attribute = (ListAttribute) obj; return super.equals(attribute) && this.inherit == attribute.inherit; }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { BasicAttributeContext bac = (BasicAttributeContext) obj; return nullSafeEquals(templateAttribute, bac.templateAttribute) && nullSafeEquals(preparer, bac.preparer) && nullSafeEquals(attributes, bac.attributes) && nullSafeEquals(cascadedAttributes, bac.cascadedAttributes); }
/** {@inheritDoc} */ public void mutate(AttributeContext ctx, javax.servlet.ServletRequest req) { Attribute attr = new Attribute(); attr.setRenderer("template"); attr.setValue(getRequestBase(req)); ctx.putAttribute(definitionAttributeName, attr); } }
/** {@inheritDoc} */ @Override public Attribute clone() { return new Attribute(this); } }
/** * Starts the context when entering the tag. * * @param context The page context to use. */ protected void startContext(PageContext context) { if (container != null) { attributeContext = container.startContext(pageContext); } }
/** {@inheritDoc} */ @Override public int hashCode() { return nullSafeHashCode(value) + nullSafeHashCode(renderer) + nullSafeHashCode(roles) + nullSafeHashCode(expressionObject); }