in action class, have list of questions
. want populated view.
public class myquiztest extends actionsupport { public string additemstotemplate(){ list<question> q= myquestions; system.out.println(q); return "success"; } public list<question> getmyquestions() { return myquestions; } public void setmyquestions(list<question> myquestions) { this.myquestions = myquestions; } private list<question> myquestions; }
this question class
public class question{ public boolean ischosen(){ retrun this.chosen } public void setchosen(boolean chosen){ this.chosen = chosen; } private boolean chosen; }
and here form that handles that
<form method = "get" action = "additemstotemplate"> <s:iterator value = "myquestions" status="key" var = "questionitem"> <s:checkbox name = "myquestions[%{#key.index}].chosen" label="check me testing"/> </s:iterator> </form>
this method handles form
public string additemstotemplate(){ list<question> q= myquestions; system.out.println(q); return "success"; }
upon submission, myquestions
returns null
. why that? want identify if corresponding question has been chosen.
where populating myquestions on action layer.
if not populating anywhere when myquestions variable encountered on jsp empty/null due think flow not go inside iterator loop.
<s:iterator value = "myquestions" status="key" var = "questionitem"> <s:checkbox name = "myquestions[%{#key.index}].chosen" label="check me testing"/> </s:iterator>
now if submit form, surely myquestions object not mapped jsp , coming null
Comments
Post a Comment