Forums Register Login

Dialog box data show in primefaces datatable when click on commandButton

+Pie Number of slices to send: Send
I am new in this site. Thank you for support. When i click on 'Add Invoice' button open a dialog box. input data in dialog box. After click on 'Save Invoice' all the data of dialog box is render in primfaces datatable. After that click on 'Save Invoices' all data of primefaces datatable and HTML table data are store in ipsDetail and Invoice object of Managed Bean class.

XHTML file :

Managed Bean :

InvoiceDao Class:


Here, Problem is ipsDetail elements NULL when click on 'Save Invoice' button in addRow() so that primefaces datatable not updated. So that i can not insert new invoice data in database table.
+Pie Number of slices to send: Send
Welcome to the JavaRanch, Hadu!

It's always a good idea when publishing sample code to reduce to the minimum amount of text you can rather than simply dumping the whole thing into the message.

You're dealing with people who don't get paid for their advice, and when your sample doesn't fit on the screen, a lot of people aren't going to spend the effort to bother reading through the whole thing.

I didn't, but I've seen problems like this enough that I'll give my standard answer and we'll see if it helps.

First, understand that unlike traditional GUIs, such as Swing, displaying a Dialog Box in JSF doesn't cause any server interaction (unless you explicitly request it via AJAX). That is because the Dialog Box - and its field contents - are rendered when the page is initially displayed, but kept hidden. The "show()" dialog method therefore doesn't construct or populate the dialog, just makes what's already in the web page visible.

Typically, I'll have an "onshow()" method defined for the dialog that issues an AJAX request. This request will inform the server to locate a record to be edited (or construct a new, blank one), and populate its fields in the dialog controls (via AJAX partial page update).

This is done before the dialog actually becomes visible, so the dialog show in ready-to-edit form.

If the user later clicks the dialog's "Save" button, another AJAX request is made. This one submits the dialog's control values (the dialog is almost always defined in an h:form). The normal JSF lifecycle is run (data validation, valuechangelisteners fired as needed, backing bean values update) and the AJAX listener (action) method is then invoked. This action method can then post the user's input data out the the database.

In real life, this is a little more complex, since if the action fails for some reason (for example, adding a duplicate record), then feedback mechanisms are required to tell the client not to hide the form, but to display an error message and allow correction of form data. Or whatever failure actions you think appropriate.
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 16728 times.
Similar Threads
problem with hibernate
Primefaces: How to insert an object attributes on a PanelGrid?
p:selectOneMenu is not working
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:46:58.