Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentContext


            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

     * @exception JspException On errors processing tag.
     */
  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 importAttribute : no tiles context found." );

      // 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 importAttribute : 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

      // Do a local copy of id
    String localId=this.id;
    if( localId==null )
      localId=attributeName;

    ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
    if( compContext == null )
      throw new JspException ( "Error - tag useAttribute : no tiles context found." );

    Object value = compContext.getAttribute(attributeName);
        // Check if value exists 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

            }
           
            if (definition != null)
            {
                // if tiles-definition could be found set ComponentContext & viewId
                ComponentContext tileContext = ComponentContext.getContext(request);
                if (tileContext == null)
                {
                    tileContext = new ComponentContext(definition.getAttributes());
                    ComponentContext.setContext(tileContext, request);
                }
                else
                {
                    tileContext.addMissing(definition.getAttributes());
                }
                viewId = definition.getPage();
                // if a controller is defined for this tile, execute it
                Controller tilesController = definition.getOrCreateController();
                if (tilesController != null) {
View Full Code Here

     *
     * @param scope the named context scope to put the attributes into.
     */
    public void importAttributes(String scope)
    {
        ComponentContext context = getCurrentContext();
        Iterator names = context.getAttributeNames();

        if (scope.equals(PAGE_SCOPE))
        {
            while (names.hasNext())
            {
                String name = (String)names.next();
                velocityContext.put(name, context.getAttribute(name));
            }
        }
        else if (scope.equals(REQUEST_SCOPE))
        {
            while (names.hasNext())
            {
                String name = (String)names.next();
                request.setAttribute(name, context.getAttribute(name));
            }
        }
        else if (scope.equals(SESSION_SCOPE))
        {
            HttpSession session = request.getSession();
            while (names.hasNext())
            {
                String name = (String)names.next();
                session.setAttribute(name, context.getAttribute(name));
            }
        }
        else if (scope.equals(APPLICATION_SCOPE))
        {
            while (names.hasNext())
            {
                String name = (String)names.next();
                application.setAttribute(name, context.getAttribute(name));
            }
        }
    }
View Full Code Here

        if (role != null && !this.request.isUserInRole(role))
        {
            return null;
        }

        ComponentContext subCompContext = new ComponentContext();
        return doInsert(subCompContext, page, role, controller);
    }
View Full Code Here

        if (role != null && !this.request.isUserInRole(role))
        {
            return null;
        }

        ComponentContext subCompContext = new ComponentContext(attributes);
        return doInsert(subCompContext, page, role, controller);
    }
View Full Code Here

     * Pops the tiles sub-context off the context-stack after the lower level
     * tiles have been rendered.
     */
    protected void popTilesContext()
    {
        ComponentContext context = (ComponentContext)this.contextStack.pop();
        ComponentContext.setContext(context, this.request);
    }
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.