Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

struts html:select tag

Status
Not open for further replies.

papalobas

Programmer
Apr 3, 2006
1
ES
Hi. I'm working with Struts 1.2.7, J2EE and Jacarta Tomcat 5.5.9.
Im trying to show a select element in a jsp to choose a question from a list of LabelValueBeans
identifier value by it's label, and put the label in a property 'question' of type String in a
DynaActionForm (to send to an action, of course).
For instance, below in my code the label will be "Question.Winner", I want to put the value '1'
in the property 'question' of my 'inserBetSortForm'.



In my action::

List questions= new ArrayList();
questions.add(new org.apache.struts.util.LabelValueBean("Question.Winner","1"));
questions.add(new org.apache.struts.util.LabelValueBean("Question.FisrGoal","2"));
questions.add(new org.apache.struts.util.LabelValueBean("Question.BestPlayer","3"));
request.setAttribute("questions",questions);




In my jsp::

html:form xmlns=" xmlns:jsp=" xmlns:fmt=" xmlns:c=" xmlns:html=" action="InsertBetSort.do" focus="question">


...

<html:select property="question" size="1">
<html:eek:ptions>
collection="${requestScope.questions}" property="value" labelProperty="label"
</html:eek:ptions>
</html:select>



In my Struts Config::

<form-bean name="insertBetSortForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="eventIdentifier" type="java.lang.Long"/>
<form-property name="question" type="java.lang.String"/>
</form-bean>


...

<action path="/InsertBetSort"
type="betandpray.http.controller.actions.InsertBetSortAction"
name="insertBetSortForm"
scope="request"
input=".EditBetSort"
validate="true">
<set-property property="authenticationRequired" value="true"/>
<set-property property="adminRequired" value="true"/>
<forward name="InsertBetChoice" path="/EditBetChoice.do"/>
</action>


This is the error I get:


ServletException in '/InsertBetSortContent.jspx': Cannot create iterator for DynaActionForm[dynaClass=insertBetSortForm,eventIdentifier=<NULL>,question=]


-----------------

I've tried with the html:eek:ptions tag ant whith the html:eek:ptionsCollection whith the same resutls.

I'm desperated!!! Please help!!

Thanks.
 
Hi,

Where are u iterating? I see the error, however I am assuming that you must be using the <html:logic> tag somewhere and it is there that the code is throwing the error. Can you provide this part please ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top