• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Storing in database with a AJAX form

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I made a form with the AJAX function.
Something like this:

<h:commandButton id="register" value="SEND">
<f:ajax execute="firstName lastName" render="output"/>
</h:commandButton>

I set the entity file, the facade file with the persistence unit and the J.S.F. Managed Bean with
a injection of the facade .

I can send the form resulting in the AJAX efect, nothing is wrong here; but the data of the form is no stored in the database
generated by the entity.

Am I missing something in the command button where the AJAX function is nested?

Thanks
 
Saloon Keeper
Posts: 27762
196
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
JSF has absolutely no database capabilities at all, so that means that you have to supply your own code to do the storing.

Beyond that, something has to invoke that code.

When you provide a SUBMIT button, whether traditional or AJAX it has to be attached to that code. For traditional submits, that would be an action method or (not recommended) action listener. For an AJAX button, you'd attach an AJAX listener method.
 
Mikel Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

I have sorted at the moment wit the action attribute in the commandButton that references to a method

in the managed bean whose body holds the facade object and the create method and return a new response page.

I think I need to become clearer about the navigation in J.S.F.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
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
An AJAX request will not navigate. It is used for updating the current page.

A traditional JSF action method will navigate. It returns a rule name that is used to select which page to display next. If it returns null, the same page is re-displayed. In JSF2, explicit rule names are optional. If the returned value is not an explicitly-defined rule name, JSF will attempt to make a URL out of it and navigate to the page that corresponds to that URL. Being JSF, the URL in the browser location control will lag behind, but that doesn't matter for the purposes of navigation. A "redirect" option can be used in cases where you want to update the browser control, although there is a performance penalty involved.
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic