Package org.apache.struts.tiles

Examples of org.apache.struts.tiles.ComponentDefinition


      // Walk thru xml set and copy each definitions.
    Iterator i = xmlDefinitions.getDefinitions().values().iterator();
    while( i.hasNext() )
      {
      XmlDefinition xmlDefinition = (XmlDefinition)i.next();
        putDefinition( new ComponentDefinition( xmlDefinition) );
      // end loop
   }
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

  * @throws JspException InstantiationException Can't create requested controller
   */
  protected TagHandler processDefinitionName(String name) throws JspException {

    try {
        ComponentDefinition definition = TilesUtil.getDefinition(name, (HttpServletRequest)pageContext.getRequest(),pageContext.getServletContext());
        if (definition == null) { // is it possible ?
            throw new NoSuchDefinitionException();
        }
        return processDefinition(definition);

View Full Code Here

   * @return appropriate TagHandler
  * @throws JspException InstantiationException Can't create requested controller
   */
  public TagHandler processAsDefinitionOrURL(String name) throws JspException {
    try {
      ComponentDefinition definition = TilesUtil.getDefinition(name, pageContext.getRequest(), pageContext.getServletContext());
      if (definition != null)
        return processDefinition(definition);
    } catch (DefinitionsFactoryException ex) { // silently failed, because we can choose to not define a factory.
    }
    // no definition found, try as url
View Full Code Here

   public int doStartTag() throws JspException
   {
     // Do we extend a definition ?
   if( extendsDefinition != null && !extendsDefinition.equals("") )
     {
     ComponentDefinition parentDef = TagUtils.getComponentDefinition( extendsDefinition, pageContext );
     //if(log.isDebugEnabled())
         //log.debug( "parent definition=" + parentDef );
     definition = new ComponentDefinition( parentDef );
     // end if
    else
      definition = new ComponentDefinition();

      // Set definitions attributes
   if( page != null )
     definition.setTemplate(page);
   if( role != null )
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

         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

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.