File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Padding for Numeric values

 
Ganesh Podaralla
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

I have defined my managed bean variables as Wrappers (Integer, Long, Double etc). I would like to left-pad zeros to the numbers to be displayed on the JSF with Facelets page. Please let me know the better ways to left-pad zeros to numeric values without changing the variables to data type String. I am using Richfaces in my project.

Thanks,
Ganesh
 
Davie Lin
Ranch Hand
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you look into



It's got a method for leftPad

Althought it use String, but you can always convert it back to the Wrapper type that you're using in the managed bean.

 
Sue Temple
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



will print 00055.

Is this what you need?
 
Ganesh Podaralla
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No..I am searching for a tag in JSF/Richfaces to pad automatically on the page. If not, I may need to use a custom converter to pad zeros. Please let me know if there is any existing tag I can use on the page (.xhtml).
 
Sue Temple
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Try to tweak this, I am guessing this will do it -

 
Ganesh Podaralla
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sue Temple..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic