1

I have 4 different types of members in my website lets say memberA, memberB, memberC, and memberD. Each should have its own header headerA.jsp, headerB.jsp, headerC.jsp, headerD.jsp.

As shown below, there is a definition for each Member type and their specific header and body are defined. Each has its own header but some of them for example memberA, memberB and memberC share gbody.jsp as their body attribute.

     <definition name="MemberA" extends="baseLayout">
            <put-attribute name="header" value="/headerA.jsp"/>
            <put-attribute name="body" value="/gbody.jsp"/>
        </definition>

       <definition name="MemberB" extends="baseLayout">
            <put-attribute name="header" value="/headerB.jsp"/>
            <put-attribute name="body" value="/bodyB.jsp"/>
        </definition>

        <definition name="MemberC" extends="baseLayout">
            <put-attribute name="header" value="/headerC.jsp"/>
            <put-attribute name="body" value="/gbody.jsp"/>
        </definition>

        <definition name="MemberD" extends="baseLayout">
            <put-attribute name="header" value="/headerD.jsp"/>
            <put-attribute name="body" value="/gbody.jsp"/>
        </definition>

I have two problems when the member is signed in

  1. How do I show them their specific header?
  2. How do I define their specific body attribute?
Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
Daniel Morgan
  • 782
  • 5
  • 15
  • 43
  • 1
    Upgrade to tiles-3 then you can use expressions inside the put attributes... OGNL expressions are supported too, you can just glue the "A", "B", "C", "D" component on to the end of the string dynamically by pulling it from the session, then you only need one tile. Traditionally you're supposed to define a new tile for every combination, but you can also use wildcard and regex matching to do a some of the work. – Quaternion Mar 01 '13 at 03:30

1 Answers1

1

You could define the 4 headers as such

<definition name="Members" extends="baseLayout">
    <put-attribute name="headerA" value="/headerA.jsp"/>
    <put-attribute name="headerB" value="/headerB.jsp"/>
    <put-attribute name="headerC" value="/headerC.jsp"/>
    <put-attribute name="headerD" value="/headerD.jsp"/>
    <put-attribute name="body" value="/gbody.jsp"/>
</definition>

and then in the base layout have some code that says

<c:if test="${memberA}">
    <tiles:insert attribute="headerA"/>
</c:if>
etc...