• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logic iterate

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put my key and value pair in a Hashtable in session.How to get the key and vlaue seperetely in JSP.My code is

<logic resent name="category">
<logic:iterate id="id1" name="category" scope="session">

<html-el ption value="${id1}"><bean:write name="id1" property="value" /></html-el ption>

</logic:iterate>
</logic resent>

Is it right or wrong please tell me?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever you iterate over an implemnentation of java.util.Map, you get an object of type Map.Entry which has a key property and a value property. Knowing this, if you have a Map stored in session scope, you can create a list of options like this:

<html:optionsCollection name="category" value="key" label="value" />
[ January 08, 2007: Message edited by: Merrill Higginson ]
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a ton.If I want to use bean:write can i use like this

<select name="sel">

<logic:iterate id="match" name="hs">
<option name="uid" value=<bean:write name="match" property="key"/>>
<bean:write name="match" property="value"/>
</option>
</logic:iterate>

</select>
But this line value=<bean:write name="match" property="key"/>> is not a valid line in JSP.How can i do this?Pliz help.Thanks in advance
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ingoba,

I notice a lot of your posts get posted two or three times. I can understand that happening when the system is slow, but did you know you can delete the extra post if that happens? Just click on the icon that looks like a pencil and piece of paper to edit the post. On the page that follows, ceck the "delete" checkbox and click the "edit post" button. That will get rid of the extra post.

Now, in answer to your question:

Just put the <bean:write /> in single quotes like this:
<option name="uid" value='<bean:write name="match" property="key"/>'>
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill for your kind information.

I am using html ption I put

<html:text property="name" value='<bean:write name="match" property="key"/>'/>

But its printing <bean:write name="match" property="key"/> in the text box.

Pliz help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic