Sunday, 15 April 2012

hibernate - Redirecting to a page displaying a specific object -



hibernate - Redirecting to a page displaying a specific object -

update

as question has changed little (this turned out more list/dropdown list, started new question concerning problem info passing: new question

i trying write appliction first have list of objects, navigate page 1 of objects displayed. each object has list of several other objects (in programme list of exams , each exam has list of questions). press button directed 3rd page can fill form create new attached object.

when saving attached object, want redirected sec page displaying same object before. and problem. form fields on page homecoming empty.

now, when calling saveattachedobject action (attachedobjectaction, method "save") redirected object.jsp. however, no object selected , receive error message invoke when click on editbutton in objectlist.jsp , have not selected object. message produced in validate method of objectaction checks if either object or attachedobject null.

i suspect, input object.jsp missing.

in struts.xml have saveattachedobject action has attachedobject.jsp input, attachedobject (including variable object) should exist. in phone call showobject action shows 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 defined in tiles.xml)

if add together

<result name= "input" type="tiles">attachedobjectform</result>

to showobject action. receive error "dropdown-list" not resolved collection/array/map/enumeration/iterator type:

http status 500 - servletexception including path '/layout/mainlayout.jsp'.

stacktrace:

tag 'select', field 'list', name 'attachedobject.type': requested list key 'objecttypes' not resolved collection/array/map/enumeration/iterator type. example: people or people.{name} - [unknown location]

here attachedobject.jsp select field causes error:

i dont know whether can give object(id) showobject action instead of whole attachedobjectform? or, dont unterstand: why want read whole objecttypes list? want utilize attachedobject (only using selected item of list new parameter of attachedobject).

if need futher code or information, please allow me know.

here concerning code parts of main classes of project:

objectaction: http://pastebin.com/q080n1nb

attachedobjectform: http://pastebin.com/m2hmxhwp

i'm not next you; +1 nice first question, though excessively verbose. can add together details want, should contract real question (the expected result, obtained result, problem) in "one-liner", or short sentence(s), separated other bunch of details potentially useful more deep debugging of problem.

from i've got, at to the lowest degree one of problems populating list in load() method (not reached in case of input result returned interceptor). alter by using prepare() method follows:

public void prepare() throws exception{ objecttypes = new arraylist<string>(); objecttype[] alltypes = objecttype.values(); (objecttype objecttype : alltypes) { objecttypes.add(objecttype.tostring()); } } public string load() { long id = 0l; if (objectid != null) { id = objectid; } else if (attachedobject.getobject() != null) { id = attachtobject.getobject().getid(); } if (id == (long) 0) { homecoming error; } else { exam = objectservice.loadobject(id); homecoming success; } }

i'm not sure workflow is, way.

if need exam populated in case of input result, set stuff of load() method in prepare() method, , ensure using the paramsprepareparamsstack instead of defaultstack.

you might find objectaction not needed anymore, , set business in prepare() method of action.

note in posted code (most cleaned before publishing it), missing getter objecttypes.

hibernate jsp redirect struts2

No comments:

Post a Comment