Hello All,

I'm trying to write a portlet like component using tiles.  A simplified
version of my first attempt follows:

The portlet definition:

<definition name=".uicomponents.portlet" 
    path="/tiles/uicomponents/portlet.jsp">
    
    <put name="content"/>
</definition>


portlet.jsp:

[...]

<div class="portletStyle">
    <tiles:insert attribute="content"/>
</div>


The definition for a particular portlet:

<definition name=".portlets.oneportlet" 
     extends=".uicomponents.portlet ">
    
    <!-- For this definition we're going to use this JSP as 
         the portlet content... --> 
    <put name="content" value="/portlets/oneportlet.jsp/>
    <!-- We're also going to define a parameter that is 
         required by oneportlet.jsp -->
    <put name="aParam"/>
</definition>


oneportlet.jsp:

[...]

<tiles:useAttribute id="aParam" 
    name="aParam" classname="com.mycompany.SomeClass"/>

<c:out value="${aParam.someProperty}"/>


Finally a body page that inserts oneportlets:

[...]

<c:forEach var="someClass" 
    items="${requestScope.collectionOfSomeClasses}">

    <tiles:insert definition=".portlets.oneportlet">
        <tiles:put name="aParam" beanName="someClass"/>
    </tiles:insert>
</c:forEach>


Upon trying this I found that aParam is not available to oneportlet.jsp
(attribute not found error on tiles:useAttribute).  I did find that
aParam was available to portlet.jsp.  From this I realized that my
tiles:insert in portlet.jsp was creating a new tile context for
oneportlet.jsp, and the fact that my .portlets.oneportlet definition was
extending .uicomponents.portlet did not mean that their context would be
shared.

The only solution I've been able to think of so far is to add a generic
"attributes" attribute to my base portlet definition, and just pass that
on the insert of the content defined by the extending definition:

The new portlet definition:

<definition name=".uicomponents.portlet" 
    path="/tiles/uicomponents/portlet.jsp">
    
    <put name="content"/>
    
    <put name="attributes"/>
</definition>


The new portlet.jsp:

[...]

<div class="portletStyle">
    <tiles:importAttribute name="attributes"/>
    <tiles:insert attribute="expandedContent">
        <tiles:put name="attributes" beanName="attributes"/>
    </tiles:insert>
</div>

My body page has to build up a collection of all the parameters that
oneportlet needs (either from the action or using scriptlets), and
oneportlet has to iterate through that collection pulling out the
parameters it needs.  It's hard read and maintain.

So thanks for listening to this point, and now for my question: can
anyone think of a better approach?  My next attempts were going to be
seeing if a tiles controller for .uicomponents.portlet could copy it's
context to the inserted content, or trying a JSTL import instead of a
tiles insert and seeing if the portlet's tiles context would be
available to the imported page.  Is there an entirely different way to
look at this that I'm not thinking of?

Thanks!

Ian

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

Reply via email to