wood burning stoves 2.0*
The moose likes JSF and the fly likes Issue with passing expression to a hashmap key in a dataTable column    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Issue with passing expression to a hashmap key in a dataTable column    " Watch "Issue with passing expression to a hashmap key in a dataTable column    " New topic
Author

Issue with passing expression to a hashmap key in a dataTable column

vishnu bola
Ranch Hand

Joined: Jun 01, 2009
Posts: 32
hi all,

Can someone help me with passing an expression like "123-456" to a hashmap key in my dataTable where 123 is userID and 456 is accountID. In my dataTable i have t:columns tag which generates checkboxes for each row in the dynamic column .The value of checkbox must be identified by a combination of userID and accountID. So i want to set value of checkbox something like this'userID-account.ID' .

But it never returns the right value since userID is taken as string instead i want the value of userID to be passed in that expression. Someone please help...iam struck with this issue from so long.Here is the code.

page1.jsp


Backing bean:
In this selectedUserIds iam intentionally setting up key something like "userID-accountID" so that i can split the userID and accountID for later user





somebody please to my email. If you need further information iam very happy to provide any time. Also let me know if there is another way to get this job done..

Thanks very much in advance
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Hi vishnu,
I'm having the exact same problem, and am stuck into it, probably if you can please assist me with the way
you solved your problem, or any way you managed achieving that.
Hope some one else, might have an answer also.
Thanks..


Qussay NAJJAR
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Try something more like:



Actually, I don't really recommend coding up that much complexity in EL because you end up spending a lot of time on puzzles like this and you risk putting what should be Model logic into the View and violating MVC. But when you quoted your variable names, you turned them into a string literal, as you saw. What you really want is a string concatenation with 2 variables joined to a literal.


Customer surveys are for companies who didn't pay proper attention to begin with.
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
thanks Tim for the reply, but that wouldn't work, it's throwing NumberFormatException '-' !!??
any idea why ?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Qussay Najjar wrote:thanks Tim for the reply, but that wouldn't work, it's throwing NumberFormatException '-' !!??
any idea why ?


Probably because I got my languages crossed and "+" doesn't work as an EL concatenation operator there. I'd have to RTFM to be able to say for sure.
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Any new ideas, i'm still stuck with it
i have to use this logic, couldn't find a replacment
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Unfortunately, I'm in the middle of something complicated, so the only suggestions I can give are to either move the computations off the page and into a backing bean or to read up on the EL documentation. My recommendation is to try and get the computations off-page, as it's usually easier.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Issue with passing expression to a hashmap key in a dataTable column
 
Similar Threads
Passing hidden Input to backing bean
Problem with column sort in myFaces dataTable
How to add a button to the first row of a dataTable
strachable columns in jsf
setting up hashmap key in t:SelectBooleanCheckbox in a dataTable