|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Best way to replace header and footer based on an affiliate ID?Hello:
I have a site developed using struts 2 with the tiles 2 plugin. I would like to use an affiliate-specific header and footer on the pages if the user comes in from an affiliate site. I think I have found two ways so far to do this: 1. When users come into my site from an affiliate, make them to a new action path. For example, people come in to the site right now my a url such as http://jammconsulting.com/myApp/page/home.action For an affiliate, they can come in using this url: http://jammconsulting.com/myApp/affName/home.action In my struts.xml, I can have these actions: <action name="page/*"> <result name="success" type="tiles">page.{1}</result> </action> <action name="affName/*"> <result name="success" type="tiles">affName.{1}</result> </action> In my tiles.xml, I can have these defintions: <definition name="page.basic" template="/layout.jsp"> <put-attribute name="header" value="/header.jsp" /> <put-attribute name="footer" value="/footer.jsp" /> </definition> <definition name="page.home" extends="page.basic"> <put-attribute name="content" value="/home.jsp" /> </definition> <definition name="page.affName" template="/layout.jsp"> <put-attribute name="header" value="/affName/header.jsp" /> <put-attribute name="footer" value="/affName/footer.jsp" /> </definition> <definition name="affName.home" extends="page.affName"> <put-attribute name="content" value="/home.jsp" /> </definition> 2. Use a tiles controller to replace the header and footer attributes on the definition containing the layout. So, my tiles.xml would have: <definition name="page.basic" template="/layout.jsp" controllerClass="page.LayoutController"> <put-attribute name="header" value="/header.jsp" /> <put-attribute name="footer" value="/footer.jsp" /> </definition> The LayoutController would check if the user came from and affiliate and if they did, set the header and footer attributes to the correct ones for the affiliate. Does anyone have a suggestion for the best practices way to do this? Thanks, Neil -- Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com Eliminate junk email and reclaim your inbox. Visit http://www.spammilter.com for details. |
|
|
Re: Best way to replace header and footer based on an affiliate ID?2008/4/30 Neil Aggarwal <neil@...>:
> 2. Use a tiles controller to replace the header and footer > attributes on the definition containing the layout. > > So, my tiles.xml would have: > > <definition name="page.basic" template="/layout.jsp" > controllerClass="page.LayoutController"> > <put-attribute name="header" value="/header.jsp" /> > <put-attribute name="footer" value="/footer.jsp" /> > </definition> > > The LayoutController would check if the user came from > and affiliate and if they did, set the header and footer > attributes to the correct ones for the affiliate. Notice that Tiles 2 changed the "controller" concept with the "view preparer", but essentially it works the same: http://tiles.apache.org/tutorial/advanced/preparer.html Anyway, if I was you, I would use your options 1 or 2 only if the pages are very limited in number. If they are too many, consider extending UrlDefinitionsFactory, to centralize the creation of definitions. For an example, see Dimensions: http://mutidimensions.sourceforge.net/ In fact, the Tiles 2 version is in the SVN trunk, and probably won't compile, but at least you will see how it works. HTH Antonio |
| Free Forum Powered by Nabble | Forum Help |