• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Dialog box data show in primefaces datatable when click on commandButton

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Saloon Keeper
Posts: 25482
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
I'm still in control here. LOOK at this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic