[
https://issues.apache.org/jira/browse/TAPESTRY-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484101
]
Arthur Tam commented on TAPESTRY-1383:
--------------------------------------
f.y.i.
I changed NumberTranslator to accept one more param: mask (a regular
expression) s.t. parseText() only parse the input when it conforms to a mask
(if provided)
Use the mask: \d*\.?\d?\d? supplement the pattern #.##, it will fail the input
0.123
> number translator
> -----------------
>
> Key: TAPESTRY-1383
> URL: https://issues.apache.org/jira/browse/TAPESTRY-1383
> Project: Tapestry
> Issue Type: Bug
> Components: Framework
> Affects Versions: 4.0, 4.1.1
> Environment: windows 2k professional, tomcat 4.1.24, j2sdk 1.4.2_13,
> eclipse 3.2.1
> Reporter: Arthur Tam
> Fix For: 4.1.2
>
>
> - define html with an input field (going to capture a number with pattern
> #.##)
> - define translator: <binding name="translator"
> value="translator:number,pattern=#.##" />
> - define validators: <binding name="validators"
> value="validators:min=-1.23,max=20.12" />
> - code onSubmit listener for the form:
> public String onSubmit (IRequestCycle cycle) {
> ValidationDelegate delegate = (ValidationDelegate) ((IForm)
> getComponent("stockQuoteForm")).getDelegate();
> System.out.println("***");
> System.out.println(getStockPrice());
> if (delegate.getHasErrors()) {
> List ut = delegate.getAssociatedTrackings();
> if (ut != null && ut.size() > 0) {
> System.out.println("***");
> System.out.println(((IFieldTracking)
> ut.get(0)).getErrorRenderer().toString());
> }
> return null;
> }
> System.out.println("should not reach here if enter " +
> getStockPrice());
> return null;
> }
> }
> Test and result:
> - enter 0.123 to the input field and submit the form
> - console output messages:
> ***
> 0.123
> should not reach here if enter 0.123
> - As the input not conform to the pattern, it should fail the input. If it
> pass the input, it should trim the number for me i.e. return 0.12 when
> calling getStockPrice(), it is found that the screen just refresh with 0.12
> silently but internally, it is accepted the input.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]