looks like a bug then - you could add a JIRA On Dec 21, 2007 11:51 PM, Drew McAuliffe <[EMAIL PROTECTED]> wrote: > The problem with the identity validator is that it doesn't seem to capture > the current value of the other control, which is the essential problem I'm > having. If you have 2 controls, and the second one uses an identity > validator to make sure it's the same as the first, if you change them both > at the same time, then the validator assumes the old value of the first > control rather than the new one. So if the controls were set to "1" and "2", > respectively, and on a submit you set them both to "3", the validator > doesn't pick up that the first control was set to "3" on that submit. So > validation fails, because it thinks its comparing "1" to "3" instead of the > current values, "3" to "3". > Am I missing something obvious? While debugging the Identity validator, it > is definitely not picking up the value in the "referent" control that was > submitted with the form. It's picking up its old value. > > This is the crux of the problem I'm having. I don't know where in the course > of a form submit that new values as part of the submission are available to > other parts of the form. I'll look into the grouping example. > > > On Dec 21, 2007 7:44 AM, Steve Shucker <[EMAIL PROTECTED]> wrote: > > > http://tapestry.apache.org/tapestry4.1/usersguide/validation.html > > > > http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/validator/Identity.html > > > > Look at the match/differ validators. The cover the basic concept of a > > validator that acts on two components. You can probably write a variant > > of the Identity class that will throw a ValidatorException is the > > referent is non-null and the validated control is null. > > > > Another approach would be to encapsulate the interrelated controls in a > > component to be validated as a group. I think there's an example of > > this in Kent Tong's book. > > > > -Steve > > > > Drew McAuliffe wrote: > > > I'm running into a problem with validators in T4. I have a situation > > where I > > > sometimes need to validate a field on a form, but only if another field > > on > > > the same form has a certain set of values. For example, a "ship > > quantity" > > > field on an order form is only required if the order delivery method is > > > "shipment" and not "download" (you don't have a ship quantity for an > > order > > > that doesn't ship). Again, both fields are on the same form. > > > Maybe I'm missing something but I don't know how to make the use of a > > > validator conditional. I don't want to do manual validation in the > > submit > > > method. I've tried setting the "validators" of the text field to a > > method on > > > the page class that checks the field values, but it seems that the > > > validation does not have access to the runtime selection made by the > > user. > > > In other words, at the time my method tries to check if a validator is > > > necessary, it is looking at old data and doesn't have access to the > > value > > > the user was trying to submit. Something related to when in the page > > cycle > > > validation is checked, I'm sure. > > > > > > Any ideas? This is for server-side validation, though of course > > client-side > > > validation would be really nice too! (I imagine that would have to be > > using > > > some sort of async callback method). > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > >
-- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]