Code eaten by Nabble :

your page :
@Persist(PersistenceConstants.FLASH)
    @Property(read=false)
    private ValidationFieldTracker myTracker;

    public ValidationFieldTracker getMyTracker() {
      if (myTracker == null) {
         myTracker = new ValidationFieldTracker(new ValidationTrackerImpl());
      }
      return myTracker;
   }

your tml :
<t:form t:id="myForm" t:clientValidation="none" t:tracker="myTracker">

        <t:errors/>

        <div t:type="ajaxformloop" t:id="themesList" source="themes" 
value="theme" encoder="encoder">
               <t:textfield t:id="label" t:clientId="prop:theme.id" 
t:value="theme.label" t:validate="required"/>
               <t:removerowlink>remove</t:removerowlink>
        </div>

        <t:submit />

</t:form>


the custom ValidationTracker :


import org.apache.tapestry5.Field;
import org.apache.tapestry5.ValidationTracker;
import org.apache.tapestry5.ValidationTrackerWrapper;

public class ValidationFieldTracker extends ValidationTrackerWrapper {

   public ValidationFieldTracker(ValidationTracker delegate) {
            super(delegate);
   }

   @Override
    public void recordError(final Field field, String errorMessage) {
                       String cn = field.getControlName();
                       // Not very elegant but it does the job - can be improved
                       if(cn.length()>12 && // is the control name expected to 
contain the _hexa suffix ?
                       cn.contains("_") && // a good candidate...
                       cn.substring(cn.lastIndexOf("_")+1).length()==11){ // we 
probably found it !
                super.recordError(new Field() {

                                     public String getClientId() {
                                             return field.getClientId();
                                     }

                                     public boolean isRequired() {
                                             return field.isRequired();
                                     }

                                     public boolean isDisabled() {
                                             return field.isDisabled();
                                     }

                                     public String getLabel() {
                                             return field.getLabel();
                                     }

                                     public String getControlName() {
                                             // All this for this : restore the 
control name as it will be rendered after submission
                                             String cn = field.getControlName();
                                             cn = cn.substring(0, 
cn.lastIndexOf("_"));
                                             return cn;
                                     }
                              }, errorMessage);
            }else{
               super.recordError(field, errorMessage);
            }
    }
}


________________________________

Ce message et les pi?ces jointes sont confidentiels et r?serv?s ? l'usage 
exclusif de ses destinataires. Il peut ?galement ?tre prot?g? par le secret 
professionnel. Si vous recevez ce message par erreur, merci d'en avertir 
imm?diatement l'exp?diteur et de le d?truire. L'int?grit? du message ne pouvant 
?tre assur?e sur Internet, la responsabilit? d'Atos ne pourra ?tre recherch?e 
quant au contenu de ce message. Bien que les meilleurs efforts soient faits 
pour maintenir cette transmission exempte de tout virus, l'exp?diteur ne donne 
aucune garantie ? cet ?gard et sa responsabilit? ne saurait ?tre recherch?e 
pour tout dommage r?sultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for 
the addressee; it may also be privileged. If you receive this e-mail in error, 
please notify the sender immediately and destroy it. As its integrity cannot be 
secured on the Internet, the Atos liability cannot be triggered for the message 
content. Although the sender endeavours to maintain a computer virus-free 
network, the sender does not warrant that this transmission is virus-free and 
will not be liable for any damages resulting from any virus transmitted.

Reply via email to