You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org> on 2005/08/09 23:39:36 UTC

[jira] Closed: (TAPESTRY-351) Add isRequired() to IFieldComponent

     [ http://issues.apache.org/jira/browse/TAPESTRY-351?page=all ]
     
Howard M. Lewis Ship closed TAPESTRY-351:
-----------------------------------------

    Fix Version: 4.0
     Resolution: Fixed

> Add isRequired() to IFieldComponent
> -----------------------------------
>
>          Key: TAPESTRY-351
>          URL: http://issues.apache.org/jira/browse/TAPESTRY-351
>      Project: Tapestry
>         Type: Improvement
>     Versions: 4.0
>     Reporter: Howard M. Lewis Ship
>     Assignee: Howard M. Lewis Ship
>      Fix For: 4.0

>
> With the phasing out of ValidField and IValidator, and the addition of RequireableField and ValidateableField, it's gotten pretty complicated to determine if a field is required or not. This is important for validation delegates that decorate required fields. The following can approximately figure it out, but is not 100% perfect (but is 100% ugly):
> private boolean isFieldRequired(IFormComponent field, IValidator validator) {
>     // Only a ValidField will have a validator
>     if (validator != null) return validator.isRequired();
>     // PropertySelection and folks are RequireableFields,
>     // which is straight forward
>     if (field instanceof RequirableField) {
>       RequirableField rf = (RequirableField) field;
>       return rf.isRequired();
>     }
>     // This needs work: it's too hard to figure out if a field is required
>     // or not. The Validator API should be extended to support this easily.
>     if (field instanceof ValidatableField) {
>       ValidatableField vf = (ValidatableField) field;
>       List<Validator> validators = (List<Validator>) vf.getValidators();
>       if (validators != null) {
>         for (Validator v : validators)
>           if (v instanceof Required) return true;
>       }
>     }
>     return false;
>   }
> There should be an easier way!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org