Forums Register Login

To update a dataTable from backing bean using p:commandbutton

+Pie Number of slices to send: Send
Hi all,

How can I update a datatable from the backing bean? I'm using JSF 2.0 and Primefaces 2.2.1.
I'm doing this by JSF custom component. So I've to bind the datatable from the encode method. And in run time I should update the table after entering few details in the other fields.
I tried populating through p:commandbutton(setUpdate) from back end. But it says I can't create a p:commandbutton without a form though I've a form in my xhtml page.
+Pie Number of slices to send: Send
JSF is a framework built on the Model/View/Controller paradigm. In JSF, the View is the webpage, the Model is the backing bean and the Controllers are the FacesServlet and tag processors.

Controllers are the glue. When the Model changes, the Controller updates the View. When the View is changed (form controls input and submitted), the Controller updates the Model.

JSF does more than just this - it also invokes the business logic (action processors) and does validations, conversions, and so forth, but the heart of it all is MVC. For flexibility's sake, the rendering code in the Controller is segregated from the rest of the Controller, so that alternative rendering systems can be plugged in with minimal impact on the rest of the application.

A dataTable is both the View side (tag) and the Model side (tableModel), so when you say "update a dataTable", it's not clear which side you're talking about.

Using the stock components, if you click a commandButton on a form containing a dataTable, any input controls on that form (including ones in the dataTable) will be validated, and if found valid, changed values will be posted to the backing bean (Model). In the case of items in a DataTable, that means that the corresponding cells in its DataModel will be updated. Once the Model has been updated, the action processor will be invoked. It can do whatever it wants, including updating the Model objects. On completion of the action method, JSF's rendering phase kicks in and it will construct a new View. If that View contains references to updated Model values, the newly-rendered View will reflect these changes.

Of course, if you're coding a custom JSF tag at the binary level, you should already know that intimately. Otherwise, you're basically Walking Dead, since that's only the beginning of what you need to know. Creating new tags at the binary level is something that I actively discourage. They're going to be horribly expensive to create, debug, and maintain, and considering what a mess that whole part of the system is right now, I think there's a very good chance that JSF3 will replace the current internal architecture with something completely different, which means that any such code will probably break and break hard.
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 6107 times.
Similar Threads
Dynamically generate Panel grid elements
JSTL and bean data
how to acces backingBean from popup
Composite Components with ViewScoped bean
Trouble updating primefaces component w/ajax
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:38:42.