This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF currencySymbol

 
Mathew Lee
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to understand following code but could not understand.



<h:inputText id="sal" value="#{ManagedBean.sal}">
<f:convertNumber currencySymbol="$" type="currency"/>
</h:inputText><br>
<h:message for="sal" style="color:BLUE"/>
<hutputText value="#{ManagedBean.sal}">
<f:convertNumber currencySymbol="$" type="currency"/>
</hutputText>


Especially what currencySymbol is doing.

Please advise. Any links, ideas, suggestions, sample code, resources highly appreciated. Thanks in advance
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you understand that currency means money, right? Money amounts are basically numbers, usually preceded (or succeeded) by currency symbols. So the numeric value in the managed bean will be converted to a string in HTML that has a dollar sign in front of it. That's all. Nothing too complicated going on there.

By the way, the current best practice is to use currencyCode instead of currencySymbol.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18025
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, when you declare a converter for currency, by default it uses whatever currency symbol is in effect for the locale. An explicit "currencySymbol" attribute overrides this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic