Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentContext


    /**
     * @param pageContext
     */
    public static void dumpComponentContext(PageContext pageContext) {
        ComponentContext compContext = (ComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT,
            PageContext.REQUEST_SCOPE);
        if (log.isInfoEnabled())
            log.info("Component context dump");
        for (Iterator e = compContext.getAttributeNames(); e.hasNext();) {
            String n = (String) e.next();
            Object value = compContext.getAttribute(n);
            if (log.isInfoEnabled())
                log.info("   " + n + " = " + value);
        }
    }
View Full Code Here


     * Dump tile attributes to {@link System#err}.
     *
     * @param pageContext page context from which to get tile.
     */
    public static void dumpTileScope(PageContext pageContext) {
        ComponentContext compContext = (ComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT,
            PageContext.REQUEST_SCOPE);
        System.err.println("Tile attributes");
        for (Iterator i = compContext.getAttributeNames(); i.hasNext();) {
            String n = (String) i.next();
            System.err.println("   " + n + " = " + compContext.getAttribute(n));
        }
    }
View Full Code Here

     */
    public String getTileIncludePath(PageContext pageContext) {
        if(includePath != null) {
            return includePath;
        }
        ComponentContext cc = ((ComponentContext) pageContext.getAttribute(
            ComponentConstants.COMPONENT_CONTEXT,
            PageContext.REQUEST_SCOPE));
        return (String)cc.getAttribute(includeAttribute);
    }
View Full Code Here

     * @param beanName Name of bean to retrieve.
     * @param pageContext Current pageContext.
     * @return Requested bean or <code>null</code> if not found.
     */
    public static Object findAttribute(String beanName, PageContext pageContext) {
        ComponentContext compContext = ComponentContext.getContext(pageContext.getRequest());

        if (compContext != null) {
            Object attribute = compContext.findAttribute(beanName, pageContext);
            if (attribute != null) {
                return attribute;
            }
        }

View Full Code Here

     * @param pageContext Current pageContext.
     * @return Requested bean or <code>null</code> 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

      {
      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

    public  int  doStartTag()  throws  JspException
        {
        ifid==null  )
            id=property;

        ComponentContext  compContext  =  (ComponentContext)pageContext.getAttributeComponentConstants.COMPONENT_CONTEXT,  PageContext.REQUEST_SCOPE);

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

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

        ifscopeName  !=  null  )
            {
View Full Code Here

            log.debug("NoSuchDefinitionException " + ex.getMessage());
        }

        // Do we do a forward (original behavior) or an include ?
        boolean doInclude = false;
        ComponentContext tileContext = null;

        // Get current tile context if any.
        // If context exists, or if the response has already been committed we will do an include
        tileContext = ComponentContext.getContext(sacontext.getRequest());
        doInclude = (tileContext != null || sacontext.getResponse().isCommitted());

        // Controller associated to a definition, if any
        Controller controller = null;

        // Computed uri to include
        String uri = null;

        if (definition != null)
        {
            // We have a "forward config" definition.
            // We use it to complete missing attribute in context.
            // We also get uri, controller.
            uri = definition.getPath();
            controller = definition.getOrCreateController();

            if (tileContext == null) {
                tileContext =
                        new ComponentContext(definition.getAttributes());
                ComponentContext.setContext(tileContext, sacontext.getRequest());

            } else {
                tileContext.addMissing(definition.getAttributes());
            }
        }

        // Process definition set in Action, if any.  This may override the
        // values for uri or controller found using the ForwardConfig, and
        // may augment the tileContext with additional attributes.
        // :FIXME: the class DefinitionsUtil is deprecated, but I can't find
        // the intended alternative to use.
        definition = DefinitionsUtil.getActionDefinition(sacontext.getRequest());
        if (definition != null) { // We have a definition.
                // We use it to complete missing attribute in context.
                // We also overload uri and controller if set in definition.
                if (definition.getPath() != null) {
                    log.debug("Override forward uri "
                              + uri
                              + " with action uri "
                              + definition.getPath());
                        uri = definition.getPath();
                }

                if (definition.getOrCreateController() != null) {
                    log.debug("Override forward controller with action controller");
                        controller = definition.getOrCreateController();
                }

                if (tileContext == null) {
                        tileContext =
                                new ComponentContext(definition.getAttributes());
                        ComponentContext.setContext(tileContext, sacontext.getRequest());
                } else {
                        tileContext.addMissing(definition.getAttributes());
                }
        }


        if (uri == null) {
View Full Code Here

      Controller controller) {

      this.page = page;
      this.role = role;
      this.controller = controller;
      subCompContext = new ComponentContext(attributes);
    }
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.