Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentContext


     * @return requested bean or null if not found.
     */
    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

                               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

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

     * @param pageContext Current pageContext.
     * @return requested bean or null if not found.
     */
    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

     * @param pageContext Current pageContext.
     * @return requested bean or null if not found.
     */
    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

    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

    System.out.println("Enter action SetPortalPrefsAction");
  HttpSession session = request.getSession();
  PortalPrefsForm prefsForm = (PortalPrefsForm)form;

          // 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" );
      }
View Full Code Here

    System.out.println("Enter action RetrievePortalAction");
      // Get current session.
    HttpSession session = request.getSession();

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

      // Get user portal list from user context
    PortalSettings settings = getSettings( context, session );

      // Set parameters for tiles
    context.putAttribute( "numCols", Integer.toString(settings.getNumCols()) );
    for( int i=0; i<settings.getNumCols(); i++ )
      context.putAttribute( "list"+i, settings.getListAt(i) );

    System.out.println("Exit action RetrievePortalAction");
    return (mapping.findForward("success"));
    }
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.