Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentDefinition


        }

        // Try to dispatch to requested definition
        try {
            // Read definition from factory, but we can create it here.
            ComponentDefinition definition =
                TilesUtil.getDefinition(
                    name,
                    request,
                    getServlet().getServletContext());
                   
View Full Code Here


    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

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

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

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

      if(debug)
        System.out.println( "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 );
          } // end loop
        }
       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;
          }
        extractItems( result, attribute, request, servletContext );
View Full Code Here

         HttpServletResponse response)
  throws IOException, ServletException {

    System.out.println( "Start dynamic definition" );
      // Create template definition
    ComponentDefinition definition = new ComponentDefinition();
    String path = "/tutorial";
      // set definition 'contents'
    //definition.setTemplate( "/tutorial/basic/myFramesetLayout.jsp" );
    definition.put( "title", "My first dynamic frameset page", true );
      // using type="string" is the same as direct=true
    definition.put( "header", path + "/common/header.jsp", "string", null );
    definition.put( "footer", path + "/common/footer.jsp", true );
    definition.put( "menu", path + "/basic/menu.jsp", true );
    definition.put( "body", path + "/basic/helloBody.jsp", true );

    System.out.println( "definition=" + definition );
      // Save our definition as a bean :
    request.setAttribute( "templateDefinition", definition );
View Full Code Here

    */
   public DefinitionCatalog( String catalogName, HttpServletRequest request, ServletContext context)
     throws FactoryNotFoundException, DefinitionsFactoryException
   {
     // Get definition containing list of definitions
   ComponentDefinition catalogDef = DefinitionsUtil.getDefinition( catalogName, request, context);
   if(debug)
     System.out.println( "Got definition " + catalogDef );
     // Get list of definition names
   List list = (List)catalogDef.getAttribute( DEFINITION_LIST_ATTRIBUTE );
   Iterator i = list.iterator();
   while(i.hasNext() )
     {
     String name = (String)i.next();
     System.out.println( "add " + name );
     ComponentDefinition def = DefinitionsUtil.getDefinition(name, request, context);
     if(def==null)
       throw new NoSuchDefinitionException("Can't find definition '" + name + "'" );
     add( name, def );
     } // end loop
   if(debug)
View Full Code Here

      throw new ServletException( "Error - CustomSkinAction : attribute '"
                                  + LAYOUT_ATTRIBUTE
                                  + "' not found in Tile's attributes. Need it to select appropriate layout"  );

      // Get user current skin
    ComponentDefinition definition = getCurrentDefinition( context, request, getServlet().getServletContext() );
      // get requested layout from definition
    String layout = (String)definition.getAttribute(layoutKey);
    if(layout==null)
      throw new ServletException( "Error - CustomSkinAction : no layout defined for key '"
                                  + layoutKey
                                  + "' in currently selected skin '"
                                  + getUserSetting(context, request ) + "'."  );
View Full Code Here

  {
    // Get selected key
  String selected = getUserSetting(context, request);

  DefinitionCatalog catalog = getCatalog( context, request, servletContext);
  ComponentDefinition definition =  (ComponentDefinition)catalog.get( selected );
  if( definition == null )
    definition = (ComponentDefinition)catalog.getDefault();

  return definition;
  }
View Full Code Here

TOP

Related Classes of org.apache.struts.tiles.ComponentDefinition

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.