Re: [Actionframework-users] Passing objects from request to another...
Status: Inactive
Brought to you by:
ptoman
From: Petr T. <cz5...@ti...> - 2002-07-23 12:53:39
|
Hello again! ><action name=3D"/addObject" method=3D"newObject()"> > <on-return value=3D"*" assign-to=3D"objectStoreId" show-url=3D"objectU= RL"> > <output-variable name=3D"objectURL" > value=3D"/ActionServlet/editObject/$objectStoreId"/= > > </on-return> ></action> > ><action name=3D"/getObject/$objectId" method=3D"newobject(String objectI= d)"> > <on-return value=3D"*" assign-to=3D"objectStoreId" show-url=3D"objectU= RL"> > <output-variable name=3D"objectURL" > value=3D"/ActionServlet/editObject/$objectSoreId"/>= > </on-return> ></action> > ><action name=3D"/editObject/$objectStoreId" method=3D"getObjectStore(Str= ing >objectStoreId)"> > <on-return value=3D"*" assign-to=3D"object" > show-template=3D"org/visres/ivr/security/view/EditObject.ht= ml.vm"/> ></action> >I have also created a seperate ObjectStore class that holds objects in a >HashMap and allows entry of objects into the HashMap, returning a unique= >id for the object just stored, and also a object remove method. Another= >point is that I'm only interested in having an object stored while I'm >on its corresponding add/edit page otherwise there is no need to have it= >around. > >If in our system we choose to add an Object and execute the /addObject >action, the newObject() method will create a new Object and place it in >the ObjectStore returning a unique store id. Now that we have stored a >new Object the url is redirected to the editObject action which will >pull this object out of the ObjectStore. Much the same happens when >editing an object already in the database. If we execute the >/editObject action passing the selected objects database id to the >newObject(String objectId) method, the objects values are retrieved from= >the database and the object is stored returning its unique store id >(remember that we will now have two id's for an object one being its >actual id in the database and the other its id for the ObjectStore). >Again the url will redirect to the /editObject action. You can use <invoke> element to avoid URL redirecting - example: <action name=3D"/addObject" method=3D"newObject()"> <on-return value=3D"*" assign-to=3D"objectStoreId" show-template=3D"org/visres/.../EditObject.html.vm= "> <invoke method=3D"getObjectStore(String objectStoreId)"> <input-variable name=3D"objectStoreId" value=3D"$objectStoreId"/> </invoke> </on-return> </action> >So if, for example, I wanted to change the /addObject action to use your= >"optional attribute for <in/output-variable>" idea, then I'd like to >totally replace the ObjectStore class, meaning that when I save an >object to the session I'd like to get a unique store/session id in >return and I'd also like to be able to remove objects from the session. >I don't think simply adding a scope attribute to the <output-variable> >tag will provide this functionality. You could decide that you do not >want to provide all this functionality apart from adding objects to the >session and leave the unique id functionality to the developer. What do= >you think? Summary: 1) you need to transfer an object across calls - this can be achieved by:= a) storing it in a session component (like your ObjectStore) b) putting it into the session directly (by 'scope' attribute) c) serializing it in the request/response (clumsy or even impossible) d) ? AS can implement 1b) easily (by ParameterRetriever), the question is: 2) how to remove our object from the session: a) let it expire with the session (default behaviour) b) remove it from the session when the <in/output-variable> scope chan= ges c) programatically: ctx.get("REQUEST").getSession().removeValue("id") d) ? I think that "id management" should not be done by AS. If you need to pas= s both object and its id, you can simply put them as two $variables into th= e context/session (or include the id with its object). >Also, a quick update on other aspects of the framework. First the issue= >of show-template/show-url attribute, since being able to pass objects >from one request to another things are working really well. Our >implementation is such that the show-template attribute is only ever >used once on each template, if another action wants to reach this >template then you are forced to call the show-url attribute that >redirects to the action that contains the show-template for the template= >you wish to see. This ensures that any <output-variable>'s that are >required for this template are loaded. Secondly, I also think we were Nesting <output-variable>s inside <template> allows all necessary $variab= les to be set up for the template. >possibly trying to do too much with the framework, where when a user >updates a particular object and the updates throw errors, we were using >actually using the <on-exception> tag to catch these errors and take the= >appropriate action. I think as far as redirecting to different url's is= >concerned the framework works really well but when you want to stay on >the same url and produce some error messages then it's best not to throw= >this up to ActionServlet but to deal with it in your components. Can you explain what are you missing or give me a comparing example pleas= e? >Sorry for the length of the mail, but if you've understood it that would= >be good, if you could make some comments/suggestions that would be >REALLY good and if you could actually implement some of the ideas that >would be absolutely AMAZING!!!! :-) I'm going to set up Tasks for AS this week. I still don't have much time,= but I believe I can do some of "the most expected" RFEs :) -Petr [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=3D22957959 ] _________________________________________________ Tipy na va=B9i dovolenou na http://leto.tiscali.cz |