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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

logic iterate

Status
Not open for further replies.

bamuthan6666

Programmer
Sep 2, 2002
5
0
0
US
I need help with the logic:iterate, I have just started learning struts.

I have a jsp which needs a listbox which should read the items of the listbox from a vector or array.

I created the vector in my mainaction.java file and in my mainform.java file I have defined the getter and setter.

My jsp during run time is giving me null pointer.

I just need to understand as to how this works,my jsp has name,address,age and the educationfield is the dropdown,once the values are entered and action button next clicked it goes to mainaction.java which inturn sends a mail and moves to next page.
i am not sure if I should point the listbox to mainaction.java or should i create a new action file which should be called onload.

Basically the listbox should be prepopulated when the form is loaded.

Please help.

Thanks!
 
logic:iterate expects a List in order to do its thing. I am not sure how it will react to a Vector.

As an experiment, pass it a List just so you can prove to yourself that it works. Then you can track down the Vector specific issue.

You may need to ask on the struts mailing list.
 
Hi,

Populate options using collections
<%
Vector colors = new Vector();
colors.addElement("red");
colors.addElement("green");
colors.addElement("blue");
pageContext.setAttribute("colors", colors);
%>

<html:select property="color1" size="7">
<html:eek:ptions name="colors" />
</html:select>

 
Thanks for the feed back, i was successfully able to generate the listbox, the problem now is when I do a view source, i see all the values as selected. why is that?

<td align=left ><html:select property="id" value=" ">
<logic:iterate id="UserRoleid" name="UserRole" type="java.lang.String" >
<html:eek:ption value=" ">
<bean:write name="UserRoleid" /></html:eek:ption>
</logic:iterate>
</html:select>
 
Hi,

Coz the value of property id is "" and the value of the options is "".

When value of the select property is equal to the value of the option the tag appends selected.

Cheers
Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top