Stripes

Problems with 'beanclass' attribute of UseActionBean tag

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.5
  • Component/s: Tag Library
  • Labels:
    None
  • Environment:
    XP, Tomcat 5.5

Description

a) Assignment to 'var' appears to be missing in UseActionBeanTagExtraInfo.getVariableInfo().
b) When tag called as:
<s:useActionBean beanclass="a.b.c.${beanclass}" var="actionBean"/>
get:
java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String
at net.sourceforge.stripes.tag.UseActionBeanTagExtraInfo.getVariableInfo(UseActionBeanTagExtraInfo.java:53)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:715)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1442)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2166)

Thanks.

Activity

Hide
Phil Sladen added a comment - 14/Feb/08 6:58 AM

Oops, title should have been "Problems with 'beanclass' attribute of UseActionBean tag", but i can't see how to change it now.

Show
Phil Sladen added a comment - 14/Feb/08 6:58 AM Oops, title should have been "Problems with 'beanclass' attribute of UseActionBean tag", but i can't see how to change it now.
Hide
Frederic Daoud added a comment - 14/Feb/08 8:19 AM

I've investigated this. The problem is that the useActionBean tag has UseActionBeanTagExtraInfo, which tries to tell the container the class of the action bean. If you assign beanclass to a String, such as beanclass="com.myco.MyActionBean", this works fine. But if you assign it to an rtexprvalue, whether it is a dynamic String as in the example above, or a Class object such as "${actionBean.class}" or "<%= someClassInstance %>", the UseActionBeanTagExtraInfo cannot determine the class of the Action Bean. Indeed, TagExtraInfo is given a TagData object, and the Javadocs clearly state that translation-time information only is available - request-time expressions are not yet available at this point.

The end result is that for rtexprvalues, UseActionBeanTagExtraInfo will either:

1) get a String such as "a.b.c.${beanclass}" (unresolved), and pass that on as the class name, causing an error
2) get the javax.servlet.jsp.tagext.TagData.REQUEST_TIME_VALUE Object. This object cannot be cast as a String, and causes the error shown above.

I'm not sure what's next. It'd be nice for the beanclass attribtue of <s:useActionBean> to work just like the beanclass attribute of all the other Stripes tags. I don't know the consequences of changing/removing UseActionBeanTagExtraInfo. People who know more in this area, please speak up

Show
Frederic Daoud added a comment - 14/Feb/08 8:19 AM I've investigated this. The problem is that the useActionBean tag has UseActionBeanTagExtraInfo, which tries to tell the container the class of the action bean. If you assign beanclass to a String, such as beanclass="com.myco.MyActionBean", this works fine. But if you assign it to an rtexprvalue, whether it is a dynamic String as in the example above, or a Class object such as "${actionBean.class}" or "<%= someClassInstance %>", the UseActionBeanTagExtraInfo cannot determine the class of the Action Bean. Indeed, TagExtraInfo is given a TagData object, and the Javadocs clearly state that translation-time information only is available - request-time expressions are not yet available at this point. The end result is that for rtexprvalues, UseActionBeanTagExtraInfo will either: 1) get a String such as "a.b.c.${beanclass}" (unresolved), and pass that on as the class name, causing an error 2) get the javax.servlet.jsp.tagext.TagData.REQUEST_TIME_VALUE Object. This object cannot be cast as a String, and causes the error shown above. I'm not sure what's next. It'd be nice for the beanclass attribtue of <s:useActionBean> to work just like the beanclass attribute of all the other Stripes tags. I don't know the consequences of changing/removing UseActionBeanTagExtraInfo. People who know more in this area, please speak up
Hide
Frederic Daoud added a comment - 16/Jun/08 3:18 PM

I got bitten by this bug today and it hurt

In a nutshell, using <s:useActionBean beanclass="${something}"/> results in a very hard-to-track down JSP error. It's all UseActionBeanTagExtraInfo's fault. I tested removing UseActionBeanTagExtraInfo and that solves the problem. What is that class good for anyway, and are its benefits worth the cost of not being able to use something dynamic in the beanclass attribute of useActionBean?

Show
Frederic Daoud added a comment - 16/Jun/08 3:18 PM I got bitten by this bug today and it hurt In a nutshell, using <s:useActionBean beanclass="${something}"/> results in a very hard-to-track down JSP error. It's all UseActionBeanTagExtraInfo's fault. I tested removing UseActionBeanTagExtraInfo and that solves the problem. What is that class good for anyway, and are its benefits worth the cost of not being able to use something dynamic in the beanclass attribute of useActionBean?
Hide
Frederic Daoud added a comment - 16/Jun/08 5:26 PM

Fixed in build 936. Managed to keep both the ExtraInfo class and make s:useActionBean work with a runtime beanclass.

Show
Frederic Daoud added a comment - 16/Jun/08 5:26 PM Fixed in build 936. Managed to keep both the ExtraInfo class and make s:useActionBean work with a runtime beanclass.

People

Vote (0)
Watch (1)

Dates

  • Created:
    14/Feb/08 6:54 AM
    Updated:
    04/Jan/11 2:59 PM
    Resolved:
    16/Jun/08 5:26 PM