All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.maven-faces-plugin.converters.trinidad.Number.xml Maven / Gradle / Ivy

There is a newer version: 2.2.1
Show newest version
<?xml version="1.0" ?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
     
-->
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:tr="http://myfaces.apache.org/trinidad"
              xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin"
              xmlns:fmd="http://java.sun.com/xml/ns/javaee/faces/design-time-metadata">
  <converter>
    <description><![CDATA[Converts an string to a Number and vice versa based on the 'pattern' or the 'type' set.]]>
    </description>
    <display-name>Number Converter</display-name>
    <converter-id>org.apache.myfaces.trinidad.Number</converter-id>
    <converter-class>org.apache.myfaces.trinidadinternal.convert.NumberConverter</converter-class>
    <property>
      <description><![CDATA[Whether the converter should be disabled, default to false.]]>
      </description>
      <property-name>disabled</property-name>
      <property-class>boolean</property-class>
      <default-value>false</default-value>
    </property>
    <property>
      <description><![CDATA[The ISO 4217 currency code, applied only when formatting currencies.
           Currency code can also be set for the entire application in trinidad-config.xml file.
           If currency code is not set on the converter, and if set on
           trinidad-config.xml configuration file it will be used by calling
           <code>RequestContext().getCurrenctInstance().getCurrencyCode().</code>
           This currency code will be used during call to getAsString() for formatting,
           provided type is set to 'currency'.]]>
      </description>
      <property-name>currencyCode</property-name>
      <property-class>java.lang.String</property-class>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <property>
      <description><![CDATA[<html><p>
          Custom error message to be used, for creating detail part of the
          <code>FacesMessage</code>, when
          <code>value</code> cannot be converted to a number, when
          <code>type</code> is set to
          <code>'currency'</code> and <code>pattern</code>
          is null or not set.
         </p>
          <p>
           <strong>
            Parameters:
           </strong>
           <ul>
            <li>
             {0} the label that identifies the component
            </li>
            <li>
             {1} value entered by the user
            </li>
           </ul>
          </p></html>]]>
      </description>
      <property-name>messageDetailConvertCurrency</property-name>
      <property-class>java.lang.String</property-class>
      <property-extension>
        <mfp:property-metadata>
          <mfp:translatable>true</mfp:translatable>
        </mfp:property-metadata>
      </property-extension>
    </property>
    <property>
      <description><![CDATA[<html><p>
          Custom error message to be used, for creating detail part of the
          <code>FacesMessage</code>, when
          <code>value</code> cannot be converted to a number, when
          <code>type</code> is set to <code>'number'</code>
          and <code>pattern</code> is null or not set.
         </p>
         <p>
          <strong>
           Parameters:
          </strong>
          <ul>
           <li>
            {0} the label that identifies the component
           </li>
           <li>
            {1} value entered by the user
           </li>
          </ul>
         </p></html>]]>
      </description>
      <property-name>messageDetailConvertNumber</property-name>
      <property-class>java.lang.String</property-class>
      <property-extension>
        <mfp:property-metadata>
          <mfp:translatable>true</mfp:translatable>
        </mfp:property-metadata>
      </property-extension>
    </property>
    <property>
      <description><![CDATA[<html><p>
          Custom error message to be used, for creating detail part of the
          <code>FacesMessage</code> message, when
          <code>value</code> cannot be converted to a number, based
          on the <code>pattern</code> set.
         </p>
         <p>
          <strong>
           Parameters:
          </strong>
          <ul>
           <li>
            {0} the label that identifies the component
           </li>
           <li>
            {1} value entered by the user
           </li>
           <li>
            {2} the specified conversion pattern
           </li>
          </ul>
         </p></html>]]>
      </description>
      <property-name>messageDetailConvertPattern</property-name>
      <property-class>java.lang.String</property-class>
      <property-extension>
        <mfp:property-metadata>
          <mfp:translatable>true</mfp:translatable>
        </mfp:property-metadata>
      </property-extension>
    </property>
    <property>
      <description><![CDATA[<html><p>
          Custom error message to be used, for creating detail part of the
          <code>FacesMessage</code>, when
          <code>value</code> cannot be converted to a number, when
          <code>type</code> is set to
          <code>'percent'</code> and <code>pattern</code>
          is null or not set.
         </p>
         <p>
          <strong>
           Parameters:
          </strong>
          <ul>
           <li>
            {0} the label that identifies the component
           </li>
           <li>
            {1} value entered by the user
           </li>
          </ul>
         </p></html>]]>
      </description>
      <property-name>messageDetailConvertPercent</property-name>
      <property-class>java.lang.String</property-class>
      <property-extension>
        <mfp:property-metadata>
          <mfp:translatable>true</mfp:translatable>
        </mfp:property-metadata>
      </property-extension>
    </property>
    <property>
      <description><![CDATA[Currency symbol, is applied only when formatting currencies.
          If currency code is set then symbol will be ignored.]]>
      </description>
      <property-name>currencySymbol</property-name>
      <property-class>java.lang.String</property-class>
    </property>
    <property>
      <description><![CDATA[Flag specifying whether formatted output will contain grouping separators.
          Default value is true.]]>
      </description>
      <property-name>groupingUsed</property-name>
      <property-class>boolean</property-class>
      <default-value>true</default-value>
    </property>
    <property>
      <description><![CDATA[Flag specifying whether only the integer part of the value will be formatted
           and parsed. Default value is false.]]>
      </description>
      <property-name>integerOnly</property-name>
      <property-class>boolean</property-class>
      <default-value>false</default-value>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <property>
      <description><![CDATA[Locale whose predefined styles for numbers are used during formatting and parsing.
          If not specified, the Locale returned by FacesContext.getViewRoot().getLocale()
          will be used.]]>
      </description>
      <property-name>locale</property-name>
      <property-class>java.util.Locale</property-class>
    </property>
    <property>
      <description><![CDATA[Maximum number of digits that will be formatted in the fractional portion of the
          output.]]>
      </description>
      <property-name>maxFractionDigits</property-name>
      <property-class>int</property-class>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <property>
      <description><![CDATA[Maximum number of digits that will be formatted in the integer portion of the
          output.]]>
      </description>
      <property-name>maxIntegerDigits</property-name>
      <property-class>int</property-class>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <property>
      <description><![CDATA[Minimum number of digits that will be formatted in the fractional portion of
           the output.]]>
      </description>
      <property-name>minFractionDigits</property-name>
      <property-class>int</property-class>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <property>
      <description><![CDATA[Minimum number of digits that will be formatted in the integer portion of the
          output.]]>
      </description>
      <property-name>minIntegerDigits</property-name>
      <property-class>int</property-class>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>            
    </property>
    <property>
      <description><![CDATA[Specifies the negative prefix, to be applied only when formatting negative numbers. 
        Negative prefix specified through this attribute will override any negative prefix implied using the pattern attribute]]>
      </description>
      <property-name>negativePrefix</property-name>
      <property-class>java.lang.String</property-class>
    </property>
    <property>
      <description><![CDATA[Specifies the negative suffix, to be applied only when formatting negative numbers.
        Negative suffix specified through this attribute will override any negative suffix implied using the pattern attribute]]>
      </description>
      <property-name>negativeSuffix</property-name>
      <property-class>java.lang.String</property-class>
    </property>
    <property>
      <description><![CDATA[Custom formatting pattern which determins how the number string should be
          formatted and parsed.]]>
      </description>
      <property-name>pattern</property-name>
      <property-class>java.lang.String</property-class>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <property>    
      <description><![CDATA[Sets the default RoundingMode for the converter. If unset, uses JDK default (usually RoundingMode.HALF_EVEN).]]>
      </description>
      <property-name>roundingMode</property-name>
      <property-class>java.math.RoundingMode</property-class>
      <mfp:enum>true</mfp:enum>
      <fmd:enum>true</fmd:enum>
    </property>
    <property>
      <description><![CDATA[Specifies how the number string will be formatted and parsed.
           Valid values are "number", "currency", and "percent".
           Default value is "number".]]>
      </description>
      <property-name>type</property-name>
      <property-class>java.lang.String</property-class>
      <default-value>number</default-value>
      <property-extension>
        <mfp:property-metadata/>
        <fmd:property-metadata>
          <fmd:preferred>true</fmd:preferred>
        </fmd:property-metadata>
      </property-extension>                  
    </property>
    <converter-extension>
      <mfp:tag-name>tr:convertNumber</mfp:tag-name>
      <mfp:tag-class>org.apache.myfaces.trinidadinternal.taglib.convert.ConvertNumberTag</mfp:tag-class>
      <mfp:long-description><![CDATA[<html:p>This is an extension of the standard JSF javax.faces.convert.NumberConverter
          The converter provides all the standard functionality of the default NumberConverter
          and is strict while converting to object.</html:p>

          <html:p>JSF javax.faces.convert.NumberConverter will convert values like
          22.22.2 or 22ABC to valid Number 22.22 and 22 respectively. Here it would
          result in a conversion failure and would throw a ConverterException.</html:p>

          <html:p>If <html:code>number grouping separator, decimal separator</html:code>
          is configured in <html:code>trinidad-config.xml</html:code> file,
          it will be used during call to <html:code>getAsObject()</html:code> and
          <html:code>getAsString()</html:code> for parsing and formatting. If it has not been set,
          <html:code>number grouping separator, decimal separator</html:code> is
          defaulted based on the locale.</html:p>

          <html:p>If <html:code>currencyCode</html:code> is set on the converter then it will be used.
          Else uses the <html:code>currencyCode</html:code> set in <html:code>trinidad-config.xml</html:code>
          file. If it is not set in the configuration file then it is defaulted based on the locale.</html:p>


         <html:p>Since Apache MyFaces Trinidad is compatible with JDK 1.4 and higher versions,
         the <html:code>currencyCode</html:code> gets preference over <html:code>currencySymbol.</html:code>
         See JSF's javax.faces.convert.NumberConverter for the way in which
         <html:code>currencyCode</html:code> and <html:code>currencySymbol</html:code> gets preference for
         different version of JDK.</html:p>


         <html:p>This converter is automatically registered under the standard
         converter ID, and therefore will be used when the
         <html:code>&lt;f:convertNumber&gt;</html:code> tag is used.</html:p>

         <html:p>Further more information see javadoc for
         <html:code>org.apache.myfaces.trinidad.converter.NumberConverter</html:code></html:p>]]>
      </mfp:long-description>
      <mfp:example>
        <mfp:source-code><![CDATA[<tr:inputText id="mdf5" value="0.75"
                        label="Score">
  <tr:convertNumber type='percent' locale="en-US" />
</tr:inputText>]]>
        </mfp:source-code>
      </mfp:example>
      <mfp:author>Vijay Venkataraman</mfp:author>
      <mfp:converter-metadata>
        <mfp:favorite-property>type</mfp:favorite-property>
      </mfp:converter-metadata>
    </converter-extension>
  </converter>
</faces-config>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy