Package org.apache.tiles

Examples of org.apache.tiles.AttributeContext


  }

  public void testRenderFragment_DynamicAttribute() throws Exception {
    BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getCurrentContainer(request, servletContext);
    Object[] requestItems = new Object[] { request, response };
    AttributeContext attributeContext = container.startContext(requestItems);
    attributeContext.putAttribute("body", new Attribute("/WEB-INF/dynamicTemplate.jsp"));
    Map<String, Attribute> resultMap = new HashMap<String, Attribute>();
    ajaxTilesView.addRuntimeAttributes(container, resultMap, request, response);
    assertNotNull(resultMap.get("body"));
    assertEquals("/WEB-INF/dynamicTemplate.jsp", resultMap.get("body").toString());
    container.endContext(requestItems);
View Full Code Here


  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<String, Attribute>();
    ajaxTilesView.addRuntimeAttributes(container, tilesRequest, resultMap);
    assertNotNull(resultMap.get("body"));
    assertEquals("/WEB-INF/dynamicTemplate.jsp", resultMap.get("body").toString());
    container.endContext(tilesRequest);
View Full Code Here

     *
     * @param tilesContext The request context to use.
     * @return The newly created attribute context.
     */
    private AttributeContext startContext(TilesRequestContext tilesContext) {
        AttributeContext context = new BasicAttributeContext();
        BasicAttributeContext.pushContext(context, tilesContext);
        return context;
    }
View Full Code Here

     *
     * @param tilesContext The request context to use.
     * @return The current attribute context.
     */
    private AttributeContext getAttributeContext(TilesRequestContext tilesContext) {
        AttributeContext context = BasicAttributeContext.getContext(tilesContext);
        if (context == null) {
            context = new BasicAttributeContext();
            BasicAttributeContext.pushContext(context, tilesContext);
        }
        return context;
View Full Code Here

        if (preparer == null) {
            throw new NoSuchPreparerException("Preparer '" + preparerName + " not found");
        }

        AttributeContext attributeContext = BasicAttributeContext.getContext(context);

        preparer.execute(context, attributeContext);
    }
View Full Code Here

            LOG.info("Access to definition '" + definitionName
                    + "' denied.  User not in role '" + definition.getRole());
            return;
        }

        AttributeContext originalContext = getAttributeContext(request);
        BasicAttributeContext subContext = new BasicAttributeContext(originalContext);
        subContext.addMissing(definition.getAttributes());
        BasicAttributeContext.pushContext(subContext, request);

        try {
View Full Code Here

   * @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);
    }
  }
View Full Code Here

        TilesContainer container = TilesAccess.getContainer(
                request.getSession().getServletContext());
        if(log.isDebugEnabled()){
            log.debug("Rendering tiles main.layout with page : "+actionUrl+"("+request.getSession().getId()+")");         
        }
        AttributeContext attributeContext = container.startContext(request, response);
        Attribute attr = new Attribute(actionUrl);
        attributeContext.putAttribute("body", attr);
        try {
            container.render("main.layout", request, response);
            container.endContext(request, response);
        } catch (Exception e) {
            if (log.isDebugEnabled()) {  // Intentionally logged at debug level
View Full Code Here

        HttpServletResponse response = createMock(HttpServletResponse.class);
        FilterChain chain = createMock(FilterChain.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        Map<String, Object> applicationScope = createMock(Map.class);
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        expect(request.getAttribute("org.apache.tiles.decoration.PREVENT:tokenKey")).andReturn(null);
        expect(servletContext.getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE))
                .andReturn(applicationContext);
        expect(applicationContext.getApplicationScope()).andReturn(applicationScope);
View Full Code Here

        RequestDispatcher rd = EasyMock.createMock(RequestDispatcher.class);
        TilesApplicationContext applicationContext = new ServletTilesApplicationContext(
                servletContext);
        TilesRequestContext requestContext = new ServletTilesRequestContext(
                applicationContext, request, response);
        AttributeContext attributeContext = EasyMock
                .createMock(AttributeContext.class);

        EasyMock.expect(request.getRequestDispatcher("/my/url.do"))
                .andReturn(rd);
        rd.include(request, response);
View Full Code Here

TOP

Related Classes of org.apache.tiles.AttributeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.