问题
I started out with a problem concerning a list/dropdown list on one of my jsps but now I realized my main problem is concerning the data input between actions/pages. Old question
I am trying to navigate from one page displaying one specific object to a nother page displaying an attachedObject
(to the first one) and then navigate back to the first object page. The last step is the one I have problems with.
The whole workflow is: first page: display a list of objects, select one and then go to second page displaying that object and the list of its attachedObjects. Select one of the attachedObjects (or click on "Add new one") and you are redirected to the third page. Fill out the form for the attachedObject and then click "save".
Here you should be redirected beck to the second page showing the object you just added the attachedOject to. However, I receive an error message I invoke when the user is trying to get to the second page but has not selected one of the objects in the list.
It seems, that I need to pass on my "object" or at least it's ID in order to remember and work with it later on.
Right now, i have a ShowAttachedObjectAction
class only responsible for showing the attachedObjectForm (implementing com.opensymphony.xwork2.Action
). On top of that I have a AttachedObjectAction
(extending com.opensymphony.xwork2.ActionSupport
) with a invalidate()
method. When adding a attachedObject (and therefore not selecting a attachedObject in the objectForm-list, an error message would come up.
Thats why I separated the Action-classes.
But how can I pass on an object during different action calls? (ShowAttachedObjectAction --> AttachedObjectAction.save() --> ShowObject.action
)
Here are my main classes on pastebin:
ObjectForm
AttachedObjectForm
Struts.xml
ObjectAction
AttachedObjectAction
ShowAttachedObjectAction
来源:https://stackoverflow.com/questions/26891460/passing-on-object-data-between-actions