Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

f:convertNumber not working in dataTable context

 
Will Wijgergangs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to use a f:convertnumber in a datatable, for some kind of reason it never seems do anything with the convertNumber in the datatable.
Below a piece of the datatable and the associated java program.
The preceding outputtext (employee.number) works fine, but the inputtext in the dataTable isn't working.
Has anybody an idea what the reason is ??
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Will!

We have a "Code" tag that can be used to preserve the formatting of your code when you post it. You can insert it by clicking the "Code" button that's in the row of buttons above the message editing area.

convertNumber does work on both input and output in datatables. Could you tell us what you mean when you say it "doesn't work"?
 
Will Wijgergangs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim for your tip of the code tag, I changed my post immediately.

The problem is when I uses a convertNumber not in a datatable it works fine.

In the mentioned example the number is formatted as 123.456 based on the pattern '###.###'.

But when I try to use it in a datatable it simply seems to ignore the convertNumber.
The monthSalaries are presented in the way they are returned from the program (500050, 200000 and 150000) and not as 5000.50 2000.00 and 1500.00 which I expected from the pattern.
The pattern is not the problem (I uses the most crazy patterns) but it looks like the convertNumber isn't recognized, I uses inputText and ouputText tags both the same problem.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not a formatting issue, the decimals are in the wrong place!

Is the property being referenced a number, or is it a String? The get-method should be returning a float or double.
 
Will Wijgergangs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried it with returning a float and a double but I don't think this is the problem.
In my understanding the purpose of a pattern is to make up a String with a kind of format.

And it is working on the employee.number !!!
I can make up this String with any pattern I like.

Today I will try to do some extra testing and will try it once again with returning a float or double.
Tim again thanks for your help
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will Wijgergangs wrote:I've tried it with returning a float and a double but I don't think this is the problem.
In my understanding the purpose of a pattern is to make up a String with a kind of format.


Not in this case. That's why it's called convertNumber. This particular converter isn't a generic String reformatter.
 
Will Wijgergangs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works great thanks Tim !!

The bold word Number in your last post triggered me.
I did test with a float or double however I used the primitives which of course won't work.
So implementing a Float as returning type gives the desired result.

Once again thanks for your help !!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic