You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Andrey Rybin (JIRA)" <ji...@apache.org> on 2010/01/17 14:13:54 UTC

[jira] Created: (CLK-612) Better user experience with DateField (and CalendarField).

Better user experience with DateField (and CalendarField).
----------------------------------------------------------

                 Key: CLK-612
                 URL: https://issues.apache.org/jira/browse/CLK-612
             Project: Click
          Issue Type: Improvement
    Affects Versions: 2.1.0, 2.1.0 RC1
            Reporter: Andrey Rybin


Current DateField.validate() is too strict. 

My suggestion is:

Add String property   similarDelimiters:

its format:   [oldChar1][newChar1] [oldChar2][newChar2]....

if odd then ignore last char.

And add this to validate() method (not tested):

  dateFormat.setLenient(false);

  String v = getValue().trim();
  if (similarDelimiters != null && similarDelimiters.length > 0) {
    for (int i=0; i<similarDelimiters.length-1; i+=2) {
      v = v.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
   }//f
  }//i

   try {
   dateFormat.parse(v).getTime();
  } catch (ParseException pe) {


Because many people around me use /,-,.(dot) as date delimiters, not only / for example.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CLK-612) Better user experience with DateField (and CalendarField).

Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12804115#action_12804115 ] 

Andrey Rybin commented on CLK-612:
----------------------------------

My final request is:

Please add 

//DateField.java

private Boolean lenientValidation = false; 


public Boolean isLenientValidation () {return lenientValidation;}

/**
* null - don't parse date. Only parent's validate (min,max len and required). Can be useful for soft filters: 2008 ~ since 2008, 2009.02 till feb 2009.
* true - date will be parsed with lenient = true (less strict).
* false - strict date validation
*/

public void setLenientValidation (Boolean value) { lenientValidation = value;}
 
//@Override public void validate() { 

super.validate();

        if (isValid() && getValue().length() > 0 && lenientValidation != null) {
            SimpleDateFormat dateFormat = getDateFormat();
            dateFormat.setLenient(lenientValidation.booleanValue());
 



> Better user experience with DateField (and CalendarField).
> ----------------------------------------------------------
>
>                 Key: CLK-612
>                 URL: https://issues.apache.org/jira/browse/CLK-612
>             Project: Click
>          Issue Type: Improvement
>    Affects Versions: 2.1.0, 2.1.0 RC1
>            Reporter: Andrey Rybin
>
> Current DateField.validate() is too strict. 
> My suggestion is:
> Add two properties: 
> 1) String prop similarDelimiters:
> its format:   [oldChar1][newChar1] [oldChar2][newChar2].... if odd then ignore last char.
> 2) boolean prop  lenientValidation //def false
> 3) Modify  setValue (not tested):
>     public void setValue(String value) {
>         if (value != null && value.length() > 0) {
>            value = value.trim();
>      if (similarDelimiters != null && similarDelimiters.length > 0) {
>        for (int i=0; i<similarDelimiters.length-1; i+=2) {
>          value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
>       }//f
>      }//i
>             try {
>                 Date parsedDate = getDateFormat().parse(value);
>                 // Cache date for subsequent retrievals
>                 date = new Date(parsedDate.getTime());
>             } catch (ParseException pe) {
>                 date = null;
>             }
>         } else {
>             date = null;
>         }
>         super.setValue(value);
>     }//setValue
> Because people in Russia use different characters  (ex:  /,-, .(dot)) as date delimiters, not one.
> So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.
> 4) Modify validate()
> dateFormat.setLenient(lenientValidation); 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CLK-612) Better user experience with DateField (and CalendarField).

Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrey Rybin updated CLK-612:
-----------------------------

    Description: 
Current DateField.validate() is too strict. 

My suggestion is:

Add String property   similarDelimiters:

its format:   [oldChar1][newChar1] [oldChar2][newChar2]....

if odd then ignore last char.


Modify setValue (not tested):

    public void setValue(String value) {
        if (value != null && value.length() > 0) {
           value = value.trim();

     if (similarDelimiters != null && similarDelimiters.length > 0) {
       for (int i=0; i<similarDelimiters.length-1; i+=2) {
         value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
      }//f
     }//i

            try {
                Date parsedDate = getDateFormat().parse(value);

                // Cache date for subsequent retrievals
                date = new Date(parsedDate.getTime());

            } catch (ParseException pe) {
                date = null;
            }

        } else {
            date = null;
        }
        super.setValue(value);
    }//setValue

Because many people around me use /,-,.(dot) as date delimiters, not only / for example.

So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.

  was:
Current DateField.validate() is too strict. 

My suggestion is:

Add String property   similarDelimiters:

its format:   [oldChar1][newChar1] [oldChar2][newChar2]....

if odd then ignore last char.

