Hello All,
I am using Struts with Tiles to build a nested layout, and have hit some wierdness:
any comments/help much appreciated.
Background: I'm constructing a webapp allowing a 'client' to view useful info (e.g.
about their account), and also allowing an 'admin' to view the client's info.
I want to embed the client's view into an admin page (allowing the admin to see both
data about the client, as well as the client's view). Tiles is an obvious candidate
for this.
So I have a tile for the client's view. To simplify, I will say that this tile relates
a JSP (/client/overview.jsp) and a Struts action (ClientActions.java), defined thus in
tiles-defs.xml:
<definition name=".clientDetails.view" page="/client/overview.jsp"
controllerUrl="ClientActions.do" />
This tile would normally be used as the 'body' attribute in a Tiles .clientLayout,
e.g.:
<definition name=".clientOverview" extends "clientLayout">
<put name="body" value=".clientDetails.view">
</definition>
In the admin context, there is a .adminLayout: the 'body' attribute is set to a JSP
that itself inserts the .clientDetails.view tile:
<definition name=".adminClientView" extends="adminLayout">
<put name="body" value="/admin/viewClient.jsp" />
</definition>
...and a Struts Action acts as controller for this tile, using Struts ActionMappings,
e.g.
<action path="/AdminViewClient type="com.ehbas.web.admin.ViewClientAction">
<forward name="success" path=".adminClientView"/>
</action>
Somewhere in viewClient.jsp I insert the client view tile in a table thus:
<td>
<tiles:insert definition=".clientDetails.view" />
</td>
Now when I access the client part of the webapp (i.e. I hit the page defined by
.clientOverview) it works OK. But when I get to the admin view (.adminClientView), the
inserted tile blows up.
Close inspection with a debugger reveals that in the former case the Action
ClientActions is invoked, but for the admin case it isn't.
(Originally the whole app was Struts Actions forwarding to tiles: I tried binding the
ClientActions action to the overview.jsp just to give myself a component-ised
controller/view tile.)
I'm expecting the following sequence:
1 /AdminViewClient.do forwards to .adminClientView
2 /admin/viewClient.jsp runs: inserts tile .clientDetails.view
3 /ClientActions.do action invoked
4 /client/overview.jsp runs.
It is step 3 that seems to be bypassed.
However, if I replace the Action with a Controller, thus:
<definition name=".clientDetails.view" page="/client/overview.jsp"
controllerClass="com.ehbas.web.ClientOverviewController" />
...where ClientOverviewController extends org.apache.struts.tiles.ControllerSupport,
then everything works OK.
My question is this: why does a JSP backed by an Action in a tiles def which is
inserted into another JSP not result in the Action being invoked, while an inserted
tile tying a JSP to a Controller *does* result in the Controller being invoked?
I guess I have a useable solution, but I'm wondering if I have (a) found a bug, or (b)
missed something!
Sorry this is rather long winded: I wanted to give as clear an indication of the
problem as poss.
Thanks for your help,
Neil Pattinson.
This e-mail message is meant solely for the person or organisation to whom it is
addressed.The message may contain personal or confidential information, or information
that is not public in nature. Ehbas Ltd accepts no responsibility for message content
and possible attachments that are unlawful or of questionable decency. Further
dissemination, publication or duplication of this message is strictly prohibited if
the person or organisation receiving this message is not the intended recipient. In
the event that you are not the intended recipient, we request you to refrain from
using the content and to immediately inform the sender of the error by returning the
message. Thank you for your co-operation.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]