By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,558 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,558 IT Pros & Developers. It's quick & easy.

JSP TLD question: why my custom tag isn't picking up the ${param.product} parameter?

P: n/a
Hi, thanks in advance for any help you can offer me.

I'm wrestling with the following problem:

The following is on the same jsp page and say that the product
parameter is "foo":

// This works fine, and results in 'foo' being written:
<c:out value="${param.product}" />

// This does not, it results in '${param.product}' being written
// (the quickOrder tag is just writing the value back, at the moment):
<common_tags:quickOrder product="${param.product}" />

Do you have any idea why the param.product in my custom tag is not
being converted into the value 'foo'?

(c:out is a jakarta-taglibs\standard-1.0 tag, and I'm running this on
JRun4; the TLD for both the apache taglibs and for my custom tag are
in the appropriate place -- below I've attached the relavent portion
of the tld if you need to see it).

Best,

Tom

-----

<tag>
<name>quickOrder</name>
<tagclass>mytags.QuickOrder</tagclass>
<body-content>JSP</body-content>
<attribute>
<name>product</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If it's not an EL, does it work pefect?

tf*****@math.luc.edu (Thomas P. Fuller) wrote in message news:<ff**************************@posting.google. com>...
Hi, thanks in advance for any help you can offer me.

I'm wrestling with the following problem:

The following is on the same jsp page and say that the product
parameter is "foo":

// This works fine, and results in 'foo' being written:
<c:out value="${param.product}" />

// This does not, it results in '${param.product}' being written
// (the quickOrder tag is just writing the value back, at the moment):
<common_tags:quickOrder product="${param.product}" />

Do you have any idea why the param.product in my custom tag is not
being converted into the value 'foo'?

(c:out is a jakarta-taglibs\standard-1.0 tag, and I'm running this on
JRun4; the TLD for both the apache taglibs and for my custom tag are
in the appropriate place -- below I've attached the relavent portion
of the tld if you need to see it).

Best,

Tom

-----

<tag>
<name>quickOrder</name>
<tagclass>mytags.QuickOrder</tagclass>
<body-content>JSP</body-content>
<attribute>
<name>product</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

Jul 17 '05 #2

P: n/a

"Thomas P. Fuller" <tf*****@math.luc.edu> wrote in message
news:ff**************************@posting.google.c om...
Hi, thanks in advance for any help you can offer me.

I'm wrestling with the following problem:

The following is on the same jsp page and say that the product
parameter is "foo":

// This works fine, and results in 'foo' being written:
<c:out value="${param.product}" />

// This does not, it results in '${param.product}' being written
// (the quickOrder tag is just writing the value back, at the moment):
<common_tags:quickOrder product="${param.product}" />

Do you have any idea why the param.product in my custom tag is not
being converted into the value 'foo'?

(c:out is a jakarta-taglibs\standard-1.0 tag, and I'm running this on
JRun4; the TLD for both the apache taglibs and for my custom tag are
in the appropriate place -- below I've attached the relavent portion
of the tld if you need to see it).

Best,

Tom

-----

<tag>
<name>quickOrder</name>
<tagclass>mytags.QuickOrder</tagclass>
<body-content>JSP</body-content>
<attribute>
<name>product</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>


Looks like your custom tag doesn't support expression language. EL support
has to be coded into your tag handler, it's not magically provided by
default unfortunately. Either use standard jsp <%= someValue %> to provide
the value, or add in EL support.

First of all you'll need to set rtexprvalue = false in the TLD. Then your
setProduct method will look something like this:

public void setProduct(String value) throws JspException {
try {
product = (Clazz) ExpressionUtil.evalNotNull(
"quickOrder",
"product",
value,
Clazz.class,
this,
pageContext);
} catch (NullAttributeException ex) {
product = null;
}
}

Where Clazz is the class you're expecting to return. You'll need to add the
JSTL jar to your path if it isn't there already, and import

import org.apache.taglibs.standard.tag.common.core.NullAt tributeException;
import org.apache.taglibs.standard.tag.el.core.Expression Util;

Let me know how it goes :-)



Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.