On 12/12/06, Charbel Abdul-Massih <[EMAIL PROTECTED]> wrote:
In my Backing Bean called editPhone, I have a phones property which contains
a list of PhoneNumber objects…The PhoneNumber object has a rawValue property
that is the actual phone number, and the property I'm trying to retrieve and
set…
In my JSF, I have the following code
<t:dataList value="#{editPhone.phones}" var="phone" id="phonesTable"
rowIndexVar="row">
<h:column>
<h:inputText value="#{editPhone.phones[row].rawValue}" size="10"/>
</h:column>
</t:dataList>
I am getting the right values back into my text boxes, but when I edit the
values on the screen and hit submit, they are not being saved back into my
bean. What am I doing wrong? How can I get such a scenario to work???
First off, you can use
<t:dataList value="#{editPhone.phones}" var="phone" id="phonesTable">
[...]
<h:inputText value="#{phone.rawValue}" size="10"/>
and dump the row index.
There's many reasons why your values might not being saved. Here's a
couple that I can think of.
1) You're hitting a validation error somewhere on your page. It may
not even be related to your phone list. Add these tags to your page:
<t:messages globalOnly="true" showDetail="true" />
<t:messages globalOnly="false" showDetail="true" />
2) The editPhone bean is request-scoped, and thus there's no list to
work from when your form is submitted. You can test for this problem
by making your bean session-scoped temporarily. My preferred fix for
this situation is to use
<t:saveState id="editPhonePhones" value="#{editPhone.phones}"/>