Hello,

  If you are in a tile controller, you don't have to create a new
ComponentDefinition, you can set the attributes of the current tiles (because you
are in the controller).
  To add / overload an attribute in the context, do something like :
  String attribute = (String)context.getAttribute("attributeName");
  attribute = "new value";
  context.setAttribute("attributeName", attribute);

  To add a list, create the list, add elements, and add the list to context.
  You can overload a previously defined list. Do not modify content of an
existing list, because it is shared between inherited instances. :

   List list = new java.util.ArrayList();
  list.add( "a value" );
  list.add( "another value");
  context.setAttribute("listAttributeName", list);

  Hope this help,

    Cedric

P.S. :
The DefinitionsUtil.setActionDefinition( aDefinition ); is to be used when you
are inside a Struts action called by Struts mechanism.
  It has not effect when used inside a tile controller
Chris Cool wrote:

> Hi,
>
> I have a tile that reads items from a PutList list and then inserts each
> item into the current page.
>
>    <struts_logic:iterate id="item" name="itemList" scope="page"
> type="String">
>        <tiles:insert name='<%=item%>' flush="true"/>
>    </struts_logic:iterate>
>
> When the items in the list are tiles defined in my tileDefinitions.xml file,
> the tiles are inserted into my JSP correctly. However, I want to dynamically
> create a tile definition and insert it into the page context.
>
> I am generating the ComponentDefinition in my tile controller and accessing
> the "itemList" where I add the name of the dynamically generated definition:
>
>       /* get the item list and insert new tile def into it */
>       ArrayList itemList = (ArrayList)context.getAttribute("itemList");
>       if (itemList != null) {
>
>         HashMap map = new HashMap();
>         map.put("name", "newtarget");
>         map.put("link", "newtarget.do");
>
>         ComponentDefinition newItem =
>                         new ComponentDefinition("new.item",
>                                           "/mytiles/simpleItem.jsp",
>                                                         map);
>
>         DefinitionsUtil.setActionDefinition( request, breadCrumbItem );
>         itemList.add("new.item");
>       }
>
> In my tile, the "itemList" contains the "new.item" entry, but it does not
> appear to find the ComponentDefinition I created.
>
> Thanks for you help.
>
> Chris
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to