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 html:select in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select in Struts" Watch "html:select in Struts" New topic
Author

html:select in Struts

Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
Hi Guys,

I have a JSP Page with two select boxes. When I write the Usual HTML code for the two DropDown, everything seems to be in place. But as soon as I replace <select> and <option> with <html:select> and <html ption> tags, I cannot see any dropdown kinda thing and also, the options come as normal labels in the same line.I ahve imported the requited .tld files also.
Below mentioned is my Code



Any Idea as to what could be the Reason ??



TIA,
Priya.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

Priya,
Do you have them in a <html:form> instead of a <form>

For the future, there is a disable smilies checkbox below the UBB codes that you can check.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
Hi Jeanne,

I have them in <html:form>.

TIA,
Priya
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
As long as your taglib is:



and the taglibs are in your web.xml that should work, when the html page opens up view source and see what you have. It may not be being parsed properly?

While we're on this topic I have a question also, I want to know if I set the options through an action form reset can I then select which one of them if to be selected by default? So it would be blue already when the jsp is displayed.
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Just wanted to make an observation, it may not be the reason your code is not working.

The <htmlption> tags need to have a valid "value" attribute. These are currently empty in your case. The "value" will be submitted when an option is selected. It is also used to determine which option to show as selected when the page loads.

And John, the answer to your question is yes. But remember to put appropriate values in the "value" attribute. Also you have to use either <htmlption> or <htmlptions>. Using normal <option> will not work for showing an option as selected when a page loads.

Sheldon
Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
Hi Sheldon,

I tried putting the value in the value attribute of html ption tag . But that doesn't work either. I have imported the strtuts-html.tld with the correct path . Also its has entry in my web.xml.
Can it because I have not put my ActionForm.class file in the classes folder of WEB-INF ??

TIA,
Priya
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi priya

There is no way that this can happen check properly whether tld is included properly and remove the cache from the server andf restart ........

and one more thing just test <html:text > and if this properly renders <input type="text"> then its not the problem with tld(I hope if html:select is not working even this wont work )
Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
Hi,

I tried even the <html:text> but Nothing Works
PLEASE HELP

TIA,
Priya
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi priya

If u can post the code of ur jsp (mainly the top part where u have included the tlds) it could give some clue

u can send that offline

sreenathn@huawei.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:select in Struts