[ http://mc4j.org/jira/browse/STS-337?page=comments#action_10602 ] 
            
Ben Gunter commented on STS-337:
--------------------------------

It took me forever to nail down the circumstances that cause this. This happens 
when a JSP displays a text field with the percentage format, submits the value 
to an ActionBean and that ActionBean redirects back to the same JSP, flashing 
itself. The problem is that formatting a value as a percentage requires 
multiplying it by 100. When the value is submitted back into the bean, it is 
the multiplied value that gets submitted. Then when that value is formatted, it 
is multiplied by 100 again.

In order for Stripes to handle this automatically, it would have to know that 
the value being submitted was formatted as a percentage when it was rendered. I 
don't think that's really plausible. If I'm wrong about that, somebody let me 
know.

This can be handled in the app by providing a setter method that handles the 
division, like so:

public double getValue() { return value; }
public void setValue(double value) { this.value = value; }

public double getValuePct() { return value; }
public void setValuePct(double value) { setValue(value / 100) ; }

Not pretty, but it works.

> Text field with formatType="percentage"  multiplies its value on each reload
> ----------------------------------------------------------------------------
>
>                 Key: STS-337
>                 URL: http://mc4j.org/jira/browse/STS-337
>             Project: Stripes
>          Issue Type: Bug
>          Components: Formatting
>    Affects Versions: Release 1.4.2
>            Reporter: Werner Kolov
>         Assigned To: Tim Fennell
>            Priority: Minor
>
> Example from bugzooky:
> <td><stripes:text name="bug.percentComplete" formatType="percentage"/></td>
> In this case a value 0.30 is displayed as "30%" and committed as 30.0 - so on 
> the next reload you get "3000%" and so on. 
> By the way: I've found this example in the example source code, but not in 
> the running application deployed from the provided WAR file.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to