UPDATE
As the question itself has changed a little (this turned out to be more about the list/dropdown list, I started a new question concerning the problem with the data passing: new question
I am trying to write an application where I first have a list of objects, then navigate to a page where only one of the objects is displayed. Each object has a list of several other objects (in my program its a list of exams and each exam has a list of questions). I then press a button to be directed to a third page where I can fill a form to create a new attached object.
When saving the attached Object, I want to be redirected to the second page displaying the same object as before. And this is my problem. The form fields on the page to which I return are empty.
Now, when calling the SaveAttachedObject Action (AttachedObjectAction, method "save") I get redirected to the object.jsp. However, no object is selected and I receive my error message that I usually invoke when I click on the editbutton in objectlist.jsp
and have not selected an object. This message is produced in the validate method of the ObjectAction
which usually checks if either object or attachedObject is null.
I suspect, the input for the object.jsp is missing.
in my struts.xml I have the SaveAttachedObject action which has the attachedObject.jsp as input, so the attachedObject (including its variable object) should exist. In that I call the ShowObject Action which shows the object.
<action name="SaveAttachedObject" class="de.example.project.action.AttachedObjectAction"
method="save">
<result name="success" type="redirect">ShowObject.action</result>
<result type="tiles" name="input">attachedObjectForm</result>
</action>
<action name="ShowObject" class="de.example.project.action.ObjectAction"
method="load">
<result type="tiles">objectForm</result>
</action>
(all tiles are defined in the tiles.xml)
If I add an
<result name= "input" type="tiles">attachedObjectForm</result>
to the ShowObject action. i always receive the error that the "dropdown-list" could not be resolved as a collection/array/map/enumeration/iterator type:
HTTP Status 500 - ServletException including path '/layout/mainLayout.jsp'.
Stacktrace:
tag 'select', field 'list', name 'attachedObject.type': The requested list key 'objectTypes' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
Here is the attachedObject.jsp with the select field that causes the error:
I dont know whether I can just give the object(id) to the ShowObject action instead of the whole attachedObjectForm?
Or, which I dont unterstand: why does it want to read the whole objectTypes list? I just want to use the attachedObject (only using the selected item of the list as the new parameter of attachedObject).
If you need any futher code or information, please let me know.
Here are the concerning code parts of the main classes of my project:
ObjectAction: http://pastebin.com/q080N1NB
attachedObjectForm: http://pastebin.com/m2HMXHwP