And add this to validate() method (not tested):

  dateFormat.setLenient(false);

  String v = getValue().trim();
  if (similarDelimiters != null && similarDelimiters.length > 0) {
    for (int i=0; i<similarDelimiters.length-1; i+=2) {
      v = v.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
   }//f
  }//i

   try {
   dateFormat.parse(v).getTime();
  } catch (ParseException pe) {


Because many people around me use /,-,.(dot) as date delimiters, not only / for example.



> Better user experience with DateField (and CalendarField).
> ----------------------------------------------------------
>
>                 Key: CLK-612
>                 URL: https://issues.apache.org/jira/browse/CLK-612
>             Project: Click
>          Issue Type: Improvement
>    Affects Versions: 2.1.0, 2.1.0 RC1
>            Reporter: Andrey Rybin
>
> Current DateField.validate() is too strict. 
> My suggestion is:
> Add String property   similarDelimiters:
> its format:   [oldChar1][newChar1] [oldChar2][newChar2]....
> if odd then ignore last char.
> Modify setValue (not tested):
>     public void setValue(String value) {
>         if (value != null && value.length() > 0) {
>            value = value.trim();
>      if (similarDelimiters != null && similarDelimiters.length > 0) {
>        for (int i=0; i<similarDelimiters.length-1; i+=2) {
>          value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
>       }//f
>      }//i
>             try {
>                 Date parsedDate = getDateFormat().parse(value);
>                 // Cache date for subsequent retrievals
>                 date = new Date(parsedDate.getTime());
>             } catch (ParseException pe) {
>                 date = null;
>             }
>         } else {
>             date = null;
>         }
>         super.setValue(value);
>     }//setValue
> Because many people around me use /,-,.(dot) as date delimiters, not only / for example.
> So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CLK-612) Better user experience with DateField (and CalendarField).

Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12804117#action_12804117 ] 

Andrey Rybin commented on CLK-612:
----------------------------------

Also similarDelimiters property is very friendly. I use it extensively 


private String similarDelimiters; 

public String getSimilarDelimiters () { return similarDelimiters; }


/** [oldChar1][newChar1] [oldChar2][newChar2] */
public void setSimilarDelimiters (String value) { similarDelimiters = value; } 


@Override public void setValue (String value) {
        if (value != null && value.length() > 0) {
          value = value.trim();

          if (similarDelimiters != null && similarDelimiters.length() > 0) {
            for (int i = 0, m = similarDelimiters.length() - 1; i < m; i += 2) {
              value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i + 1));
            }//f
          }//i

          try {
                Date parsedDate = getDateFormat().parse(value);

                // Cache date for subsequent retrievals
                date = new Date(parsedDate.getTime());

            } catch (ParseException pe) {
                date = null;
            }

        } else {
            date = null;
        }

        super.setValue(value);
    }//setValue 

> Better user experience with DateField (and CalendarField).
> ----------------------------------------------------------
>
>                 Key: CLK-612
>                 URL: https://issues.apache.org/jira/browse/CLK-612
>             Project: Click
>          Issue Type: Improvement
>    Affects Versions: 2.1.0, 2.1.0 RC1
>            Reporter: Andrey Rybin
>
> Current DateField.validate() is too strict. 
> My suggestion is:
> Add two properties: 
> 1) String prop similarDelimiters:
> its format:   [oldChar1][newChar1] [oldChar2][newChar2].... if odd then ignore last char.
> 2) boolean prop  lenientValidation //def false
> 3) Modify  setValue (not tested):
>     public void setValue(String value) {
>         if (value != null && value.length() > 0) {
>            value = value.trim();
>      if (similarDelimiters != null && similarDelimiters.length > 0) {
>        for (int i=0; i<similarDelimiters.length-1; i+=2) {
>          value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
>       }//f
>      }//i
>             try {
>                 Date parsedDate = getDateFormat().parse(value);
>                 // Cache date for subsequent retrievals
>                 date = new Date(parsedDate.getTime());
>             } catch (ParseException pe) {
>                 date = null;
>             }
>         } else {
>             date = null;
>         }
>         super.setValue(value);
>     }//setValue
> Because people in Russia use different characters  (ex:  /,-, .(dot)) as date delimiters, not one.
> So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.
> 4) Modify validate()
> dateFormat.setLenient(lenientValidation); 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CLK-612) Better user experience with DateField (and CalendarField).

Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrey Rybin updated CLK-612:
-----------------------------

    Description: 
Current DateField.validate() is too strict. 

My suggestion is:

Add two properties: 
1) String prop similarDelimiters:

its format:   [oldChar1][newChar1] [oldChar2][newChar2].... if odd then ignore last char.


2) boolean prop  lenientValidation //def false


3) Modify  setValue (not tested):

    public void setValue(String value) {
        if (value != null && value.length() > 0) {
           value = value.trim();

     if (similarDelimiters != null && similarDelimiters.length > 0) {
       for (int i=0; i<similarDelimiters.length-1; i+=2) {
         value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
      }//f
     }//i

            try {
                Date parsedDate = getDateFormat().parse(value);

                // Cache date for subsequent retrievals
                date = new Date(parsedDate.getTime());

            } catch (ParseException pe) {
                date = null;
            }

        } else {
            date = null;
        }
        super.setValue(value);
    }//setValue

