Migrating from the Struts 1.3/Tiles 1.x combo to the Struts 2/Tiles 3. But this is really a Tiles question
Previously there was support for a bean declaration within the definition to support functionality as menu items, Tiles 3 have apparently gone away with that. So I've converted this:
<definition name=".selectPatient.menu" path="/WEB-INF/templates/menu.jsp">
<putList name="items">
<bean classtype="org.a.m.s.jsp.MenuItem">
<set-property property="id" value="menubar_register"/>
<set-property property="name" value="menubar_register"/>
<set-property property="title" value="Register"/>
<set-property property="onclick" value="registerPatient()"/>
<set-property property="text" value="Register"/>
<set-property property="roles" value="BASIC,LEAD,SUPER"/>
</bean>
<bean classtype="org.a.m.s.jsp.MenuItem">
<set-property property="id" value="menubar_multitransaction"/>
<set-property property="name" value="menubar_multitransaction"/>
<set-property property="title" value="Post Multiple Transactions"/>
<set-property property="onclick" value="postMultiTransactions()"/>
<set-property property="text" value="Post Multiple Transactions"/>
<set-property property="roles" value="BASIC,LEAD,SUPER"/>
</bean>
</putList>
</definition>
and the corresponding menu.jsp page:
<logic:iterate id="item" name="items" type="org.a.m.s.jsp.MenuItem">
<%if (UserRoles.userHasRole(request,item.getRoles())){%><td><table id="button_<bean:write name="item" property="id"/>" cellpadding="0" cellspacing="0" border="0"><tr><td><img src="images/menu_button_round_edge_left2.gif"></td>
<td style="border-top:1px white solid; border-bottom:1px white solid;">
<a name="<bean:write name="item" property="name"/>" id="<bean:write name="item" property="id"/>" accesskey="M" title="<bean:write name="item" property="title"/>" class="menuItem" href="#" isDisabled="false" onclick="if (this.isDisabled != 'true'&&isPageReady()) <bean:write name="item" property="onclick"/>;"
onmouseover="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_<bean:write name="item" property="id"/>').style.backgroundColor='#ffff99';" onmouseout="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_<bean:write name="item" property="id"/>').style.backgroundColor='#000066';"><bean:write name="item" property="text"/></a></td>
<td><img src="images/menu_button_round_edge_right2.gif" width="9" height="17"></td>
</tr></table></td>
<%}%>
</logic:iterate>
Migrated over to the
- definition:
<definition name="defaultMenuComponent" template="/WEB-INF/templates/barbutton.jsp">
</definition>
<definition name="menubar_register" extends="defaultMenuComponent">
<put-attribute name="id" value="menubar_register" cascade="true"/>
<put-attribute name="name" value="menubar_register" cascade="true"/>
<put-attribute name="title" value="Register" cascade="true"/>
<put-attribute name="onclick" value="registerPatient()" cascade="true"/>
<put-attribute name="text" value="Register" cascade="true"/>
<put-attribute name="roles" value="BASIC,LEAD,SUPER" cascade="true"/>
</definition>
<definition name="menubar_multitransaction" extends="defaultMenuComponent">
<put-attribute name="id" value="menubar_multitransaction" cascade="true"/>
<put-attribute name="name" value="menubar_multitransaction" cascade="true"/>
<put-attribute name="title" value="Post Multiple Transactions" cascade="true"/>
<put-attribute name="onclick" value="postMultiTransactions()" cascade="true"/>
<put-attribute name="text" value="Post Multiple Transactions" cascade="true"/>
<put-attribute name="roles" value="BASIC,LEAD,SUPER" cascade="true"/>
</definition>
<definition name=".selectPatient.menu" template="/WEB-INF/templates/menu.jsp">
<put-list-attribute name="items">
<add-attribute value="menubar_register" type="definition"/>
<add-attribute value="menubar_multitransaction" type="definition"/>
</put-list-attribute>
</definition>
- pushed all the construction logic into the barbutton.jsp :
<table id="button_<tiles:insertAttribute name="id" flush="true"/>" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="images/menu_button_round_edge_left2.gif"></td>
<td style="border-top:1px white solid; border-bottom:1px white solid;">
<a name="<tiles:insertAttribute name="name" flush="true"/>" id="<tiles:insertAttribute name="id" flush="true"/>" accesskey="M" title="<tiles:insertAttribute name="title" flush="true"/>" class="menuItem" href="#" isDisabled="false" onclick="if (this.isDisabled != 'true'&&isPageReady()) <tiles:insertAttribute name="onclick" flush="true"/>;" onmouseover="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_<tiles:insertAttribute name="id" flush="true"/>').style.backgroundColor='#ffff99';" onmouseout="if (this.isDisabled != 'true'&&isPageReady())document.getElementById('button_<tiles:insertAttribute name="id" flush="true"/>').style.backgroundColor='#000066';"><tiles:insertAttribute name="text" flush="true"/>
</a>
</td>
<td><img src="images/menu_button_round_edge_right2.gif" width="9" height="17"></td>
</tr>
</table>
- and the menu.jsp gets changed as following:
<tilesx:useAttribute id="items" name="items" classname="java.util.List"/>
<table border=0 cellpadding=0 cellspacing=1>
<tr>
<c:forEach items="${items}" var="listItem">
<td>
<tiles:insertDefinition name="${listItem}" flush="true"/>
</td>
</c:forEach>
</tr>
</table>
And it does not work, getting the java.lang.StackOverflowError
tries various and different ways