This content has been marked as final.
Show 2 replies
-
1. Re: h:outputFormat and f:param with complex value
sreemanth May 29, 2011 7:16 AM (in response to laurentg)hi tried to solve this problem,
approach 1
-----------------
aNumericValueFormatted is a new getter method which will return the formatted value.
<h:outputFormat value="#{messages['my.message']}"> <f:param value="#{myBean.stringValue]}" /> <f:param value="#{myBean.aNumericValueFormatted}"> </f:param> </h:outputFormat>
approach 2(This has some issue)
----------------
can you try the following snippet
<h:outputText value="1234.123466666666666" binding="#{requestScope.simple}" rendered="false"> <f:convertNumber maxFractionDigits="6" ></f:convertNumber> </h:outputText> <h:outputFormat value="A test message {0} {1}"> <f:param value="Simple zero"></f:param> <f:param value="#{requestScope.simple.value}"> </f:param> </h:outputFormat>
-
2. Re: h:outputFormat and f:param with complex value
laurentg Sep 5, 2011 11:29 AM (in response to sreemanth)Thank you for your suggestions.
Of course, approach 1 works but I don't like it since I have to modify my model and introduce presentation concerns in Java code.
Approach 2 doesn't work : the value stores in the binding property is of type "javax.faces.component.html.HtmlOutputText".
Finally, I added a new method in a bean :
public String formatNumber(double number, String format) {
final DecimalFormat decimalFormat = new DecimalFormat(format);
return decimalFormat.format(number);
}