cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject ClassCastException in ScriptablePropertyHandler/JXTemplateGenerator
Date Tue, 16 Nov 2004 12:33:03 GMT
I'm getting a ClassCastException when using the JXTemplateGenerator and passing
bizdata to it:

java.lang.ClassCastException
at org.apache.cocoon.components.flow.javascript.ScriptablePropertyHandler
                           .getPropertyNames(ScriptablePropertyHandler.java:77)
at org.apache.cocoon.generation.JXTemplateGenerator
                           .fillContext(JXTemplateGenerator.java:2410)
at org.apache.cocoon.generation.JXTemplateGenerator
                           .setContexts(JXTemplateGenerator.java:2457)
at org.apache.cocoon.generation.JXTemplateGenerator
                           .setup(JXTemplateGenerator.java:2397)

It's an older version of Cocoon (2004-06-29):

http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/java/org/apache/cocoon/
       components/flow/javascript/ScriptablePropertyHandler.java?annotate=1.7
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/java/org/apache/cocoon/
       generation/JXTemplateGenerator.java?annotate=1.50

In this code some properties are casted to Strings:

69 :  Object[] ids;
70 :  if (obj instanceof ScriptableObject) {
71 :      ids = ((ScriptableObject)obj).getAllIds();
72 :  } else {
73 :      ids = ((Scriptable)obj).getIds();
74 :  }
75 :  String[] result = new String[ids.length];
76 :  for (int i = 0; i < result.length; i++) {
77 :      result[i] = (String)ids[i];
78 :  }

But obj is a NativeArray in my case and ids after running through line 71
contains an Integer 0 and a String "length".

The flowscript code looks like the following:

var legalcasesArray = new Array();
for (var i = 0; i < legalcases.size(); i++) {
    var lc = legalcases.get(i);
    var event = lc.getEvent();
    legalcasesArray[i] = {"document": event.getDocument(lc), "variant":
                          lc.getDocumentVariant(), "eventId": event.getId()};
}
cocoon.sendPage("internal-display-document-bulk", legalcasesArray);

Everything works like expected, I only get this exception stacktrace printed on
the console as the exception is ignored. Is there an error in using JXTemplate
or is it a bug?

Joerg


Mime
View raw message