wood burning stoves 2.0*
The moose likes JSF and the fly likes validating t:columns together Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "validating t:columns together" Watch "validating t:columns together" New topic
Author

validating t:columns together

A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
I need to validate the data entered in each row(all columns inputTexts) in a datatable. I am using myfaces t:columns since the numbers of columns are dynamic. I need some ideas how to do validation for the data entered by the user in each row together. I bound the datatable to a backing bean property, I have a validator method in my backing bean and I am calling this method using a dummy hidden field's validator attribute. Inside the method, I am accessing the datatable via its property in the backing bean. But when I am stepping through the rows from the method, I find that they do not contain the latest data entered.

I understand that the data is not yet posted to the model at this point, I am still in validation phase. But then how will I be able to get hold of data of each inputtext while in validation phase?
First of all is this the right way to do the validation?

Thanks for any help.
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
As a workaround, I am now validating in the action method in the backing bean - AFTER - the values are posted to model and then re throwing the same page if there are any invalid rows.
Since I now cannot add an error message to the faces Context(I am now Invoke Application phase), I used an extra text column at the end of each row and populating it with messages in the event of any validation errors.

Although this solves the problem for now, I am really interested to know solution that does validation even before the values are posted to model.

Thanks in advance.
Wally Hartshorn
Ranch Hand

Joined: Jan 30, 2003
Posts: 77
I'm having the same problem.

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.

When that validator 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 it does NOT have the new values of the fields that were in the 3-by-3 table, but it DOES have the new value that was entered in the standalone input field.

However, 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.

This has been EXTREMELY confusing and frustrating! I'm using Java 1.5, MyFaces 1.3, and Tomahawk 1.3. Has anyone found a way to make validation with DataModel work properly?


Wally Hartshorn
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
Howdy "A"

In order to keep things friendly, I'd like to ask you to update your display name to match the JavaRanch naming policy.

Thanks!

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
Bert Bates,
I read the naming policy again today and it says one could use initials for the first name if one wanted.
Is something changed now? I have had this display name for almost 2 years?! Before I change it to my real name, can you clarify?
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
Hey A. -

You have my apology! I haven't actually read the darned thingfor a long time and I didn't realize that a first initial was okay! Proceed

Bert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validating t:columns together