Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

convertNumber question  RSS feed

 
Liviu Mitrofan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my project I use myfaces and tomahawk, and I have a question concerning the convertNumber tag.
In my jsf code I have this statement:
<f:convertNumber pattern="###,###,###,##0" minIntegerDigits="1" maxIntegerDigits="12" maxFractionDigits="0" />

But I want to change this behavior accordingly with a radio button. These radio buttons are meter and km. When the user selects "meter" radio button then he can insert a number without a comma. But when he selects the km radio button, he can insert a number with 3 decimals, which later will be converted in meters.

Which is the correct approach to this problem.
Any suggestion will be appreciated.
Thank you
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You MAY be able to supply the pattern as a variable:

<f:convertNumber pattern="#{backingBean.inputPattern}" minIntegerDigits="1" maxIntegerDigits="12" maxFractionDigits="0" />

But you need to check the spec on f:convertNumber. Not all attributes are allowed to be expressions, and I don't know if the patter attribute is one of them or not.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!