Examples of ComponentDefinition


Examples of org.apache.struts.tiles.ComponentDefinition

     */
    protected String processAsDefinitionOrURL(String name) throws Exception
    {
        try
        {
            ComponentDefinition definition =
                    TilesUtil.getDefinition(name, this.request, this.application);
            if (definition != null)
            {
                return processDefinition(definition);
            }
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

            tilesId = tilesId  + tilesExtension;
        }
        ServletRequest request = (ServletRequest)externalContext.getRequest();
        ServletContext servletContext = (ServletContext)externalContext.getContext();

        ComponentDefinition definition = null;
        try
        {
            definition = getDefinitionsFactory().getDefinition(tilesId, request, servletContext);
           
            if (definition == null)
            {
                /**
                 * Check for the definition without the leading '/' character.  Allows user to specify Tiles definitions without a
                 * leading '/' char.
                 */
                int slashIndex = tilesId.indexOf("/");
                if (slashIndex == 0)
                {
                    tilesId = tilesId.substring(1);
                    definition = getDefinitionsFactory().getDefinition(tilesId, request, servletContext);
                }
            }
           
            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) {
                    ServletResponse response = (ServletResponse) externalContext.getResponse();
                    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
                        try {
                            tilesController.execute(tileContext, (HttpServletRequest) request,
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

            tilesId = tilesId  + tilesExtension;
        }
        ServletRequest request = (ServletRequest)externalContext.getRequest();
        ServletContext servletContext = (ServletContext)externalContext.getContext();

        ComponentDefinition definition = null;
        try
        {
            definition = getDefinitionsFactory().getDefinition(tilesId, request, servletContext);
           
            if (definition == null)
            {
                /**
                 * Check for the definition without the leading '/' character.  Allows user to specify Tiles definitions without a
                 * leading '/' char.
                 */
                int slashIndex = tilesId.indexOf("/");
                if (slashIndex == 0)
                {
                    tilesId = tilesId.substring(1);
                    definition = getDefinitionsFactory().getDefinition(tilesId, request, servletContext);
                }
            }
           
            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) {
                    ServletResponse response = (ServletResponse) externalContext.getResponse();
                    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
                        try {
                            tilesController.execute(tileContext, (HttpServletRequest) request,
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

   */
  protected String prepareForRendering(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    // get component definition
    ComponentDefinition definition = getComponentDefinition(this.definitionsFactory, request);
    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()) {
        logger.debug("Executing Tiles controller [" + controller + "]");
      }
      executeController(controller, context, request, response);
    }

    // determine the path of the definition
    String path = getDispatcherPath(definition, request);
    if (path == null) {
      throw new ServletException(
          "Could not determine a path for Tiles definition '" + definition.getName() + "'");
    }

    return path;
  }
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

    if( param != null )
      {
      try
        {
          // Read definition from factory, but we can create it here.
        ComponentDefinition definition = DefinitionsUtil.getDefinition( param, request, getServlet().getServletContext() );
        //definition.putAttribute( "attributeName", "aValue" );
        DefinitionsUtil.setActionDefinition( request, definition);
        }
       catch( FactoryNotFoundException ex )
        {
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

    log.debug("Extract menu item from '" + object + "'");

    if (object instanceof String) { // definition name
      try {
        ComponentDefinition def =
          DefinitionsUtil.getDefinition(
            (String) object,
            request,
            servletContext);

        extractItems(result, def, request, servletContext);

      } catch (Exception ex) { // silently fail
      }

    } else if (object instanceof List) {
      List list = (List) object;
      Iterator iter = list.iterator();
      while (iter.hasNext()) {
        extractItems(result, iter.next(), request, servletContext);
      }

    } else if (object instanceof ComponentDefinition) {
      ComponentDefinition definition = (ComponentDefinition) object;
      Object attribute = definition.getAttribute("items");
      if (attribute == null) {
        attribute = definition.getAttribute("list");
      }

      if (attribute == null) {
        return;
      }
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

  @Override
  protected String prepareForRendering(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    // get component definition
    ComponentDefinition definition = getComponentDefinition(this.definitionsFactory, request);
    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()) {
        logger.debug("Executing Tiles controller [" + controller + "]");
      }
      executeController(controller, context, request, response);
    }

    // determine the path of the definition
    String path = getDispatcherPath(definition, request);
    if (path == null) {
      throw new ServletException(
          "Could not determine a path for Tiles definition '" + definition.getName() + "'");
    }

    return path;
  }
View Full Code Here

Examples of org.apache.struts.tiles.ComponentDefinition

   */
  protected String prepareForRendering(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    // get component definition
    ComponentDefinition definition = getComponentDefinition(this.definitionsFactory, request);
    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()) {
        logger.debug("Executing Tiles controller [" + controller + "]");
      }
      executeController(controller, context, request, response);
    }

    // determine the path of the definition
    String path = getDispatcherPath(definition, request);
    if (path == null) {
      throw new ServletException(
          "Could not determine a path for Tiles definition '" + definition.getName() + "'");
    }

    return path;
  }
View Full Code Here

Examples of org.apache.tiles.definition.ComponentDefinition

     * Tests the inheritance properties of ComponentDefinition objects.
     */
    public void testResolveInheritances() {
        Map defs = new HashMap();
       
        ComponentDefinition def = new ComponentDefinition();
        def.setName("parent.def1");
        def.setTemplate("/test1.jsp");
        ComponentAttribute attr = new ComponentAttribute();
        attr.setName("attr1");
        attr.setValue("value1");
        def.addAttribute(attr);
        defs.put(def.getName(), def);
       
        def = new ComponentDefinition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new ComponentAttribute();
        attr.setName("attr1");
        attr.setValue("New value");
        def.addAttribute(attr);
        defs.put(def.getName(), def);
       
        ComponentDefinitions definitions = new ComponentDefinitionsImpl();
        try {
            definitions.addDefinitions(defs);
        } catch (NoSuchDefinitionException e) {
View Full Code Here

Examples of org.apache.tiles.definition.ComponentDefinition

    /**
     * Tests the inheritance with localized definitions.
     */
    public void testLocalizedResolveInheritances() {
        Map defs = new HashMap();
        ComponentDefinition def = new ComponentDefinition();
        def.setName("parent.def1");
        def.setTemplate("/test1.jsp");
        ComponentAttribute attr = new ComponentAttribute();
        attr.setName("attr1");
        attr.setValue("value1");
        def.addAttribute(attr);
        defs.put(def.getName(), def);
       
        def = new ComponentDefinition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new ComponentAttribute();
        attr.setName("attr1");
        attr.setValue("New value");
        def.addAttribute(attr);
        defs.put(def.getName(), def);

        Map localDefs = new HashMap();
        def = new ComponentDefinition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new ComponentAttribute();
        attr.setName("attr1");
        attr.setValue("US Value");
        def.addAttribute(attr);
        localDefs.put(def.getName(), def);

        ComponentDefinitions definitions = new ComponentDefinitionsImpl();
        try {
            definitions.addDefinitions(defs);
            definitions.addDefinitions(localDefs, Locale.US);
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.