wood burning stoves 2.0*
The moose likes JSF and the fly likes how to retrieve a particular value from datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how to retrieve a particular value from datatable" Watch "how to retrieve a particular value from datatable" New topic
Author

how to retrieve a particular value from datatable

Aparna Ram
Ranch Hand

Joined: Jan 27, 2006
Posts: 59
Hi,

I have a datatable, in which I display 4 columns. I am able to retrieve the value of these 4 columns and store them where I want to.

Now, I need to store the value of a 5th column in a hidden input field. This 5th column should not be displayed in the datatable.
I tried but there is no option to hide a column in a datatable. How do I retrieve the 5th column from the bean, not display it in the datatable and store it in a hidden input field.


Please help on the same. Many thanks.
Rohit Kumar
Ranch Hand

Joined: Jul 19, 2007
Posts: 35
Hi,

If you don't declare 5th column in <hutputtext>, it wont display right.

sorry..i didn't understand the question what you are trying to do.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Why do you want a hidden 5th column?


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Aparna Ram
Ranch Hand

Joined: Jan 27, 2006
Posts: 59
Ok, there are only 4 columns in the datatable that are displayed. This datatable is populated from a bean. The bean holds 5 values.

I want to store this fifth value in a hidden input field. How do I access this fifth column's value.
Aparna Ram
Ranch Hand

Joined: Jan 27, 2006
Posts: 59
Well, I need to display this bean value, that is not displayed in the datatable. If I was able to have a hidden column in the datatable, then I would just be able to access this value and things would go fine.

How do I go about doing the same?
Aparna Ram
Ranch Hand

Joined: Jan 27, 2006
Posts: 59
Ok, is there a way I can display the value of a "rendered = false" column in a h:datatable ?

Please guide.
Jimmy Ho
Ranch Hand

Joined: Jul 31, 2007
Posts: 61
Since JSF is a server-side sort of framework, perhaps you can just store the data in a JSF-managed bean, in session scope. Then when the form submits, you can just get the value directly.

This may be unacceptable since your session size may get large. My only other recommendation is to play around with some DHTML and manually hide it. Or, just add it as a hidden input text field in one of the other columns.

Using rendered="false" attribute probably won't work because then the HTMl doesn't get rendered at all, which means the data won't be there. That is, if you do a View Source on the rendered HTML, it won't be there, so when the form submits, you won't see that data.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
I still don't know what for information your 5th column is holding, but you could in your backing bean just remove the last object which is seen by the table and put it as an another reference in your backing bean.
Aparna Ram
Ranch Hand

Joined: Jan 27, 2006
Posts: 59
I am sorry.. I have not mentioned the question properly..
I would like to display the value of the 5th column(not displayed in datatable) which corresponds to the row that I have selected(clicked on).

The code in my first post shows the row selection.
Aparna Ram
Ranch Hand

Joined: Jan 27, 2006
Posts: 59
Sorry.. this code shows row selection.

Gabriel Claramunt
Ranch Hand

Joined: May 26, 2007
Posts: 375

From the code I understand you want to use JavaScript
Mixing JSF and JavaScript is difficult (but not impossible).
You can use rendered="false" inside the cell, but then it will not be rendered at all, and you won't be able to get the value with JavaScript.
Have you tried setting the column width to 0% or 0px or 1px ?
Maybe that will do the trick...


Gabriel
Software Surgeon
Ronald Aguilar
Greenhorn

Joined: Sep 14, 2004
Posts: 21
you can use <f:param name="idAcct" value="#{data.idAcct}" />


Ron
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to retrieve a particular value from datatable