Struts html:select question.

S

Senthil

I want to accomplish....

I have to query a database whic return list of employee records.
In the front end, i have to show, list of all firstName's in a list
box style
(<select multiple> <option>). If user decides to add more employees,
then
i have to validate the name(with no special characters) and proceed to
the
next screen. There i need to show the newly added name in that screen
along
with all other fields empty. So that user can add that fields.

For this, i am doing like this.

When i query database through my Action execute() method, database
returns a set of employee records. I am capturing all those in my
NameBean[] and passing it to JSP.Code looks like this..

NameBean[] name = DatabaseReturnsListOfEmployees...
request.setAttribute("MyNameBean", name);

In my JSP
<select name="allName" multiple>
<logic:iterate id="MyNameBean" name="MyNameBean">
<option> <bean:write name="MyNameBean" property="firstName"/>
</logic:iterate>
</select>

This code populates <select> <option> with all the firstName in the
list box.
Now my JSP looks like a ListBox.

The question is when i tried to add new firstName in the ListBox, how
do i take it to the Action class? Since ListBox MyNameBean is
NameBean[] and the Action's execute() method has ActionForm has form
value. Not a ActionForm[] value. See below.

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top