justinwalsh
Mar 20th, 2006, 06:19 AM
I have two controllers, each controlling a semi-autonomous jsp panel in an web application (much liked a tabbed panel). The request to change a panel is a POST request (we never want to expose urls to client) with the parameter action=changePanel (via a hidden input field).
The request submits to the first controller.
Controller 1 receives the request, recognizes the action to change the panel and forwards to the controller responsible for the the display of the second panel. Before it sends the request, it 'changes' the action to display (so that the second controller doesn't try to change panel) (Controller 2). Controller 2 receives the request, and inspects the action parameter. At this stage it is "display, changePanel" (a comma delimited string of the request parameters). This is the problem - it is the same request and you cannot remove parameters.
Spring takes the string array and converts it into a comma delimited string - whereas struts used to just take the first string if the property was bound (in a form bean) to a string. I tried all sorts of property editors but didn't getting any to work.
I have come up with a couple of ideas on how to solve this - but perhaps I am missing something in the general architecture of the app.
1) Control all panels from one controller. Forwarding is then not required. This may be ok for the simple case but what if we want distinct command objects per panel.
2) Do a redirect:. This is what I have implemented currently. Involves round trip to client. Parameters need to be written out to a query string and it turns the request into a GET which is visible to the client.
3) Assume that the action parameter is a (possibly) comma delimited string and parse it in the controller. Smells like a hack.
Any ideas?
The request submits to the first controller.
Controller 1 receives the request, recognizes the action to change the panel and forwards to the controller responsible for the the display of the second panel. Before it sends the request, it 'changes' the action to display (so that the second controller doesn't try to change panel) (Controller 2). Controller 2 receives the request, and inspects the action parameter. At this stage it is "display, changePanel" (a comma delimited string of the request parameters). This is the problem - it is the same request and you cannot remove parameters.
Spring takes the string array and converts it into a comma delimited string - whereas struts used to just take the first string if the property was bound (in a form bean) to a string. I tried all sorts of property editors but didn't getting any to work.
I have come up with a couple of ideas on how to solve this - but perhaps I am missing something in the general architecture of the app.
1) Control all panels from one controller. Forwarding is then not required. This may be ok for the simple case but what if we want distinct command objects per panel.
2) Do a redirect:. This is what I have implemented currently. Involves round trip to client. Parameters need to be written out to a query string and it turns the request into a GET which is visible to the client.
3) Assume that the action parameter is a (possibly) comma delimited string and parse it in the controller. Smells like a hack.
Any ideas?