struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murray, Christopher" <Christopher.Mur...@ds-s.com>
Subject RE: <html:options> with an ActionForm
Date Thu, 31 Oct 2002 12:19:12 GMT
Isn't the action form is a bean on the request ?

If the list is wrapped in the action form then isn't this the same as your
last suggestion,

"Even better might be, to put your list into a bean and to put this bean
into request." ?

Have tried putting the list on the request but the page displays a blank
drop down list.

in the action :

request.setAttribute(MyActionForm, myForm);
request.setAttribute("customerNameList", myForm.getCustomerNameList());

in page:

<html:form method="post" action="/<blah blah blah>/MyAction">

<html:select property="customerId">

    <html:options collection="customerNameList" property="id"
labelProperty="name" />

</html:select>

</html:form>

Getting a blank drop down list.  

???

-----Original Message-----
From: Marcus Biel [mailto:Marcus.Biel@bmw.de]
Sent: 31 October 2002 11:59
To: struts-user@jakarta.apache.org
Subject: Re: <html:options> with an ActionForm


I guess you got just the same problem as I had.
1. I guess you misunderstood the way of ActionClass and ActionForm.

First of all, the ActionForm gets filled with the data the user types in
the input fields on your jsp. Then the action gets called.

So I bet putting your List into a Form won't help you, because you will
build it in your action.

You have to:
At the end of your action, write an request.setAtribute for your list.
Even better might be, to put your list into a bean and to put this bean
into request.

Then you should be able to use it.
You should carefully read:
http://localhost:8080/struts-documentation/struts-html.html#options

Imho it's written quite tricky. I needed some time to fully understand
it.
(I'm german, so it was even harder)
How to use the options tag depends wether your using a bean, a form, a
property....

I got a Vector of Strings in a Bean, and I am not using the Form (I
doubt this could work)
Here's my solution:
<html:form action="getAlaskaGroups.do" method="POST">
	<html:select property="plantSelection" size="1">
		<html:option value="%"><bean:message
key="index.selectbox.all"/></html:option>
		<html:options name="plantListBean" property="plantList"/>
	</html:select> <br>
	<html:submit><bean:message
key="submit.getAlaskaGroups"/></html:submit>
</html:form>

hope this helps.

marcus
p.s: My Vector is build dynamically from database

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message