-
1. Re: Display Integer as currency?
ppitonak Apr 11, 2011 11:43 AM (in response to ginni)Hi,
in my opinion, f:convertNumber is exactly what you need.
<h:outputLabel for="currency" value="currency" /> <h:inputText id="currency" value="#{minBean.value}" label="currency"> <f:convertNumber type="currency" currencySymbol="€" locale="sk" /> </h:inputText>
My code above renders as follows:
Palo
-
2. Display Integer as currency?
ginni Apr 11, 2011 11:55 AM (in response to ppitonak)What is the datatype of your minBean.value? Mine is Integer. I tried exactly what you have there (with Symbol $) and it is not converted. the Integer 1000 shows just as that, 1000, not $1,000.
-
3. Display Integer as currency?
ppitonak Apr 11, 2011 12:05 PM (in response to ginni)I tried it with java.lang.Integer, too.
-
4. Re: Display Integer as currency?
ginni Apr 12, 2011 11:28 AM (in response to ppitonak)My object has the attribute as Integer:
private integer amount;
with the standard getter and setter.
Then in the UI, I have the code I originally posted in my JSF. We are using Seam 2.2.1 with RichFaces 3.3. The amount fields appear in a table as you see below, but they are not formatted like currency, even though the convertNumber tag is there. The fields appear in a rich:dataTable. The column code is like so:
<h:inputText
value="#{record.amount}"
rendered="#{record.amountType and (authorizationUpdatable or !authorizationExists)}"
validator=
"numericInputValidator"
validatorMessage=
"The #{record.authorizationForm.formTitle} field must be a number"
styleClass="tableCellInput"
style="width: 98%"
>
<f:convertNumber type="currency" integerOnly="true"/>
<
a4j:support
event="onchange"
ajaxSingle="true"
reRender="authorizationToolBar, authorizationControlBar"/>
</h:inputText
>
<h:outputText
value="#{record.amount}"
rendered="#{!record.amountType or (!authorizationUpdatable and authorizationExists)}"
styleClass="tableCellInput"
style="width: 98%"
>
<f:convertNumber type="currency"/>
</h:outputText>
But the page renders without formatting.
-
amount.gif 1.8 KB
-