| Author |
Spring : Two actions possible leading to 2 views ?
|
Girish Varde
Greenhorn
Joined: Jul 09, 2004
Posts: 23
|
|
Hello all, We normally write a property/key in URL mapping element of sn-servlet.xml file. The action mapps to a controller which refers only one form view that is displayed after formBindingObject() etc. On submitting, only one view is returned which may be a redirect view, ultimately dsiplaying only one jsp view. Now, my requirement is that, after submitting a form, two different jsp views to be displayed. One is parent window and othe is child. Both need to have some values to be set in text boxes, meaning I have to use formBackingObject() in two separate controllers. Currently, the application is implemented in cold fusion where they use javascript's window.open() function which is difficult for me to convert. Can you guys guide me to tackle this problem ? Thanks and best regards, Girish Varde
|
 |
Reid M. Pinchback
Ranch Hand
Joined: Jan 25, 2002
Posts: 775
|
|
Doable, but can be a pain, particularly if you have to be careful not to execute logic twice. One solution is: process initial request via springdivide data results of request into two pieces, one for parent, one for childstore child results in the sessionbind parent results plus a tag in the response to be used to retrieve child datahave spring return data via parent viewopening of child window is done via url providing the tagchild GET causes child-specific data to be retrieved via another spring action that gets the data from the session, binding those results to the responsespring returns the data via the child view If you are in a clustered environment this may not be the best solution, because session synchronization can kill you if the child needs a lot of data. Other downsides, clustered or not, is that now you are responsible for keeping track of when you can turf data out of the session. You also have this wierd interdependence between actions and views that ultimately can be very difficult to maintain. I've worked on apps that had coordinated outer window and iframe content much like you describe, and it was a pain in the neck to maintain unless you put a lot of careful thought into keeping the logic of the two windows independent of each other. Instead of thinking of this as the consequences of one initial action, as I described above, if the model data used for the view of the parent and the child windows are independent, you could just treat them as two unrelated requests and hence two unrelated actions and views. The first, parent, action just gets what it needs. The second, child, action just gets what it needs. The limitation to this approach, unfortunately, is that it breaks down if parent and child require similar processing steps by the action - you can have double the processing overhead. Ultimately, past a certain level of complex interdependency I think Ajax might be a better solution. You have one request, one response, and it is up to the response handling javascript to divide the data between the two windows. [ February 12, 2006: Message edited by: Reid M. Pinchback ]
|
Reid - SCJP2 (April 2002)
|
 |
 |
|
|
subject: Spring : Two actions possible leading to 2 views ?
|
|
|