Hi, i have started learning struts two weaks ago. I have done some things for now succeesfully. But i came acrosse one problem and I am solving it for a while now but whithought any success.
My problem is populating options tag:
1. The simpliest way to do this is:
dataBean - ordinary bean with two setters,getters and two variables int value and String description
<html:select property="dateBean" style="width:152px">
<html:option value="0">Today</html:option>
<html:option value="2">2 Days Ago</html:option>
<html:option value="7">7 Days Ago</html:option>
<html:option value="30">30 Days Ago</html:option>
<html:option value="all">All</html:option>
</html:select>
-why should I use bean here (options are static like ordinary html)
2.1 Populating from options collection bean
languageBean - ordinary bean with two setters,getters and two variables int id and String description
collectionBean - here I add some languages in collection (to getCollection I use this method)
collection name = languages
!!! I'm not sure if this code is OK.
<html:select name="languageBean" property="languages">
<html:options collection="languages" property="id"labelProperty="description"/>
</html:select>
Now my questions here:
- what should i write for html:select name and property attributes; should be the name of the bean, must I define or declare it first or what is the procedure to do this
- what I write for html:options collection attribute; I know that property attribute and labelProperty are from my languageBean (private variables)
2.1 Populating from options collection from session
- how can I do this; some example and description would help
I would like to be this problem discused in a way so new struts user would understand it and after reading this topic they would be able to use this options collection tag.
So I am asking experts to help me out and write or add some code for this two examples about populating oprions tag. Some links with tutorials or examples could be added on this topic.
Thank you very much.