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.

Reply via email to