• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL vs struts tag

 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34863
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
anybody help me
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
I got it..

Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic