Hi,
There is several way to have "dynamic definition".
The first one is to write your own definitions factory implementing
'ComponentDefinitionsFactory'. The getDefinition() method is called each time you insert
a definition. So you can implement your own to serve your dynamic definition. You change
the factory used in web.xml. See the tiles-chanel.war as example.
Another way is to associate an Action and a Tile. The action create and set the
definition or read it from factory, and push it to be used by Tiles. Your action use the
forward mechanism to forward directly to a Tile/jsp, or to a definition name. In this
later case, values set in your pushed definition overload values set by definition used
in forward.
I'm currently writing a new example showing this features (dynamic portal customizable
by user). You can also check tiles-doc/test/testStrutsAction.jsp and
examples.tiles.test.TestActionTileAction.java.
Cedric
Nathan Coast wrote:
> Thanks Cedric, I'll give that a go.
>
> Looking in tiles\web\doc\web-inf\tilesDefinitions.xml I found
>
> <definition name="main.portal.body" path="/layout/columnsLayout.jsp">
> <put name="numCols" value="2" />
> <putList name="list0" >
> <add value="/tutorial/portal/login.jsp" />
> <add value="/tutorial/portal/messages.jsp" />
> <add value="/tutorial/portal/newsFeed.jsp" />
> <add value="/tutorial/portal/advert2.jsp" />
> </putList>
> <putList name="list1" >
> <add value="/tutorial/portal/advert3.jsp" />
> <add value="/tutorial/portal/stocks.jsp" />
> <add value="/tutorial/portal/whatsNew.jsp" />
> <add value="/tutorial/portal/personalLinks.jsp" />
> <add value="/tutorial/portal/search.jsp" />
> </putList>
> </definition>
>
> is there any way that this can be done dynamically? so the portal page could be
> customised for each user?
>
> Cheers
> Nathan
>
> Cedric Dumoulin wrote:
>
> > Hi Nathan,
> >
> > Tiles are compatible with templates. This mean that you can use Tiles in place
of
> > templates.
> > This can be done with a minimum effort by replacing the template tld declaration
> > in web.xml :
> >
> > <taglib>
> > <taglib-uri>/WEB-INF/template.tld</taglib-uri>
> > <taglib-location>/WEB-INF/tiles.tld</taglib-location>
> > </taglib>
> >
> > If you use only template tags, then continue to use original template.
> > If you also use tiles tags or features, then use tiles library instead of templates
> > one.
> > You can still have both prefix in your jsp files if you wish.
> >
> > Hope this help,
> >
> > Cedric
> >
> >
> > Nathan Coast wrote:
> >
> >
> >>Hi,
> >>
> >>I've been looking at tiles and not sure whether its best to use tiles layouts
or
> >>struts templates or some mix of the two. We've currently got a site implemented
> >>using templates but would be looking to implement a portal-like page possibly
> >>using tiles functionality to provide the component layout.
> >>
> >>I'm a bit concerned that using tiles layouts would result in two page layout
> >>mechanisms within one app (tiles and templates).
> >>
> >>Cheers
> >>Nathan
> >>
> >
> >
|