You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jesse Kuhnert (JIRA)" <de...@tapestry.apache.org> on 2007/05/20 23:13:16 UTC

[jira] Closed: (TAPESTRY-1383) number translator

     [ https://issues.apache.org/jira/browse/TAPESTRY-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesse Kuhnert closed TAPESTRY-1383.
-----------------------------------

    Resolution: Invalid
      Assignee: Jesse Kuhnert

If you want to have an exact number of characters just give your pattern something like "0.000" instead and it will do what you want.

> 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
>         Assigned To: Jesse Kuhnert
>             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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org