I think it is a bad idea to generate the control name in the your code. The way 
the control name is generated might be changed in the uture. 

 If you "collect" the dummy fields for onTimes and offTimes first in  
onValidateFromOnTime and  onValidateFromOffTime  methods, 
then do the cross validations  in onValidateFromForm method, it should work 
with a single TimeTableEntry  component. 


The  following example illustrates  "collecting" the dummy fields first in 
onValidateFromEntry, then do the cross validation in onValidateForm method. 


http://lombok.demon.co.uk /tapestry5Demo/test/crossvalidation2



Shing 




----- Original Message -----
From: John <j...@quivinco.com>
To: Shing Hing Man <mat...@yahoo.com>; Tapestry users 
<users@tapestry.apache.org>
Cc: 
Sent: Thursday, February 7, 2013 8:12 AM
Subject: Re: how to recordError against a form field in a loop

That was useful although my implementation is like this:

            int loopi = 0;
            for (TimetableEntry entry : timetableEntryFlash) {
                String loopex = loopi == 0 ? "" : ("_" + (loopi - 1));
                if (entry.getOnTime1() == null && entry.getOffTime1() != null) {
                    DummyField dField = new DummyField("fmtOnTime1" + loopex);
                    timetableForm.recordError(dField, "missing on time");
                }
                loopi++;
            }

so that I can validate data across rows as field pairs rather than as 
individual fields. I suspect at this point my time pairs should be a distinct 
component?

John
  ----- Original Message ----- 
  From: Shing Hing Man 
  To: Tapestry users 
  Sent: Wednesday, February 06, 2013 9:49 PM
  Subject: Re: how to recordError against a form field in a loop


  The following example might be useful.


http://lombok.demon.co.uk/tapestry5Demo/test/crossvalidation

  Shing

  ________________________________
  From: John <j...@quivinco.com>
  To: users@tapestry.apache.org 
  Sent: Wednesday, February 6, 2013 9:28 PM
  Subject: how to recordError against a form field in a loop


  <input maxlength="5" size="5" id="fmtOnTime2_0" name="fmtOnTime2_0" 
type="text">

  How do I do something this in my page class

  void onValidateFromForm() {
  ...
  loop (var X) {
  validation_rule_fail {
  timetableForm.recordError(fmtOnTime2_X, messages.get("errmsg...."));
  }
  }
  } 

  ---------------------------------------------------------------------
  To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
  For additional commands, e-mail: users-h...@tapestry.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to