Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentContext


     */
    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 Exception {

        // 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 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" );
        }

      pageContext.setAttribute(name, value, scope);
      }
     else
      { // set all attributes
      Iterator names = compContext.getAttributeNames();
      while(names.hasNext())
        {
        String name = (String)names.next();
        if(name == null ) {
          if(!isErrorIgnored)
            throw new JspException ( "Error - tag importAttribute : "
                + "encountered an attribute with key 'null'" );
          else
            return SKIP_BODY;
        }

        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 + "' has a value of '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

            }
           
            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

            }
           
            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

    if (definition == null) {
      throw new ServletException("No Tiles definition found for name '" + getUrl() + "'");
    }

    // get current component context
    ComponentContext context = getComponentContext(definition, request);

    // execute component controller associated with definition, if any
    Controller controller = getController(definition, request);
    if (controller != null) {
      if (logger.isDebugEnabled()) {
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.