[Actionframework-users] Passing objects from request to another...
Status: Inactive
Brought to you by:
ptoman
From: Mandip S. S. <ma...@su...> - 2002-07-10 18:15:25
|
Hi Petr I need to be able to pass objects from one request to another and so far have not found an easy way of doing this using the framework. The problem is as follows:- I have objects which correspond to row entries in a table called, lets say, RowObjects. I have an action defined for RowObjects so that a user is able to go an edit page for an individual RowObject and I also have an action for any changes that a user makes to a RowObject in the RowObject edit page. The code is as follows: <action name="/editRowObject" method="getRowObject(String rowObjectId)"> <on-return value="*" assign-to="rowObject" show-template="org/visres/ivr/security/EditRowObject.html.vm"/> <on-exception class="Exception" assign-to="error" show-template="error.vm"/> </action> <action name="/rowObjectAction" method="rowObjectAction(String actionType, String rowObjectId, String field1, String field2, String field3)"> <on-return value="*" assign-to="rowObjectId" show-url="rowObjectURL"> <output-variable name="rowObjectURL" component="Security" value="getRowObjectURL($rowObjectId)"/> </on-return> <on-exception class="Exception" assign-to="exception" show-template="org/visres/ivr/security/EditRowObject.html.vm"> <output-variable name="error" value="$exception.getMessage()"/> <output-variable name="rowObject" value="$exception.getChangedObject()"/> </on-exception> </action> If we imagine we're in the system and arrive at a page that lists all RowObjects, we click an individual RowObject which triggers the /editRowObject action and we arrive at the EditRowObject.html.vm page. We see all the fields for this RowObject and need to be able to update these fields. Two things are important here first after we update the fields we should stay on this edit page and secondly if when doing field updates any of the values we enter are wrong, we need to be bought back to this edit page with a helpful error message. So if we imagine when we update a RowObject we trigger the /rowObjectAction and we find some field values are wrong and an exception is thrown. I now have a RowObject with erreneous values and an error message, which need to be displayed. Currently when this is happening I'm essentially repeating the code in the /editRowObject action within the <on-exception> block of the /rowObjectAction action, this is not nice!!!! Instead of doing show-template in the <on-exception> block I want to be able do show-url which redirects to the /editRowObject action. However, once I do this I loose everything in the context and I'm left with no error meassage and no RowObject :-( Is there a simple way of getting round this problem? I could think about creating a component existing session-wide and place objects in it and possibly check this component for objects in the /editRowObject action for example. However this seems a bit messy. Do you think we need to add more funtionality to the framework? Perhaps we could have <session-output-variables> that place things into the session and then when looking for parameters for a method the framework would not only look for parameters in the request but the session aswell? Any comments/suggestions would be much appreciated. Regards Mandip P.S. due to mail server problems please could you Cc: any replys to man...@ya... |