Search code examples
decimalxpagesseparator

xpages decimal separator EditBox


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


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