This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes setting a default value for a drop-down Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "setting a default value for a drop-down" Watch "setting a default value for a drop-down" New topic
Author

setting a default value for a drop-down

Reshmi Kuttappan
Greenhorn

Joined: May 26, 2009
Posts: 17
am using a drop-down whose values are retreived from database in ascending order...........this works fine
but now i am faced with the following problem:

on load of the screen i need to set a default value for the dropdown.........

how should i do this???
am using JSP.......
please help.....
Praveen Sangolli
Greenhorn

Joined: May 22, 2008
Posts: 28
Hi,

can you paste the code where you are setting the values to the dropdown
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

you can do this



This way your second option will be selected by default...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Reshmi Kuttappan
Greenhorn

Joined: May 26, 2009
Posts: 17
Hi,

I am designing Struts application and in JSP i have used <html:form>tag and for form data i used <display:table > tag.

Though my form retreives the values it is not displayed in the jsp page. Instead a "No record found" message is being displayed.

Following is the code for reference:

<display:table id="resultList" name="requestScope.resultList" pagesize="10" >
<display:column titleKey="serialno" property="serialNo"/>
</display:table>

here "resultList" contains my list of data to be displayed, "serialNo" is the property within the "resultList".

Please help ASAP.

Praveen Sangolli
Greenhorn

Joined: May 22, 2008
Posts: 28
Try this

<ajax:displayTag ajaxFlag="true" id="displayTagList" baseUrl="SomePage.jsp">
<display:table name="sessionScope.resultList" pagesize="10" htmlId="pagedDisplayTableId" id="histListDisp" class="displaytag" >

<display:column property="serialNo" title="SL No" />


</display:table>
</ajax:displayTag>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: setting a default value for a drop-down
 
Similar Threads
Not able to retain the selected value from the drop down menu
Getting drop down value in JSP as request scope.
Hashmap in Struts
Drop down list value
JSTL sql taglib and html drop down box