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
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
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
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