It's not a secret anymore!
The moose likes JSF and the fly likes binding in a datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "binding in a datatable" Watch "binding in a datatable" New topic

binding in a datatable

Men rai

Joined: May 31, 2011
Posts: 11
I have a datatable that reads registers from a database.
Into the datatable I have a panelgroup that is populated by binding
My problem is that I can not pass a parameter. I want to pass a value from the datatable var, in that case preg, on each row I want to know the value of the register read to populate the panelgroup.
If I display the value it works fine for each row: #{preg.idpreg}

<h:dataTable var="preg" value="#{Pregbacking.list(Pregbacking.idenq)}">
<h:panelGroup binding="#{Pregbacking.dynamicDataTableGroup(preg.idpreg)}"/>

Does anybody know how can I solve this ??
Thanks in advance.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

You're attempting to put logic in your View. That's bad MVC. MVC should display what's in the Model, not attempt to program the Model. Aside from everything else, why use a Separation of Concerns pattern if you're not actually going to keep the Concerns separated?

It's a popular misconception that the Model on a dataTable should always be the original persistent Domain Model. But that's limiting yourself. In cases like this, it's better to make the model be a fa├žade or decorator for the actual domain model objects. That way you can do the necessary logic when you build the Model and the View merely needs to display the Model with no logic required in the View.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: binding in a datatable
jQuery in Action, 3rd edition