aspose file tools*
The moose likes Struts and the fly likes html:options default item selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:options default item selection" Watch "html:options default item selection" New topic
Author

html:options default item selection

Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
hi,
i have a html ptions which is using catValues collection. This collection is loaded with all the categories. The following is the code
<html:select property="contextCode"> <html ptions collection="catValues" property="categoryCode" labelProperty="categoryName" />
</html:select>
i wanted to set the index of the select box to the second element is there a way to do it in the html options box
Thanks
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
there are a couple of ways you can do this...

1. break the <htmlptions> into iterations of <htmlption>. track the indexId (with logic:equal or c:if) and generate the <htmlption> with selected="true" attribute

2. if your collection is generated from the action, do form.set("contextCode", secondOptionValue); inside the action before forwarding it to the page.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
Thanks
but the problem is that the page is first time initialized. so i have the collection in the session variable and it is used to populate the html ptions tag. So the page is loaded for the first time and it does not go to the action class. i think the first method is fine. Could you please eloborate how i expand the html ptions tag.
Thanks
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
is the second value in the dropdown always a known value? if so, you can initialize your form-property (using the initial="xxx" attribute) to that value. if you can't do this, i'll explain the <html ption>.
Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
Thanks Alan
its works now. i just set the initial property in my dynaaction form declaration in the struts-config.xml file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:options default item selection