cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Boksa <mailingli...@boksa.de>
Subject [2.2] Accessing static methods in JX Templates
Date Fri, 15 Aug 2008 23:21:06 GMT
Hi List,

at the moment I am working on a simple template to output a list of  
some arbitrary beans including their properties. To do this I would  
like to use PropertyUtil.describe(java.lang.Object bean) [1].

However there seems to be some problem when I try to access  
PropertyUtils within the template (where bean is set by jx:forEach).

    <jx:set var="beanMap" value="$ 
{org.apache.commons.beanutils.PropertyUtils.describe(bean)}"/>
    <jx:out value="${beanMap}"/>

The construct runs without an error but does not output anything. Is  
this the correct behaviour or did I run into a bug?

For now I am using the following workaround (the template is called  
from flowscript)

    importClass(Packages.org.apache.commons.beanutils.PropertyUtils);

    [...]

    cocoon.sendPage("foo", {
       "beanList"	: list,
       "PropertyUtils"	: cocoon.createObject(PropertyUtils)
    });

and accordingly in the template:

    <jx:set var="beanMap" value="${PropertyUtils.describe(bean)}"/>
    <jx:out value="${beanMap}"/>

which outputs a map of the Bean's properties as expected.

As you might imagine I am absolutely not happy with this workaround.  
Is there any better solution or a fix to the issue mentioned above? If  
you need to know more information just let me know. I am looking  
forward to your answers.

Thanks in advance

Benjamin


[1] http://commons.apache.org/beanutils/commons-beanutils-1.7.0/docs/api/org/apache/commons/beanutils/PropertyUtils.html#describe(java.lang.Object)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message