cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jianyu Wang <Jia...@Imkenberg.de>
Subject Help about how to use Repeater--bean binding
Date Thu, 18 Sep 2003 15:50:20 GMT
hi,
I have a problem when I use repeater  to add a new row in the form and later
save it into bean. I get the Exception like these:

org.apache.commons.jxpath.JXPathException: Exception trying to create xpath
addresses[1]; org.apache.cocoon.woody.binding.InsertBeanJXP
athBinding.access$000(Lorg/apache/cocoon/woody/binding/InsertBeanJXPathBindi
ng;)Ljava/lang/String;
        at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath(JXPathCon
textReferenceImpl.java:420)
        at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath(JXPathCon
textReferenceImpl.java:397)
        at
org.apache.cocoon.woody.binding.RepeaterJXPathBinding.saveFormToModel(Repeat
erJXPathBinding.java:233)
        at
org.apache.cocoon.woody.binding.ComposedJXPathBindingBase.saveFormToModel(Co
mposedJXPathBindingBase.java:108)
        at
org.apache.cocoon.woody.binding.ContextJXPathBinding.saveFormToModel(Context
JXPathBinding.java:107)
        at
org.apache.cocoon.woody.binding.JXPathBindingBase.saveFormToModel(JXPathBind
ingBase.java:115)


my form defination is :

  <wd:repeater id="addresses">
      <wd:output id="oid">
        <wd:datatype base="long"/>
      </wd:output>
	  
	  <wd:field id="street" required="true">
	   <wd:label><i18n:text>Street</i18n:text></wd:label>
	   <wd:datatype base="string">
	      <wd:validation>
	        <wd:length min="2"/>
	      </wd:validation>
	    </wd:datatype>
	  </wd:field>
 
	  <wd:booleanfield id="address-select">
       <wd:label>Select</wd:label>
      </wd:booleanfield>
    
   </wd:repeater>

and bind data like this:

  <wb:repeater id="addresses"
    parent-path="."
    row-path="addresses"
    unique-row-id="oid"
    unique-path="@oid"
    >
    <!-- important note: the row-path is used inside jxpath-createPath
context,
         as a consequence it cannot have dependent children or predicates
-->

    <wb:on-bind>
    	<!-- executed on updates AND right after the insert -->
      <wb:value id="street" path="street"/>
    </wb:on-bind>

    <wb:on-delete-row>-->
    	<!-- chose on of these to test -->
    	<!--
      <wb:set-attribute name="row-state" value="deleted" />
      -->
      <wb:delete-node />
    </wb:on-delete-row>

    <wb:on-insert-row>
      <wb:insert-bean
        classname="com.imkenberg.bo.address.impl.AddressBean"
        addmethod="addAddress"/>
    </wb:on-insert-row>
  </wb:repeater>    

And then the parent Bean has properties like this:
public abstract class DefaultPartyBean implements Party {
    private Long oid;
    private String email;
    private String password;
    protected List addresses = new LinkedList();
and also methods.
    public PartyAddress getAddress() 
    public void addAddress( PartyAddress address ) 
    public Iterator getAddressIterator()  
    public List getAddresses() 
    public void setAddresses( List addresses ) 

And the AddressBean is simplely like this:
public class AddressBean implements Address {
    private Long oid;
    private String city;
    private String country;
    private String houseNo;
    private String zip;
    private String street;
    private long type;
with get and set methods.

I am glad for your helping

Thanks

Jianyu

Mime
View raw message