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/06/21 17:30:21 UTC

[jira] Created: (TAPESTRY-351) Too hard for validation delegate to determine if a field is required

Too hard for validation delegate to determine if a field is required
--------------------------------------------------------------------

         Key: TAPESTRY-351
         URL: http://issues.apache.org/jira/browse/TAPESTRY-351
     Project: Tapestry
        Type: Improvement
    Versions: 4.0    
    Reporter: Howard M. Lewis Ship


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


[jira] Assigned: (TAPESTRY-351) Too hard for validation delegate to determine if a field is required

Posted by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-351?page=all ]

Howard M. Lewis Ship reassigned TAPESTRY-351:
---------------------------------------------

    Assign To: Howard M. Lewis Ship

> Too hard for validation delegate to determine if a field is required
> --------------------------------------------------------------------
>
>          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

>
> 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


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

Posted by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-351?page=all ]

Howard M. Lewis Ship updated TAPESTRY-351:
------------------------------------------

        Summary: Add isRequired() to IFieldComponent  (was: Too hard for validation delegate to determine if a field is required)
    Description: 
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!

  was:
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!


Paul F. is working on remove RequireableField (those will become ValidatableFields).  The logic I'm adding to AbstractValidatableField will delegate to the ValidatableFieldSupport which, in turn, asks each valiator if it is required.

> 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

>
> 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


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

Posted by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org>.
     [ 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