Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentContext


    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
    wac.addMessage("code1", locale, "messageX");
    view.render(new HashMap(), request, response);

    assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
    ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
    assertNotNull(cc);
    PathAttribute attr = (PathAttribute) cc.getAttribute("content");
    assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());

    assertEquals(locale, Config.get(request, Config.FMT_LOCALE));
    LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
    assertEquals("messageX", lc.getResourceBundle().getString("code1"));
View Full Code Here


    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));

    view.render(new HashMap(), request, response);
    assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
    ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
    assertNotNull(cc);
    PathAttribute attr = (PathAttribute) cc.getAttribute("content");
    assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());

    LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
    assertEquals("message1", lc.getResourceBundle().getString("code1"));
    assertEquals("message2", lc.getResourceBundle().getString("code2"));
View Full Code Here

    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
    view.render(new HashMap(), request, response);
    assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
    ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
    assertNotNull(cc);
    PathAttribute attr = (PathAttribute) cc.getAttribute("content");
    assertEquals("/WEB-INF/jsp/otherContent.jsp", attr.getValue());
    assertEquals("testVal", request.getAttribute("testAttr"));

    view.render(new HashMap(), request, response);
    assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
    cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
    assertNotNull(cc);
    attr = (PathAttribute) cc.getAttribute("content");
    assertEquals("/WEB-INF/jsp/otherContent.jsp", attr.getValue());
    assertEquals("testVal", request.getAttribute("testAttr"));
  }
View Full Code Here

    public InsertHandler( Map attributes, String page, String role, Controller controller  )
      {
      this.page = page;
      this.role = role;
      this.controller = controller;
      subCompContext = new ComponentContext( attributes );
      }
View Full Code Here

    public InsertHandler( String page, String role, Controller controller )
      {
      this.page = page;
      this.role = role;
      this.controller = controller;
      subCompContext = new ComponentContext();
      }
View Full Code Here

                                 HttpServletRequest request,
                                 HttpServletResponse response)
                          throws IOException, ServletException
  {
    // Try to retrieve tile context
  ComponentContext context = ComponentContext.getContext( request );
    if( context == null )
      {
      throw new ServletException( "Can't find Tile context for '" + this.getClass().getName()
                                + "'. TilesAction subclasses must be called from a Tile" );
      }
View Full Code Here

     * @exception JspException if a JSP exception has occurred
     */
  public int doStartTag() throws JspException
    {
      // retrieve component context
    ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, pageContext.REQUEST_SCOPE);
    if( compContext == null )
        throw new JspException ( "Error - tag.useProperty : component context is not defined. Check tag syntax" );

      // set scope
    scope = TagUtils.getScope( scopeName, PageContext.PAGE_SCOPE );

      // push attribute in requested context.
    if( name != null )
      {
      Object value = compContext.getAttribute(name);
        // Check if value exist and if we must send a runtime exception
      if( value == null )
        if(!isErrorIgnored)
          throw new JspException ( "Error - tag.useProperty : property '"+ name + "' not found in context. Check tag syntax" );
         else
          return SKIP_BODY;

      pageContext.setAttribute(name, value, scope);
      }
     else
      { // set all attributes
      Iterator names = compContext.getAttributeNames();
      while(names.hasNext())
        {
        String name = (String)names.next();
        pageContext.setAttribute(name, compContext.getAttribute(name), scope);
        } // end loop
      } // end if

      // Continue processing this page
    return SKIP_BODY;
View Full Code Here

      {
        return EVAL_PAGE;
      } // end if

      // Get context
    ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, pageContext.REQUEST_SCOPE);

    if( compContext == null )
      throw new JspException ( "Error - tag.getAsString : component context is not defined. Check tag syntax" );

    Object value = compContext.getAttribute(attribute);
    if( value == null)
      { // no value : throw error or fail silently according to ignore
      if(isErrorIgnored == false )
        throw new JspException ( "Error - tag.getAsString : attribute '"+ attribute + "' not found in context. Check tag syntax" );
       else
View Full Code Here

  public int doStartTag() throws JspException
    {
    if( id==null )
      id=attributeName;
     
    ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, pageContext.REQUEST_SCOPE);
    if( compContext == null )
      throw new JspException ( "Error - tag.useAttribute : component context is not defined. Check tag syntax" );

    Object value = compContext.getAttribute(attributeName);
        // Check if value exist and if we must send a runtime exception
    if( value == null )
      if(!isErrorIgnored)
        throw new JspException ( "Error - tag.useAttribute : attribute '"+ attributeName + "' not found in context. Check tag syntax" );
       else
View Full Code Here

  public int doStartTag() throws JspException
    {
    if( id==null )
      id=property;
     
    ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, pageContext.REQUEST_SCOPE);

    if( compContext == null )
      throw new JspException ( "Error - tag.useProperty : component context is not defined. Check tag syntax" );

    Object value = compContext.getAttribute(property);
    if( value == null )
      throw new JspException ( "Error - tag.useProperty : property '"+ property + "' not found in context. Check tag syntax" );

    if( scopeName != null )
      {
View Full Code Here

TOP

Related Classes of org.apache.struts.tiles.ComponentContext

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.