Your JSP code looks OK (except obviously you want to remove the
value="22" from the html:select tag). Are you sure the value you're
setting in form.license is correct?
L.
Jonathan Drnek wrote:
I'm fairly new to struts and am having a problem with the <html:select>
tag. I can't get the value property to work correctly. I have a list of
licenses that I want displayed in the drop down box. I want the license
that is used by the current software to be selected.
If I hard code the value property to be 22 for example, the license that
has 22 for its key is selected. It seems like I should be able to use
the license property in my SoftwareForm bean for the value but that does
not work. When I do that, nothing ends up being selected.
My JSP page looks like
<html:form action="/updateSoftware" >
<html:hidden property="id"/>
Name <html:text property="name" /><br>
Location <html:text property="location" /><br>
Approved <html:checkbox property="approved" value="true"/><br>
License
<html:select property="license" value="22">
<html:option value="-1"> </html:option>
<html:options collection="allLicenses" property="id"
labelProperty="name" />
</html:select><br>
Notes <html:text property="notes" /><br>
<html:submit/>
</html:form>
My action mapping looks like.
<action name="SoftwareForm" path="/updateSoftware"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy"
input="/EditSoftware.jsp">
<forward name="success"
path="/loadAllSoftware.do">
</forward>
<forward name="Failure"
path="/EditSoftware.jsp">
</forward>
</action>
As you can see I am using spring.
My SoftwareForm bean contains the String properties you would expect.
In the action that forwards to the above form I have the following code
Software s = softwareDAO.get(Long.decode(id));
Iterator i = licenseDAO.getAllLicenses();
SoftwareForm sForm = new SoftwareForm();
sForm.setApproved(Boolean.toString(s.isApproved()));
sForm.setId(s.getId().toString());
sForm.setLicense(s.getLicense().getId().toString());
sForm.setLocation(s.getLocation());
sForm.setName(s.getName());
sForm.setNotes(s.getNotes());
request.setAttribute("SoftwareForm",sForm);
request.setAttribute("allLicenses",i);
This seems like it should be a fairly simple thing to do. What am I
missing?
Jon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]