2 Replies Latest reply on May 13, 2010 12:44 AM by raphaufrj

    global convertNumber

      Hello, I know how to use:

      <f:convertNumber pattern="##.00"></f:convertNumber>

      But I don't want to put this into every input/output text of my pages.

      Is there any way to use a global pattern for every output/input text??


        • 1. Re: global convertNumber

          Of course, there are several ways that you could do this.

          First thing that comes to mind is to stick that pattern into a properties file and reference it via EL, such as #{messages['pattern.number']}, assuming that was the name of the property key.

          Or, you could make a managed bean to store these kinds of application-level/runtime values, such as a class called ConverterHelper that you declare in faces-config.

          • 2. Re: global convertNumber
            There is another way for it if you're using faceletes. You can create one component easily.

            1. Declare a taglib in xml file


            2. In numeric.xhtml

                    <h:inputText id="#{id}" value="#{value}" disabled="#{disabled}" style="#{styleComponent}">
            <f:convertNumber pattern="##.00"></f:convertNumber>

            3. In your real xhtml
            <teste:numeric id="test" />
            Do not forget to declare xmlns:teste="http://teste.com.br/jsf" in the top of page...