Ugo Cei wrote:
Il giorno 27/gen/06, alle ore 15:54, Leszek Gawron ha scritto:
Ugo Cei wrote:
Our docs [1] state that something like:
<jx:forEach var="${var}"
items="${java.util.StringTokenizer(items, delims)}">
</jx:forEach>
should work. However, that doesn't seem to be the case, at least in
2.1.8 while it apparently worked before. I did a few more tests and
discovered that even simple cases like ${java.util.Date ()} produce
no output and no error message. This even if I put "Packages." in
front of the package name. Is this a bug or what?
Ugo
[1] http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html
Didn't you want to do:
<jx:forEach var="varName"
items="${java.util.StringTokenizer(items, delims)}">
</jx:forEach>
The code I copied above is straight from our docs, but it doesn't make
an inch of a difference whether I change to what you suggest or not.
The problem is that invoking Java class constructors or calling static
methods does not work.
As I replied in another message: referencing any java constructs like:
- packages
- classes
- constructors
- static methods
- constants
is available in jxtg via rhino (org.mozilla.javascript.NativeJavaClass,
NativeJavaPackage, NativeJavaTopPackage). ${Packages} is simply a
NativeJavaTopPackage and ${java} is a NativeJavaPackage. They are
treated as ordinary view data. I have never tried but this should work also:
<jx:set var="MyConstantsClass"
value=${Packages.com.mycompany.some.very.long.package.name.MyConstantsClass}"/>
<jx:if test="${bean.status == MyConstantsClass.STATUS_OK}">
<ok/>
</jx:if>
Unfortunatelly in 2.1.x those variables are only properly initialized
when flowscript is the controller. 2.2 artificialy creates those
variables no matter if you already have rhino context available or not.
--
Leszek Gawron [EMAIL PROTECTED]
IT Manager MobileBox sp. z o.o.
+48 (61) 855 06 67 http://www.mobilebox.pl
mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65