Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[riena-dev] DateTextRidget discussion

Hi everybody,

I've finished the Riena DateTextRidget. The API leaves a implementation
points open, which I would like to discuss:

1. ridget.setText(newText) - My implementation accepts all 'partial'
matches of the pattern and throws a RuntimeException otherwise.

      /*
	 *  A partial match is any string that has digits
	 *  and separators in the expected places - as defined by the
	 *  format pattern - regardless of limits for a certain group
	 *  (i.e. month <= 12 etc.). For example, assuming the format
	 *  pattern is 'dd.MM.yyyy', all of the following values are
	 *  valid: "", "12", "12.10", "47.11", "12.10.20", "12.10.2008",
	 *  "  .  .    ", "  .10". Invalid values would be: null, "abc",
	 *  "12.ab", "12122008", "12/12/2008"
	 */

2. ridget.updateFromModel() - similar to 1 - partial matches are
accepted; otherwise the value is ignored (no Exception thrown, ridget
and control are left as is). 

(1+2 match the behavior of NumericTextRidget / DecimalTextRidget)

3. What is the desired behavior after changing the format pattern? It's
hard to generalize, sometimes the new pattern is a modification of the
old one, sometimes is something enterely different. The patterns can
also vary a lot. 

Example #1:

ridget.setFormat("dd.MM.yyyy"); 
ridget.setText("12.12.2008"); 
ridget.setFormat("HH:mm");
ridget.getText() ?

Example #2:

ridget.setFormat("dd.MM.yyyy"); 
ridget.setText("24.10.2008"); 
ridget.setFormat("MM.dd");
ridget.getText() ?

My implementation will clear the value in the ridget and the control
once the pattern is changed. The model is left as is. In most cases I
expect that the pattern would be set before calling r.setText() /
r.updateFromModel();


Your comments are appreciated.

Kind regards,
Elias.



Back to the top