@Component public class AViewPreparer implements ViewPreparer { @Autowired private AutowiredBean autowiredBean; @Override public void execute(Request tilesRequest, AttributeContext attributeContext) throws PreparerException { attributeContext.putAttribute("tilesAttributeName", new Attribute("tilesAttributeValue")); } }
builder.append(SUFFIX); attributeContext.putAttribute("body", Attribute.createTemplateAttribute(builder.toString()));
/** * Executes before the tile view is rendered * * @param tilesRequest * @param attributeContext * @throws PreparerException */ public void execute(Request tilesRequest, AttributeContext attributeContext) throws PreparerException { String resourceType = (String) tilesRequest.getContext("request").get("resourceType"); LOG.debug("Preparing view for resource: {}", ""); if (resourceType != null && !resourceType.equals("")) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("editor.body.").append(resourceType); LOG.debug("View name to add is: {}", stringBuffer.toString()); if (hasDefinition(stringBuffer.toString(), tilesRequest)) { LOG.info("Found valid tiles body definition"); attributeContext.putAttribute("body", new Attribute(stringBuffer.toString())); } else { LOG.info("Tiles body definition not found. Using default definition."); } } else { LOG.warn("Resource type is null or empty. Using default view from 'tiles-editor.xml'."); } }
/** {@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} */ public void mutate(AttributeContext ctx, ServletRequest req) { Attribute attr = new Attribute(); attr.setRenderer("template"); attr.setValue(getRequestBase(req)); ctx.putAttribute(definitionAttributeName, attr); } }
/** * * @param actionUrl url should be start with "/" * @param request HttpServletRequest * @param response HttpServletResponse * @throws Exception Exception */ public static void render(String actionUrl, HttpServletRequest request, HttpServletResponse response) throws Exception { TilesContainer container = TilesAccess.getContainer( request.getSession().getServletContext()); AttributeContext attributeContext = container.startContext(request, response); Attribute attr = new Attribute(actionUrl); attributeContext.putAttribute("body", attr); container.render("main.layout", request, response); container.endContext(request, response); }
attributeContext = container.getAttributeContext(request); attributeContext.putAttribute(name, listAttribute, cascade);
attributeContext.putAttribute(name, attribute, cascade);
/** * <p> * Process nested ≶put> tag. * <p/> * <p> * Places the value of the nested tag within the * {@link org.apache.tiles.AttributeContext}.It is the responsibility * of the descendent to check security. Security will be managed by * called tags. * </p> * * @param nestedTag the put tag desciendent. */ public void processNestedTag(PutAttributeTag nestedTag) { Attribute attribute = new Attribute( nestedTag.getValue(), null, nestedTag.getRole(), nestedTag.getType()); attributeContext.putAttribute(nestedTag.getName(), attribute, nestedTag .isCascade()); }
/** {@inheritDoc} */ public void processNestedTag(PutListAttributeTag nestedTag) { ListAttribute attribute = new ListAttribute(nestedTag.getAttributes()); attribute.setRole(nestedTag.getRole()); attribute.setInherit(nestedTag.getInherit()); attributeContext.putAttribute(nestedTag.getName(), attribute, nestedTag .isCascade()); } }
public void testRenderFragment_DynamicAttribute() throws Exception { ApplicationContext tilesAppContext = new WildcardServletApplicationContext(servletContext); Request tilesRequest = new ServletRequest(tilesAppContext, request, response); BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesAppContext); AttributeContext attributeContext = container.startContext(tilesRequest); attributeContext.putAttribute("body", new Attribute("/WEB-INF/dynamicTemplate.jsp")); Map<String, Attribute> resultMap = new HashMap<>(); ajaxTilesView.addRuntimeAttributes(container, tilesRequest, resultMap); assertNotNull(resultMap.get("body")); assertEquals("/WEB-INF/dynamicTemplate.jsp", resultMap.get("body").toString()); container.endContext(tilesRequest); }