Hello fellas,
I'm writing a custom tag and using it in my JSP, but for some reason the EL put in the body isn't being evaluated. Take a look what I did:
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
<tlib-version>1.0</tlib-version>
<short-name>e-commerce</short-name>
<tag>
<name>bestSellers</name>
<tag-class>tlf.ecommerce.web.tag.BestSellersTag</tag-class>
<body-content>scriptless</body-content>
<description>
List the best sellers.
</description>
<attribute>
<name>top</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
public class BestSellersTag
extends SimpleTagSupport {
private String[] bestSellers = { ... };
private Integer top = 10;
@Override
public void doTag() throws JspException, IOException {
Integer numberOfIteractions = resolveNumberOfIteractions();
for (int i = 0; i < numberOfIteractions; i++) {
getJspContext().setAttribute("bestSeller", i + ". " + bestSellers[i]);
getJspContext().setAttribute("bestSellerUrl", "#something");
getJspBody().invoke(null);
}
}
public void setTop(Integer value) {
...
}
}
<ecomm:bestSellers top="10">
<tr class="navigation_row">
<td class="navigation_sub_cell">
<p><a href="${bestSellerUrl}" class="navigation_link">${bestSeller}</a></p>
</td>
</tr>
</ecomm:bestSellers>
So, I'm not getting any exception, but the ${bestSeller} and ${bestSellerUrl} are being kept as they are, and not being evaluated. Does someone know what's going on?
Thanks
I'm writing a custom tag and using it in my JSP, but for some reason the EL put in the body isn't being evaluated. Take a look what I did:
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
<tlib-version>1.0</tlib-version>
<short-name>e-commerce</short-name>
<tag>
<name>bestSellers</name>
<tag-class>tlf.ecommerce.web.tag.BestSellersTag</tag-class>
<body-content>scriptless</body-content>
<description>
List the best sellers.
</description>
<attribute>
<name>top</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
public class BestSellersTag
extends SimpleTagSupport {
private String[] bestSellers = { ... };
private Integer top = 10;
@Override
public void doTag() throws JspException, IOException {
Integer numberOfIteractions = resolveNumberOfIteractions();
for (int i = 0; i < numberOfIteractions; i++) {
getJspContext().setAttribute("bestSeller", i + ". " + bestSellers[i]);
getJspContext().setAttribute("bestSellerUrl", "#something");
getJspBody().invoke(null);
}
}
public void setTop(Integer value) {
...
}
}
<ecomm:bestSellers top="10">
<tr class="navigation_row">
<td class="navigation_sub_cell">
<p><a href="${bestSellerUrl}" class="navigation_link">${bestSeller}</a></p>
</td>
</tr>
</ecomm:bestSellers>
So, I'm not getting any exception, but the ${bestSeller} and ${bestSellerUrl} are being kept as they are, and not being evaluated. Does someone know what's going on?
Thanks