Conversion error in write access to a property

Hello,

in JSF I get a conversion error when I try to save an order.

An order object has a from- and a to-address.

To avoid duplicate coding I encapsulated the address data in a class Address.

publicclass Orderimplements Serializable{

private Address fromAddress;

private Address toAddress;

//Getter/Setter for addresses are implemented

}

publicclass Addressimplements Serializable{

private String city;

private String country;

private String remark;

...

//Getter/Setter for all fields are implemented

}

Reading the address data works without problems.

Writing (saving an order) does not work. For each property of Address a conversion error is thrown.

The access is like

<t:inputText value="#{orderBean.order.address.country}" .../>

Principally it is possible to access the address properties because reading works.

What is going wrong when writing?

And how could I find out more details about the conversion errors occurred?

Any hints appreciated

Jan

[1650 byte] By [ed.o.neilla] at [2007-10-3 1:36:22]
# 1
First put in a <h:messages/> tag into your form to see what the reported validation-error messages are. If that is not enough information, then check you application server logs -- there may be a stack trace or message recorded there.
BlackBeana at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Edit: nevermind.Message was edited by: BalusC
BalusCa at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hi,

thx for the hint. I have already the <h:messages> tag at the top of the page, They just show (the German version for) "Conversion error".

App server tomcat doesn't log anything about this problem.

I could solve the problem by moving the properties from class Address to Order and duplicate it, but that's not what I want...

Jan

ed.o.neilla at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Are you sure the conversion error is in the place you tell?Can you put the source of the page please?
pringia at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hello,

I'm afraid these are the fileds causing the errors.

Here is an excerpt from the JSP.

When I set rendered="false" for the panelGroup containing five "crucial" fields, I get five messages "conversion error" less.

<t:panelTab label="#{messages['auftrag.reiter_von']}" rendered="true">

<t:panelGrid columns="1">

...

<%-- Line with input fields--%>

<t:panelGroup>

<t:panelGrid columns="5">

<!-- Name -->

<t:inputText size="20" maxlength="80"

value="#{orderBean.order.fromAddress.name}"

readonly="#{orderBean.readonly}">

</t:inputText>

<!-- Street -->

<t:inputText size="20" maxlength="80"

value="#{orderBean.order.fromAddress.street}"

readonly="#{orderBean.readonly}">

</t:inputText>

<!-- Zip -->

<t:inputText size="5" maxlength="10"

value="#{orderBean.order.fromAddress.zip}"

readonly="#{orderBean.readonly}">

</t:inputText>

<!-- Country -->

<t:inputText size="5" maxlength="5"

value="#{orderBean.order.fromAddress.country}"

readonly="#{orderBean.readonly}">

</t:inputText>

<!-- City -->

<t:inputText size="40" maxlength="80"

value="#{orderBean.order.fromAddress.city}"

readonly="#{orderBean.readonly}">

</t:inputText>

</t:panelGrid>

</t:panelGroup>

Thx for assistance. If there is no solution in sight, I will refactor it the way I described. It already took me too much time...

Jan

ed.o.neilla at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Did you try this:public class Order implements Serializable{private Address fromAddress = new Address();private Address toAddress = new Address(); ...}
hammouda at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

Direct hit! I forgot to instantiate the Address objects. Now I do it in the constructor. How could this happen me :(

Strange message from the JSF anyway, I rather expected a NullPointerExc.

Hammoud, how could you guess it? Did the same happen to you?

Great thanks to you.

Jan

ed.o.neilla at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
> Did the same happen to youYes - need also some time to get it.> Strange message from the JSF anyway, I rather expected a NullPointerExc.I wonder too:)
hammouda at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
same happened to me :) thanks hammoud!!!!
Alzhaid.a at 2007-7-14 18:34:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...