You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by euphobot <eu...@pacbell.net> on 2005/04/19 02:04:21 UTC

BindingException

Hi
I am new to tapestry, but things were going very well until an immovable 
BindingException.  I have so tried many fixes that I now am sure that I 
am not interpreting the error messages correctly. I sure would 
appreciate some advice.

I have a TeamForm.html with
            <span jwcid="@PropertySelection" 
model="ognl:storyPropertySelectionModel" value="ognl:team.storyid"/>
This comes to the exceptions below when a save is attempted through a 
listener method. Before that it imperfectly renders the first time 
(pre-rewind) with the minor(?) flaw that the PropertySelection will not 
be set to the right value.

I can verify that when pageBeginRender(PageEvent) completes, team and 
its story are correctly instantiated, so I have a
team object with a set/getStoryid(){return story.getId();} Also the 
storyid value is a valid Integer.

I get a BindingException (but only on the rewind when I try to do a form 
submit for a save,
but before the actual save method is entered):
    Unable to update expression 'team.storyid' for 
org.x.TeamForm$Enhance_19@191c263[teamForm]
    to org.x.Story@33549b[id=1,longname=longname1].

Apparently caused by a NumberFormatException
    For input string: "org.x.Story@33549b[id=1,longname=longname1]"

To me it looks like tapestry is trying to stuff Story.toString() into 
team.storyid which should be an Integer.
I don't know how to stop that.
I tried <property-specification name="storyid"  
type="java.lang.Integer"/> without change.

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: BindingException

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Apr 19, 2005, at 2:20 AM, euphobot wrote:
> I thoroughly appreciate your response and, if it were a textarea or 
> TextField, I would thoroughly expect to supply and receive a String. 
> However I am supplying an Integer (team.storyid) to a 
> PropertySelection

Oops!  I apologize for not being more careful about noticing that in 
your original message.

> and expect in return an Integer returned to the same property.  The 
> question remains as to why the PropertySelection displays correctly as 
> a selection on the first round (pre-rewind) except for selecting the 
> correct value and tries to put a string to the Integer property 
> causing an exception.

PropertySelection renders properly in your case because you gave it a 
proper model.  It doesn't select the correct value because you have 
different types and thus no item in the list .equals() the current 
value.

> However, there is something compelling in your observation that the 
> component returns a String, enough that it opened my eyes a little 
> more. In fact it is a Story.toString() and suddenly I saw that the 
> component is returning Story.  If I change the value from storyid to 
> story, everything works as it should.  Review ing  the api for 
> IPropertySelectionModel I see the source of the confusion is in the 
> description of the method Object translate(String value).  Adding one 
> sentence would clear things up: "This returns the object from the list 
> that the component will return." And someplace it should be pointed 
> out that is a real OO component unlike the underlying html selection 
> that would have returned a value alone. Finally the examples on the 
> component reference need cleaning up. I wonder if I could do all that 
> in a bug report.

Yes, you're welcome (and encouraged!) to do this all within a single 
patch.

And this just goes to show that Tapestry has a steep *un*learning curve 
with components like PropertySelection - where it is quite surprising 
the first few times you use it that you really get back a rich object 
as the value and not a simple id.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: BindingException

Posted by euphobot <eu...@pacbell.net>.
Erik -
I thoroughly appreciate your response and, if it were a textarea or 
TextField, I would thoroughly expect to supply and receive a String. 
However I am supplying an Integer (team.storyid) to a PropertySelection 
and expect in return an Integer returned to the same property.  The 
question remains as to why the PropertySelection displays correctly as a 
selection on the first round (pre-rewind) except for selecting the 
correct value and tries to put a string to the Integer property causing 
an exception.  So the type of component is not one that demands a text 
or String value, and in fact should by type of component should demand 
an Integer. Bottom line -- the type of component is not affecting things 
(as far as I can see). Further the model is a list of value and label 
where the value is Integer and label of String.

However, there is something compelling in your observation that the 
component returns a String, enough that it opened my eyes a little more. 
In fact it is a Story.toString() and suddenly I saw that the component 
is returning Story.  If I change the value from storyid to story, 
everything works as it should.  Review ing  the api for 
IPropertySelectionModel I see the source of the confusion is in the 
description of the method Object translate(String value).  Adding one 
sentence would clear things up: "This returns the object from the list 
that the component will return." And someplace it should be pointed out 
that is a real OO component unlike the underlying html selection that 
would have returned a value alone. Finally the examples on the component 
reference need cleaning up. I wonder if I could do all that in a bug report.

Thanks,
eupho


Erik Hatcher wrote:

>
> On Apr 18, 2005, at 8:04 PM, euphobot wrote:
>
>> I have a TeamForm.html with
>>            <span jwcid="@PropertySelection" 
>> model="ognl:storyPropertySelectionModel" value="ognl:team.storyid"/>
>> This comes to the exceptions below when a save is attempted through a 
>> listener method. Before that it imperfectly renders the first time 
>> (pre-rewind) with the minor(?) flaw that the PropertySelection will 
>> not be set to the right value.
>>
>> I can verify that when pageBeginRender(PageEvent) completes, team and 
>> its story are correctly instantiated, so I have a
>> team object with a set/getStoryid(){return story.getId();} Also the 
>> storyid value is a valid Integer.
>>
>> I get a BindingException (but only on the rewind when I try to do a 
>> form submit for a save,
>> but before the actual save method is entered):
>>    Unable to update expression 'team.storyid' for 
>> org.x.TeamForm$Enhance_19@191c263[teamForm]
>>    to org.x.Story@33549b[id=1,longname=longname1].
>>
>> Apparently caused by a NumberFormatException
>>    For input string: "org.x.Story@33549b[id=1,longname=longname1]"
>
>
> Is this with a TextField component?
>
>> To me it looks like tapestry is trying to stuff Story.toString() into 
>> team.storyid which should be an Integer.
>> I don't know how to stop that.
>> I tried <property-specification name="storyid"  
>> type="java.lang.Integer"/> without change.
>
>
> TextField *only* can bind to a java.lang.String, sadly.
>
> Try ValidField (and set up a validator and form delegate appropriately).
>
>     Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: BindingException

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Apr 18, 2005, at 8:04 PM, euphobot wrote:
> I have a TeamForm.html with
>            <span jwcid="@PropertySelection" 
> model="ognl:storyPropertySelectionModel" value="ognl:team.storyid"/>
> This comes to the exceptions below when a save is attempted through a 
> listener method. Before that it imperfectly renders the first time 
> (pre-rewind) with the minor(?) flaw that the PropertySelection will 
> not be set to the right value.
>
> I can verify that when pageBeginRender(PageEvent) completes, team and 
> its story are correctly instantiated, so I have a
> team object with a set/getStoryid(){return story.getId();} Also the 
> storyid value is a valid Integer.
>
> I get a BindingException (but only on the rewind when I try to do a 
> form submit for a save,
> but before the actual save method is entered):
>    Unable to update expression 'team.storyid' for 
> org.x.TeamForm$Enhance_19@191c263[teamForm]
>    to org.x.Story@33549b[id=1,longname=longname1].
>
> Apparently caused by a NumberFormatException
>    For input string: "org.x.Story@33549b[id=1,longname=longname1]"

Is this with a TextField component?

> To me it looks like tapestry is trying to stuff Story.toString() into 
> team.storyid which should be an Integer.
> I don't know how to stop that.
> I tried <property-specification name="storyid"  
> type="java.lang.Integer"/> without change.

TextField *only* can bind to a java.lang.String, sadly.

Try ValidField (and set up a validator and form delegate appropriately).

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org