Two Laptop Bag*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 9293
    
  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: 61104
    
  66

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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: setting a default value for a drop-down