• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSTL vs struts tag

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to struts.
I need following code in struts.

how can i do in struts?


<tr><td>Cust group</td>
<td>${c.cucl}
<input type="hidden" name="cucl" value="${c.cucl}" />
<select>
<c:forEach var="cg" items="${sessionScope.custGroupsMap}">
<option value="${cg.key}" ${(cg.key == c.cucl) ? 'selected' : ''}>${cg.value} (${cg.key})</option>
</c:forEach>
</select>
</td>
</tr>


Thank you for your help
 
author & internet detective
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bhaskar,
Why do you want to use the Struts tags instead of JSTL? You can still use the Struts classes (actions/forms/etc) an use JSTL for your JSP.

If you want to use Struts tags, I recommend converting one piece at a time. For example, you could use bean:write instead of the EL outputs. Then you could use logic:iterate instead of the loop.
 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your responce. I am converting jsp application in to struts.
But i am unable to convert the jsp code in to struts.

I tried in the following way:

<td>Cust group</td>
<td>
${c.cucl}
<html:select name="customerForm" property="cucl">
<html ptions property="custGroupsMap" name ="customerForm"/>
</html:select></td>
But there is no selected property in html ption.

How can i do in struts .


jsp code :
<select>
<c:forEach var="cg" items="${sessionScope.custGroupsMap}">
<option value="${cg.key}" ${(cg.key == c.cucl) ? 'selected' : ''}>${cg.value} (${cg.key})</option>
</c:forEach>
</select>



Thank you for your help
 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody help 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
When you use the struts html:select tag, Struts handles the logic for selecting the appropriate option. All you have to do is make sure that the cucl property has the right value prior to the JSP being displayed and the option corresponding to that value will be selected. Example:

[ January 24, 2008: Message edited by: Merrill Higginson ]
 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cucl has right vlaue(key value).

i wrote code what you said

<html:select name="customerForm" property="cucl">
<html ptionsCollection property="custGroupsMap" name ="customerForm" value="key" label="value"/>
</html:select>

while i select a value in a combo box it is updating right key value(cucl).

my question is :


if i re login in to application

and i want to see customer details

combo box is not showing the correct value based on the key.

it is showing first value in the map..

did you get it now?( after re login )

i tried may ways...
but i could n't solve it..

Please give me suggestion..



Thank you for your help
 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it..

Thank you
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic