File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes setting a default value for a drop-down Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply 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
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

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: 56202
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting a default value for a drop-down
 
Similar Threads
Hashmap in Struts
JSTL sql taglib and html drop down box
Getting drop down value in JSP as request scope.
Not able to retain the selected value from the drop down menu
Drop down list value