aspose file tools*
The moose likes JSP and the fly likes dynamic drop down menu, jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "dynamic drop down menu, jsp" Watch "dynamic drop down menu, jsp" New topic
Author

dynamic drop down menu, jsp

Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
Hi -
I have written a piece of code to dynamically include data in the drop down list after querying the data base. I can print the values using out.print().. but they do not show up in the drop down list. Below is the code. Please lemme know the mistake in my code. Thanks you!


[ August 14, 2004: Message edited by: Hari priya ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Hari,
The idea is to wrap each one in an <option> tag. For your example,

Also note that in some older browsers the extra out.print statements could mess up the output display.


[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
Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
Hi Jeanne -

Thanks for your reply. It still doesn't work. I am able to print the values using out.print(num.intValue()) [without using the form, select or options tag]. However, I am unable to capture the values in the drop down list [I do not have any out.print stmts now], I could not see the values.

The drop down list should contain two values 10001 and 1. Is the number of digits making any difference? Thanks!
Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
Hi -

My code works fine. I gave "options" instead of "option"

Thanks you!
Stas Sokolov
Ranch Hand

Joined: Apr 13, 2004
Posts: 117

Time to Try Struts :-)


In general you can yuse any collection of java beans to shows the properties. Check the reference guide on

http://struts.apache.org/userGuide/struts-html.html#select


Good luck for yourself.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Adopting a behemoth like Struts is a bit of overkill to implement a simple dynamic dropdown list. A custom action to dynamically populate the options list would be but a few lines of code.
[ August 16, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stas Sokolov
Ranch Hand

Joined: Apr 13, 2004
Posts: 117

It is not good pracise to make a cutom action for the popilating of the collection. Custom tag can greatly fit to this role



Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
Thanks guys for all your contributions!!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

s not good pracise to make a cutom action for the popilating of the collection. Custom tag can greatly fit to this role


What are you talking about? They are the same thing.
Stas Sokolov
Ranch Hand

Joined: Apr 13, 2004
Posts: 117

What are you talking about? They are the same thing.
Please use correct terms because in the sense of struts action means a subclass of the
org.apache.struts.action.Action
I have never heard that somebody used term "Custom Action" to the custom tags.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

I have never heard that somebody used term "Custom Action" to the custom tags.


Perhaps you should get a copy of the JSP Specification. "Custom action" is the official and correct term for what is colloquially called a "custom tag".

The fact that Struts uses the term 'action' to mean something different is an unfortunate name collision.
[ August 16, 2004: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic drop down menu, jsp