wood burning stoves 2.0*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "binding in a datatable" Watch "binding in a datatable" New topic
Author

binding in a datatable

Men rai
Greenhorn

Joined: May 31, 2011
Posts: 11
Hi,
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:column>
#{preg.idpreg}
<h:panelGroup binding="#{Pregbacking.dynamicDataTableGroup(preg.idpreg)}"/>
</h:column>
</h:dataTable>

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

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: binding in a datatable
 
Similar Threads
Doubt in JSF
Design problem with dynamically added row in datatable
One-To-Many Child Objects Not Rendering
Change CSS from ControllBean
Finding which cell was clicked in a DataTable?