>I'm trying to format the output of some numbers. Before, the way I
>would do this was:
>
><h:outputText value="#{myBean.score}">
> <f:convertNumber maxFractionDigits="1" />
></h:outputText>
>
>I've tried this with the clay-config.xml with:
>
> <component jsfid="outputScore" extends="outputText">
> <element renderId="0" jsfid="convertNumber">
> <attributes>
> <set name="maxFractionDigits" value="1" />
> </attributes>
> </element>
> </component>
>
You have a couple options:
<component jsfid="outputScore" extends="outputText">
<converter jsfid="convertNumber">
<attributes>
<set name="maxFractionDigits" value="1" />
</attributes>
</converter>
</component>
or:
<component jsfid="outputScore" extends="outputText">
<attributes>
<set name="converter" value="javax.faces.Number" />
</attributes>
</component>
But, I missed many of the base converter's. The defaults are defined in the
/META-INF/clay-config.xml file in the clay archive.
If you find some missing from the JSF spec., please post your definition in a
bugzilla ticket and I'll add it to the base clay config (javax.faces.Number is
missing)
>But that gives me a NPE with the message "The component identified by
>jsfid convertNumber could not be found." Was the f:convertNumber
>component not mapped on purpose or is this a simple oversight?
>
>I tried creating my own mapping using:
>
> <component jsfid="numberConverter" componentType="javax.faces.Number" >
> <attributes>
> <set name="currencyCode" bindingType="Early" />
> <set name="currencySymbol" bindingType="Early" />
> <set name="maxFractionDigits" bindingType="Early" />
> <set name="minFractionDigits" bindingType="Early" />
> <set name="maxIntegerDigits" bindingType="Early" />
> <set name="minIntegerDigits" bindingType="Early" />
> <set name="pattern" bindingType="Early" />
> <set name="groupingUsed" bindingType="Early" />
> <set name="integerOnly" bindingType="Early" />
> </attributes>
> </component>
>
>But that throws an exception saying that javax.faces.Number is an
>undefined component type. Any ideas what I did wrong?
>
The converter component definition is correct and this one is missing from the
base clay config file. If you want to apply this converter to a component, you
need to nest it under the component as a "converter" node or provide the
componentType (registered name of the converter) as a converter attribute of
the target component (see example above).
>Thanks,
>Rich