You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jianyu Wang <Ji...@Imkenberg.de> on 2003/09/18 17:50:20 UTC
Help about how to use Repeater--bean binding
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
Re: Help about how to use Repeater--bean binding
Posted by Marc Portier <mp...@outerthought.org>.
Hugo Burm wrote:
> Hello Jianyu,
>
> Your unique-row-id (oid) must be a String. It is somewhere in the Woody
> documentation and there is a comment in the sources that some conversion
> routines should be added. The Long appears in your <wd:repeater> in the form
> definition, and in your AddressBean Java class.
>
> Hugo
>
Hugo,
I've created a fix for the mentioned TODO's and am updating the samples
to include the long datatype to show off this new support for convertors
on the row_ID field of the repeaters.
Maybe odd at first sight but the consequence of this is that if you have
a backend that is strongly typed (i.e. it produces Java Objects and
beans rather then the typical Strings of the XML backend) then one will
NOT NEED TO DEFINE the convertor.
will check in right away,
Jianyu, could you verify that this is solving your problems?
regards,
-marc=
>
>>-----Original Message-----
>>From: Jianyu Wang [mailto:Jianyu@Imkenberg.de]
>>Sent: Thursday, September 18, 2003 5:50 PM
>>To: dev@cocoon.apache.org
>>Subject: Help about how to use Repeater--bean binding
>>
>>
>>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/InsertBeanJ
>>XPathBindi
>>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.saveFormToMo
>>del(Repeat
>>erJXPathBinding.java:233)
>> at
>>org.apache.cocoon.woody.binding.ComposedJXPathBindingBase.saveForm
>>ToModel(Co
>>mposedJXPathBindingBase.java:108)
>> at
>>org.apache.cocoon.woody.binding.ContextJXPathBinding.saveFormToMod
>>el(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
>>
>
>
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://radio.weblogs.com/0116284/
mpo@outerthought.org mpo@apache.org
RE: Help about how to use Repeater--bean binding
Posted by Hugo Burm <hu...@xs4all.nl>.
Hello Jianyu,
Your unique-row-id (oid) must be a String. It is somewhere in the Woody
documentation and there is a comment in the sources that some conversion
routines should be added. The Long appears in your <wd:repeater> in the form
definition, and in your AddressBean Java class.
Hugo
> -----Original Message-----
> From: Jianyu Wang [mailto:Jianyu@Imkenberg.de]
> Sent: Thursday, September 18, 2003 5:50 PM
> To: dev@cocoon.apache.org
> Subject: Help about how to use Repeater--bean binding
>
>
> 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/InsertBeanJ
> XPathBindi
> 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.saveFormToMo
> del(Repeat
> erJXPathBinding.java:233)
> at
> org.apache.cocoon.woody.binding.ComposedJXPathBindingBase.saveForm
> ToModel(Co
> mposedJXPathBindingBase.java:108)
> at
> org.apache.cocoon.woody.binding.ContextJXPathBinding.saveFormToMod
> el(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
>