Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

about JSP reset function

  Asked By: Francisca    Date: Mar 26    Category: Java    Views: 1578
  

I have a page which displays some contents
along which are some dropdown boxes which are used to change the status of the contents in the database
these dropdowns are assigned a default value "Select" using <html:option>
these dropdowns are created by using <html:options> tag
after submittion the database is updated and the same page is again uploaded
which now displays the changed status of the contents

now the problem is
when the page is again displayed the default value is changed to any value in the dropdown
how can I retain the default value "Select"

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Neil Turner     Answered On: Mar 26

You'll have to specify the type attribute of the iterate tag or the scriptlet will fail.
There is a much nicer solution, however:
<html:select property="control" size="2">
<html:options collection="customers" property="id" labelProperty="fullName"/>
</html:select>
This time we use the options tag, where the collection attribute gives the name of the Collection of beans, and property gives the name of the property in the bean whose value will be returned when the form is submitted. labelProperty is the bean property that will be displayed. I've created  a pseudo-property, fullName, in the Customer bean with a getter-method that returns the firstName and the lastName. In the browser we could have this presented:


The generated HTML looks like this:
<select name="control" size="2">
<option value="001">John Doe</option>
<option value="002" selected="selected">Peter Smith</option>
</select>

 
Didn't find what you were looking for? Find more on about JSP reset function Or get search suggestion and latest updates.




Tagged: