Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentContext


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

     * @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 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

    if(debug)
      System.out.println( "Enter Rss Channel Action" );

          // Try to retrieve tile context
    ComponentContext context = ComponentContext.getContext( request );
    if( context == null )
      {
      throw new ServletException( "This action must be called by a Tile, not directly" );
      }

        ActionErrors errors = new ActionErrors();
        org.apache.commons.digester.rss.Channel channel = null;

        // -- Retrieve parameters --
        // Urls can come from a list, or from a single attribute.

        List channels = (List)context.getAttribute( CHANNEL_URLS_KEY );
        if( channels == null )
          {
          Object url = context.getAttribute( CHANNEL_URL_KEY );
          channels = new ArrayList(1);
          channels.add(url);
          }
            //channels.add("http://www.newsforge.com/newsforge.rss");
            //channels.add("http://xmlhack.com/rss.php");
            //channels.add("http://lwn.net/headlines/rss");
        // channels.trimToSize();

        if(debug)
          System.out.println( "urls count" + channels.size() ) ;
        // -- Loop through channels --
        ArrayList channelBeans = new ArrayList(channels.size());
        try {
            for (int i=0; i<channels.size(); i++) {
                RSSDigester digester = new RSSDigester();
                String url = (String)channels.get(i);
                  // Add application path if needed
                if( url.startsWith("/") )
                  {
                  url = toFullUrl( request, url );
                  }
                if(debugSystem.out.println( "Channel url=" + url) ;
                Channel obj = (Channel)digester.parse(url);
                if(debugSystem.out.println( "Channel:" + obj) ;
                //System.out.println( "Channel.items:" + obj.getI) ;
                channelBeans.add(obj);
            }
        }
        catch (Throwable t) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("rss.access.error"));
            servlet.log(t.toString());
        }

        // -- Handle Errors ---
        if (!errors.empty()) {
            saveErrors(request, errors);
            if (mapping.getInput()!=null)
                return (new ActionForward(mapping.getInput()));
            // If no input page, use error forwarding
         if(debug)
           System.out.println( "Exit Rss Channel Action : error" );
            return (mapping.findForward("error"));
        }

        // -- Save Bean, and Continue  ---

         if(debug)
           System.out.println( "Exit Rss Channel Action" );
        //request.setAttribute(CHANNELS_KEY,channelBeans);
          // Use Tile context to pass channels
        context.putAttribute( CHANNELS_KEY,channelBeans);
        return (mapping.findForward("continue"));
    } // ---- End perform ----
View Full Code Here

    if(debug)
      System.out.println( "Enter Rss Channel Action" );

          // Try to retrieve tile context
    ComponentContext context = ComponentContext.getContext( request );
    if( context == null )
      {
      throw new ServletException( "This action must be called by a Tile, not directly" );
      }

        ActionErrors errors = new ActionErrors();
        org.apache.commons.digester.rss.Channel channel = null;

        // -- Retrieve parameters --
        // Urls can come from a list, or from a single attribute.

        List channels = (List)context.getAttribute( CHANNEL_URLS_KEY );
        if( channels == null )
          {
          Object url = context.getAttribute( CHANNEL_URL_KEY );
          channels = new ArrayList(1);
          channels.add(url);
          }
            //channels.add("http://www.newsforge.com/newsforge.rss");
            //channels.add("http://xmlhack.com/rss.php");
            //channels.add("http://lwn.net/headlines/rss");
        // channels.trimToSize();

        if(debug)
          System.out.println( "urls count" + channels.size() ) ;
        // -- Loop through channels --
        ArrayList channelBeans = new ArrayList(channels.size());
        try {
            for (int i=0; i<channels.size(); i++) {
                RSSDigester digester = new RSSDigester();
                String url = (String)channels.get(i);
                  // Add application path if needed
                if( url.startsWith("/") )
                  {
                  url = toFullUrl( request, url );
                  }
                if(debugSystem.out.println( "Channel url=" + url) ;
                Channel obj = (Channel)digester.parse(url);
                if(debugSystem.out.println( "Channel:" + obj) ;
                //System.out.println( "Channel.items:" + obj.getI) ;
                channelBeans.add(obj);
            }
        }
        catch (Throwable t) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("rss.access.error"));
            servlet.log(t.toString());
        }

        // -- Handle Errors ---
        if (!errors.empty()) {
            saveErrors(request, errors);
            if (mapping.getInput()!=null)
                return (new ActionForward(mapping.getInput()));
            // If no input page, use error forwarding
         if(debug)
           System.out.println( "Exit Rss Channel Action : error" );
            return (mapping.findForward("error"));
        }

        // -- Save Bean, and Continue  ---

         if(debug)
           System.out.println( "Exit Rss Channel Action" );
        //request.setAttribute(CHANNELS_KEY,channelBeans);
          // Use Tile context to pass channels
        context.putAttribute( CHANNELS_KEY,channelBeans);
        return (mapping.findForward("continue"));
    } // ---- End perform ----
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

                               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

     */
    public static Object findAttribute( String beanName,
                                        PageContext pageContext )
      {
      Object attribute;
      ComponentContext compContext = ComponentContext.getContext(pageContext.getRequest());
      if( compContext != null )
        {
        attribute =  compContext.findAttribute( beanName, pageContext );
        if( attribute != null )
          return attribute;
        } // end if

        // Search in pageContext scopes
View Full Code Here

    public static Object getAttribute( String beanName, int scope,
                                       PageContext pageContext )
      {
      if( scope == ComponentConstants.COMPONENT_SCOPE )
        {
        ComponentContext compContext = ComponentContext.getContext(pageContext.getRequest());
        return compContext.getAttribute( beanName );
        }
      return pageContext.getAttribute( beanName, scope );
      }
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.