• Post Reply Bookmark Topic Watch Topic
  • New Topic

jstl populating a menu via iteration  RSS feed

 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to fill in the "vaule" and "displayed text" of a menu by iteration using jstl.

Here's the menu:



And here's what i know about iteration:







I need some help piecing things together. Any one know any good articles i can read on jstl.
[ September 13, 2008: Message edited by: jite eghagha ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without any information about the data structures containing the menu information, it's not clear what advice you can get.
[ September 13, 2008: Message edited by: Bear Bibeault ]
 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the moment the "value" is stored in an arrayList.


And the "title of each file" is stored in a comma delimited string.


It would have been wiser to use a doulbe array.......perhaps
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, those aren't the best data structures for the job. An important part of writing good JSP pages is making sure that the data being fed to them is appropriate.

For <select> elements, an ordered Map like TreeMap is a good choice as the map key can hold the option value, and the map value can hold the display text. An array or list of items that can contain the two strings can also serve well.

In any case, a smarter data structure will make the job much simpler.
[ September 13, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jite eghagha:
It would have been wiser to use a doulbe array.......perhaps
Not really. using a double anything is a bad idea (reminds me of FORTRAN or some reason). You want to have one thing to iterate over, not two.
 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came up with this as a solution.

I use a .txt file containing, a files location and a files name :

Bear.wmv, The Bear Video File
Lake.wmv,The Lake Video File

Use that file to build an <OPTION></OPTION> tag in my bean class:



Then i iterate over my bean in the JSP page:



And that populates my drop-dwon list
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!