Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

store a value generated by custom tags in a variable  RSS feed

 
Divya Kaushik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to store the value that is generated by the custom tag in a variable.
Assuming I have declared the tag prefix to be test, when I use

<c:set var="store" value="<test:getSomeValue property=\"${collection.propertyName}\"/>"/>

I encounter an exception as "<" is in the value field.

Can anyone please provide me a solution to this?
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Modify the tag to optionally store the value as a page context (or request / session / application) attribute. Then use this attribute. For example:
 
Divya Kaushik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your suggestion. I've included the var like you have mentioned. The TLD file changes have also been made.
Now I get an exception as " Element "tag" does not allow "display-name" here. "
I have removed the <display-name> and still get the same exception.
Initially, it was after <body-content> tag.
I am new to Custom Tags and TLDs... could you please provide me with a solution to this?
here is the variable tag in the TLD file for your reference:

<variable>
<name-given>var</name-given>
<variable-class>java.lang.String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
</variable>
<!-- Forte4J_TLDX: This comment contains code generation information. Do not delete.
<tldx>
<name>var</name>
</tldx>
-->
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!