I'm trying to validate input fields within t:columns backed by a DataModel
object. These input fields are validated by a custom validator method
attached to a hidden input field (so that I can do things like verify that
if something is entered in THIS field, then THAT field is blank).

What appears to be happening is that the UIInput fields in the DataModel do
not get updated until AFTER the validation phase. This means that the
validator can't access the values in the UIInput fields to do the
validation.

After much mystification and pulling out of hair, I finally made a small
webapp to test various combinations -- none of which work properly.

Suppose I have a 3-by-3 table of input fields backed by a DataModel, plus an
additional input field that is NOT part of the DataModel, plus a hidden
field that contains the hook to the validator.

 <t:dataTable id="myTable" var="oneRow"
     value="#{myBean.tableBody}">

     <t:columns id="oneCol" value="#{myBean.tableHeadings}"
         var="oneHeading">

         <f:facet name="header">
             <h:outputText value="#{oneHeading.value}" />
         </f:facet>

         <h:inputText value="#{myBean.cellValue}"
             binding="#{myBean.cellInput}" />

     </t:columns>

 </t:dataTable>

 <h:inputText binding="#{myBean.someNameInput}" />

 <t:commandButton value="Submit" action="submit" />

 <h:inputHidden value="needed" required="true"
     validator="#{myBean.validateAllCells}" />

The method myBean.getCellValue() returns the object entered in the field,
while myBean.getCellInput() returns the UIInput component that is bound to
the field.

When myBean.validateAllCells() runs, it loops through the rows and columns
of the DataModel, accessing the UIInput fields and doing its thing. After
that, it accesses the UIInput field for the stand-alone input field.

When it does this, I've found that the UIInput fields that were bound to
input fields within t:columns do NOT have the new values of the fields that
were in the 3-by-3 table, but the UIInput field that is bound to the
standalone input field (which is outside of the t:dataTable) DOES have its
new value. I determined this by having the validator consider all of the
fields to be in error, displaying their UIInput values in the error
messages. I've tried accessing UIInput.getLocalValue(),
UIInput.getSubmittedValue, and UIInput.getValue; none provide the validator
with the value that was just submitted.

AFTER the validator has run, the UIInput fields in the DataModel object are
updated, so if I click the Submit button again, then it sees those values.
In other words, the validator always sees what was entered on the PREVIOUS
button click.

If I attach a validator method directly to the input fields and access the
value of the object passed to it, the validator sees the proper value, but
that doesn't allow me to do the type of validation I need to do (where one
field's legal values are dependent upon another field's values).

This has been EXTREMELY confusing and frustrating! I'm using Java 5, MyFaces
1.1.3, and Tomahawk 1.1.3. Has anyone found a way to make validation with
t:columns and DataModel work properly? Is this an unreported bug in Tomahawk
or am I just missing something?
-- 
View this message in context: 
http://www.nabble.com/Validation-with-DataModel-and-t%3Acolumns-tf2332358.html#a6488960
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to