Examples of ComponentContext


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

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

Examples of org.apache.struts.tiles.ComponentContext

        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

Examples of org.apache.struts.tiles.ComponentContext

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

Examples of org.apache.struts.tiles.ComponentContext

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

Examples of org.apache.struts.tiles.ComponentContext

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

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

Examples of org.apache.struts.tiles.ComponentContext

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

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

Examples of org.apache.struts.tiles.ComponentContext

     * 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

Examples of org.apache.tiles.ComponentContext

    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain)
        throws IOException, ServletException {

        TilesContainer container = TilesAccess.getContainer(servletContext);
        ComponentContext ctx = container.getComponentContext(request, response);

        ComponentAttribute attr = new ComponentAttribute();
        attr.setType(ComponentAttribute.TEMPLATE);
        attr.setName(targetAttributeName);
        attr.setValue(getTargetResource(request));
        ctx.putAttribute(targetAttributeName, attr);

        try {
            container.render(request, response, definition);
        } catch (TilesException e) {
            throw new ServletException("Error wrapping jsp with tile definition.", e);
View Full Code Here

Examples of org.oasisopen.sca.ComponentContext

        } catch (ServletException e) {
            throw new JspException("Exception initializing Tuscany webapp: " + e, e);
        }
        ServletContext servletContext = pageContext.getServletContext();
        ComponentContext componentContext = (ComponentContext)servletContext.getAttribute("org.oasisopen.sca.ComponentContext");
        Node scaDomain = null;
        if (componentContext == null) {
            scaDomain = (Node)servletContext.getAttribute(WebAppServletHost.SCA_NODE_ATTRIBUTE);
            if (scaDomain == null) {
                throw new JspException("SCADomain is null. Check Tuscany configuration in web.xml");
            }
        }

        Class<?> typeClass;
        try {
            typeClass = Class.forName(type, true, Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
            throw new JspException("Reference '" + name + "' type class not found: " + type);
        }

        Object o;
        try {
            if (componentContext != null) {
                o = componentContext.getService(typeClass, name);
            } else {
                o = scaDomain.getService(typeClass, name);
            }
        } catch (Exception e) {
            throw new JspException("Exception getting service for reference'" + name + "': " + e, e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.