• 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

using c:out in a href and html:select

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I am trying to use html:select element and a:href element along with jsp <c: tags in a jsp.
While using <a href element along with c:out, the following piece of code compiles and runs fine:
<a href="javascript:deleteChannelRow('<c:out value="${rowNum}" />');">test </a>

But while using <html:select element along with c:out, the following piece of code doesnot compile:
<html:select property="tt" name="dat" onchange="javascript:populateprofiles('<c:out value="${rowNum}" />');" >
<html:option value="" >select profile</html:option>
</html:select>
The javascript error is occured in the double quote of the javascript function and jsp syntax is missed in middle.



If anyone has worked on this, let me know if this is a problem with html:select or if there is a work around for this problem.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The difference between success with the <a> tag and failure with the <html:select> tag is that the <a> tag is a plain HTML tag, while the <html:select> tag is a custom tag. Since the <c:out> tag is also a custom tag, it won't work to embed it inside the property of another custom tag, while it works fine in the property of a plain HTML tag.

If your application is Servlet 2.4 compliant (You can tell by the DTD reference in your web.xml file) then you can simply use the EL Expression ${rowNum} rather than the c:out tag. Otherwise, your options are to use a scriptlet, or to use the struts-el version of the html tags, which allow you to use an EL expression in a Struts tag even in a servlet 2.3 application.
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For someone still interested to use the struts html:select tag, you should be using the
 
Rama Krishna
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For someone still interested to use the struts <html:select> tag, you could make use of indexId attribute of <logic:iterate ..> tag


That works for me.

Cheers
Rama
[ December 31, 2008: Message edited by: Rama Krishna ]
reply
    Bookmark Topic Watch Topic
  • New Topic