/** * 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); } } }
public void execute(Request tilesContext, AttributeContext attributeContext) { invoked = true; assertTrue(attributeContext.getAttribute("searchNavigation") != null); }
@Override public void render(final String path, final Request request) throws IOException { Matcher matcher = OPTIONS_PATTERN.matcher((String) path); if (null != matcher && matcher.find()) { boolean done = false; String match = matcher.group(1); ListAttribute fallbacks = (ListAttribute) TilesAccess .getCurrentContainer(request) .getAttributeContext(request) .getAttribute(match); if (null == fallbacks) { throw new IllegalStateException("A matching list-attribute name=\"" + match + "\" must be defined."); } else if (fallbacks.getValue().isEmpty()) { throw new IllegalStateException( "list-attribute name=\"" + match + "\" must have minimum one attribute"); } for (Attribute option : (List<Attribute>) fallbacks.getValue()) { String template = path.replaceFirst(Pattern.quote(matcher.group()), (String) option.getValue()); done = renderAttempt(template, request); if (done) { break; } } if (!done) { throw new IOException("None of the options existed for " + path); } } else { renderer.render(path, request); } }
while (iterator.hasNext()) { final String attributeName = iterator.next(); resultMap.put(attributeName, attributeContext.getAttribute(attributeName));
while (iterator.hasNext()) { final String attributeName = iterator.next(); resultMap.put(attributeName, attributeContext.getAttribute(attributeName));
/** * 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); } } }
while (iterator.hasNext()) { final String attributeName = iterator.next(); resultMap.put(attributeName, attributeContext.getAttribute(attributeName));
boolean ignore, Map<String, Object> attributes, Request request) { Attribute attr = attributeContext.getAttribute(name); if (attr != null) { try {
/** * <p> * Iterate over dynamically added Tiles attributes (see "Runtime Composition" in the Tiles documentation) and add * them to the output Map passed as input. * </p> * * @param container the Tiles container * @param resultMap the output Map where attributes of interest are added to. * @param request the Servlet request * @param response the Servlet response */ protected void addRuntimeAttributes(BasicTilesContainer container, Map<String, Attribute> resultMap, HttpServletRequest request, HttpServletResponse response) { AttributeContext attributeContext = container.getAttributeContext(new Object[] { request, response }); Set<String> attributeNames = new HashSet<String>(); 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); } } }
/** * 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<String>(); 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); } } }
Attribute attr = attributeContext.getAttribute(name);
/** * Computes the attribute to render, evaluating the various tag attributes. * * @param context The page context. * @return The computed attribute. */ private Attribute computeAttribute(PageContext context) { Attribute attribute = (Attribute) value; if (attribute == null) { AttributeContext evaluatingContext = container .getAttributeContext(context); attribute = evaluatingContext.getAttribute(name); if (attribute == null) { attribute = computeDefaultAttribute(); if (attribute == null && !ignore) { throw new NoSuchAttributeException("Attribute '" + name + "' not found."); } } } return attribute; }
/** {@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; }
/** * Returns an attribute. * * @param key The name of the attribute to get. * @return The Attribute. * @since 2.2.0 */ public Attribute get(String key) { Request velocityRequest = createVelocityRequest(getServletContext(), null); TilesContainer container = TilesAccess.getCurrentContainer(velocityRequest); AttributeContext attributeContext = container .getAttributeContext(velocityRequest); Attribute attribute = attributeContext.getAttribute(key); return attribute; }
attribute = attributeContext.getAttribute(name); if ((attribute == null || attribute.getValue() == null) && ignore) { return SKIP_BODY;