cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vilya Harvey <vi...@lineone.net>
Subject ClassCastException in binding framework.
Date Wed, 07 Jul 2004 16:01:22 GMT
Hi,

With the Cocoon 2.1.5 release, the binding framework throws a 
ClassCastException if you use anything other than an <fb:value> in the 
<fb:identity> part of a repeater binding. Is this intentional behaviour, or 
a bug?

The offending code comes from RepeaterJXPathBinding.java:

------------------
/**
  * Get the identity of the given row. That's infact a list of all the
  * values of the fields in the form model that constitute the identity.
  * @param thisRow
  * @return List the identity of the row
  */
private List getIdentity(Repeater.RepeaterRow row) {
   List identity = new ArrayList();

   JXPathBindingBase[] childBindings =
       this.identityBinding.getChildBindings();
   if (childBindings != null) {
     int size = childBindings.length;
     for (int i = 0; i < size; i++) {
       String fieldId =
           ((ValueJXPathBinding)childBindings[i]).getFieldId();
       Widget widget = row.getChild(fieldId);
       Object value = widget.getValue();
       identity.add(value);
     }
   }
   return identity;
}
------------------

The first line inside the for statement, which retrieves a field ID, is 
where the exception occurs. If you're using an <fb:javascript> binding to 
generate IDs dynamically, for example, the value in the childBindings array 
will be an instance of JavaScriptJXPathBinding - which cannot be cast to 
ValueJXPathBinding.

I'm guessing that the correct thing to do would be to use only methods from 
the JXPathBindingBase class to retrieve the identity values, but I can't see 
how. I'm probably overlooking something, as I'm not very familiar with the 
internals of the binding framework (yet!).

Can anyone shed any more light on this?

Cheers,
Vil.
-- 
             __
    o|   _. /  \|o._  _  _ ._  _  ._  _ _|_
\/ ||\/(_|| (|/||| |(/_(_)| |(/_o| |(/_ |_
      /     \__
http://website.lineone.net/~vilya


Mime
View raw message