Question

I have a very very simple source code:

<xp:inputText id="inputText3"
                            value="#{document1.A}" 
                            defaultValue="5.5" type="number">
                            <xp:this.converter>
                                <xp:convertNumber type="number">
                                </xp:convertNumber>
                            </xp:this.converter>
                        </xp:inputText>

If I use a European Browser (that use the comma separator for decimal number) only the first time (when load the page) I see the correct information on the field. If I refresh (partialrefresh for example) the InputBox...I see 55

With USA Browser all work correctly (where the pound is a decimal separator)

I have try play with converter without success...

Have you some suggest to fix this problem?

Tnx a lot

Was it helpful?

Solution

I have solve my problem. The really problem was HTML5 attribute type=number that force with dot my number...

SO that I have created a custom converter and now work correctly:

<xp:inputText value="#{document1.valore}" id="valore1"
                    type="number" immediate="false" defaultValue="5.5">

<xp:this.converter>
                        <xp:customConverter
                            getAsString="#{javascript:value.toString()}">
                            <xp:this.getAsObject><![CDATA[#{javascript:parseFloat(value.replace(/,/g,"\."))}]]></xp:this.getAsObject>
                        </xp:customConverter>
                    </xp:this.converter>
                </xp:inputText>

So work if you insert , or . in the inputtext

P.S. Chrome have the problem with the decimal value that don't render the value into the inputbox

OTHER TIPS

I'm not sure if this is correct, but it sounds like the server is sending 5.5 to the browser. However, during the partial refresh, the European browser identifies the "." as a thousand separator so sends the value back to the server as 55, which is then written back to the underlying datasource as 55 and passed back to the browser as 55.

You might be able to confirm that by checking the post data from the browser or adding a custom validator that just prints the submittedValue for the component. It would need to be a validator or converter, in order to run in the Process Validations phase, and so before the value is converted and written back to the field. Server-side 5.5 should be dealt with the same way regardless of the browser.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top