Because people in Russia use different characters  (ex:  /,-, .(dot)) as date delimiters, not one.

So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.


4) Modify validate()
dateFormat.setLenient(lenientValidation); 

  was:
Current DateField.validate() is too strict. 

My suggestion is:

Add String property   similarDelimiters:

its format:   [oldChar1][newChar1] [oldChar2][newChar2]....

if odd then ignore last char.


Modify setValue (not tested):

    public void setValue(String value) {
        if (value != null && value.length() > 0) {
           value = value.trim();

     if (similarDelimiters != null && similarDelimiters.length > 0) {
       for (int i=0; i<similarDelimiters.length-1; i+=2) {
         value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
      }//f
     }//i

            try {
                Date parsedDate = getDateFormat().parse(value);

                // Cache date for subsequent retrievals
                date = new Date(parsedDate.getTime());

            } catch (ParseException pe) {
                date = null;
            }

        } else {
            date = null;
        }
        super.setValue(value);
    }//setValue

Because many people around me use /,-,.(dot) as date delimiters, not only / for example.

So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.


+ lenientValidation 
lenient should have possibility to tune it too

> Better user experience with DateField (and CalendarField).
> ----------------------------------------------------------
>
>                 Key: CLK-612
>                 URL: https://issues.apache.org/jira/browse/CLK-612
>             Project: Click
>          Issue Type: Improvement
>    Affects Versions: 2.1.0, 2.1.0 RC1
>            Reporter: Andrey Rybin
>
> Current DateField.validate() is too strict. 
> My suggestion is:
> Add two properties: 
> 1) String prop similarDelimiters:
> its format:   [oldChar1][newChar1] [oldChar2][newChar2].... if odd then ignore last char.
> 2) boolean prop  lenientValidation //def false
> 3) Modify  setValue (not tested):
>     public void setValue(String value) {
>         if (value != null && value.length() > 0) {
>            value = value.trim();
>      if (similarDelimiters != null && similarDelimiters.length > 0) {
>        for (int i=0; i<similarDelimiters.length-1; i+=2) {
>          value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
>       }//f
>      }//i
>             try {
>                 Date parsedDate = getDateFormat().parse(value);
>                 // Cache date for subsequent retrievals
>                 date = new Date(parsedDate.getTime());
>             } catch (ParseException pe) {
>                 date = null;
>             }
>         } else {
>             date = null;
>         }
>         super.setValue(value);
>     }//setValue
> Because people in Russia use different characters  (ex:  /,-, .(dot)) as date delimiters, not one.
> So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.
> 4) Modify validate()
> dateFormat.setLenient(lenientValidation); 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CLK-612) Better user experience with DateField (and CalendarField).

Posted by "Malcolm Edgar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801753#action_12801753 ] 

Malcolm Edgar commented on CLK-612:
-----------------------------------

I think having a lenientValidation property is excellent, as we can introduce this new behaviour without effecting the existing behaviour. I am assuming by default lenientValidation would be false.

regards Malcolm Edgar

> Better user experience with DateField (and CalendarField).
> ----------------------------------------------------------
>
>                 Key: CLK-612
>                 URL: https://issues.apache.org/jira/browse/CLK-612
>             Project: Click
>          Issue Type: Improvement
>    Affects Versions: 2.1.0, 2.1.0 RC1
>            Reporter: Andrey Rybin
>
> Current DateField.validate() is too strict. 
> My suggestion is:
> Add two properties: 
> 1) String prop similarDelimiters:
> its format:   [oldChar1][newChar1] [oldChar2][newChar2].... if odd then ignore last char.
> 2) boolean prop  lenientValidation //def false
> 3) Modify  setValue (not tested):
>     public void setValue(String value) {
>         if (value != null && value.length() > 0) {
>            value = value.trim();
>      if (similarDelimiters != null && similarDelimiters.length > 0) {
>        for (int i=0; i<similarDelimiters.length-1; i+=2) {
>          value = value.replace(similarDelimiters.charAt(i), similarDelimiters.charAt(i+1));
>       }//f
>      }//i
>             try {
>                 Date parsedDate = getDateFormat().parse(value);
>                 // Cache date for subsequent retrievals
>                 date = new Date(parsedDate.getTime());
>             } catch (ParseException pe) {
>                 date = null;
>             }
>         } else {
>             date = null;
>         }
>         super.setValue(value);
>     }//setValue
> Because people in Russia use different characters  (ex:  /,-, .(dot)) as date delimiters, not one.
> So I will set similarDelimiters to "-/\\/./" and pattern to dd/MM/yyyy - and it will work.
> 4) Modify validate()
> dateFormat.setLenient(lenientValidation); 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.