| Author |
JSTL vs struts tag
|
Bacchi Gerem
Ranch Hand
Joined: Jan 23, 2004
Posts: 120
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26173
|
|
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.
|
[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
|
 |
Bacchi Gerem
Ranch Hand
Joined: Jan 23, 2004
Posts: 120
|
|
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
Joined: Jan 23, 2004
Posts: 120
|
|
|
anybody help me
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
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 ]
|
Merrill
Consultant, Sima Solutions
|
 |
Bacchi Gerem
Ranch Hand
Joined: Jan 23, 2004
Posts: 120
|
|
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
Joined: Jan 23, 2004
Posts: 120
|
|
I got it.. Thank you
|
 |
 |
|
|
subject: JSTL vs struts tag
|
|
|