This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes select a row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "select a row" Watch "select a row" New topic
Author

select a row

Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Hi,

I need to select a row from the datatable and get the unique id from the table(unique id is in one of the column) and do actions . Please could anyone tell me a solution? I have been trying it since last 2 days. Please help me. I am using t:datatable and t:selectoneRadio to selectthe row.

Thank you very much,
Joe.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hey joe,

this will definately help....
http://balusc.xs4all.nl/srv/dev-jep-dat.html

you can as a matter of fact get a handle to every unique row of a datatable , when you select a checkbox or radio in that particular row.
go through the link above .
Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Originally posted by Sachin Sthalekar:
hey joe,

this will definately help....
http://balusc.xs4all.nl/srv/dev-jep-dat.html

you can as a matter of fact get a handle to every unique row of a datatable , when you select a checkbox or radio in that particular row.
go through the link above .


Thanks Sachin. Let me try and get back to you. One more doubt, can I use radio inside command link ? Will that work to get an id/value ?

Thanks,
Joe.
Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Hi Sachin,

I have tried what you said. But didn't work out. Command link action is not working.Here is my code :



bean :



Please help me.

Thanks,
Joe.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
If you really want to use selectOneRadio in a datatable to select the row, then do :

JSF:

JavaScript:

MyBean:
Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Hi Bauke,

Thanks for the reply.

I tried your code. But the onchange javascript is not working i think, it doesn't call the valueChangeListener as well.
my code is as follows :

jsp:


bean:



Can you please tell me where do I exactly give the valuechangelistener ?
It doesn't work for me.

Thanks,
Joe.
Joe Jose
Ranch Hand

Joined: Jan 14, 2004
Posts: 125
Hi Bauke,

I am getting the valuChangeListener when I put the bean in session scope. But I have some other problems when I put the bean in session. Can I do it request scope ? Or if put the bean in session , how can I clear it ?

Thanks for the help Bauke.

Joe.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It works in request scope in here. Try upgrading your JSF version.
yusuf Kaplan
Ranch Hand

Joined: Mar 11, 2011
Posts: 58
Im using JSF 2.x
and copy and pasted Baukes solutions. But still there is a Javascript error when I click "get selected row".
Any ideas?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

You're expecting a 2006 solution to still apply 6 years later?

Bauke hasn't been heard from for about 3 years now.


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

Joined: Mar 11, 2011
Posts: 58
Tim Holloway wrote:You're expecting a 2006 solution to still apply 6 years later?

Bauke hasn't been heard from for about 3 years now.


Maybe someone else then Bauke can answer my question...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Actually, what I really meant was http://www.coderanch.com/how-to/java/DontWakeTheZombies

We don't charge extra if you start your own thread!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: select a row
 
Similar Threads
oracle sequence id
oracle sequence id and table data insertion
JSF multiple check box and single array list in backing bean
Difference between rowid and rownum in sql query??
problem for update and delete row in table using jsp