Hi I just created custom tag being used in my JSP The .tld of the tag is something like this
<?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>acma</shortname>
<info>AccountManag</info>
<tag>
<name>clookup</name>
<tagclass>taglib.acm</tagclass>
<info>Customer Lookup</info>
<attribute>
<name>cust_id</name>
<required>true</required>
</attribute>
</tag>
</taglib>
Now the tag works great when i use it with an int value like so cust_id="1"
<dd:clookup cust_id="1"></dd:clookup>
but it doesnt work when i use EL .with it like
<dd:clookup cust_id="${sessionScope.cust.id}"></dd:clookup>
All the tutorials start of with int or other data type so i cant locate any resource that might help here.. any suggestions ?
Passing values to and from custom tags To pass data from the calling page to the custom tag, you can specify attribute name-value pairs in the custom tag, just as you do for normal HTML and CFML tags. In the custom tag, you use the Attributes scope to access attributes passed to the tag.
Custom tags are user-defined tags. They eliminates the possibility of scriptlet tag and separates the business logic from the JSP page. The same business logic can be used many times by the use of custom tag.
You can include one or more custom JSP tags in a tag library. You define a tag library by a tag library descriptor ( . tld ) file. The TLD describes the syntax for each tag and ties it to the Java classes that execute its functionality.
The JSP 2.0 specification introduced the Simple Tag Handlers for writing these custom tags. To write a custom tag, you can simply extend SimpleTagSupport class and override the doTag() method, where you can place your code to generate content for the tag.
Specify rtexprvalue
in your tld:
<attribute>
<name>cust_id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
See Tag Library Descriptors for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With