• 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

Passing runtime variables to jsp 2.0 tag files.

 
author
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'd like to use tag files to build some templates in my web pages.
My problem is that I need to pass variables at runtime


Unfortunately I cannot use standard jsp <%=myvar%> notation like this:

<% String myvar="blabla"; %>

<tags ageHeading title="<%=myvar%>" />

So which is the correct way to pass runtime parameters to tag files?
Thanks a lot
Francesco
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Francesco Marchioni:
Hi all,
I'd like to use tag files to build some templates in my web pages.
My problem is that I need to pass variables at runtime


Unfortunately I cannot use standard jsp <%=myvar%> notation like this:

<% String myvar="blabla"; %>

<tags ageHeading title="<%=myvar%>" />

So which is the correct way to pass runtime parameters to tag files?
Thanks a lot
Francesco




Hi Francesco,
if you are using custom taglibs, then in the tld file , you can specify rtexprvalue = true for that parameter
eg.
<tag>
<name>TextInput</name>
<tagclass>blah.web.taglib.TextInputTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>Writing text inputs</info>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

with this tld , in jsp i have statements like
<% String myName = "Abhimanyu" ; %>

<html:TextInput name="<%=myName%>" />

Hope this helps,
Abhimanyu
 
reply
    Bookmark Topic Watch Topic
  • New Topic