527

JSF h:CommandButton don't work with f:ajax?

Question:

I am trying to submit a form with the following code but it doesn't populate the fields in the bean:

//input above <h:commandButton actionListener="#{transferenciaVagaBean.search()}" value="Search"> <f:ajax render="@form"/> </h:commandButton>

Althoug, if I change the component to:

//input above <a4j:commandButton actionListener="#{transferenciaVagaBean.search()}" value="Search" render="@form" />

It works perfect. Am I doing something wrong using h:commandButton?

I tried to change from actionListener to action since I had problems before with this, but it didn't work either way with h:commandButton.

Answer1:

By default, the f:ajax will only execute @this meaning it will only submit the action button, not any of the values of inputs in the form. Try this:

... <f:ajax execute='@form' render='@form' /> ...

See the <strong>execute</strong> section of the <a href="http://docs.oracle.com/javaee/6/javaserverfaces/2.1/docs/vdldocs/facelets/" rel="nofollow">javadoc</a>:

<blockquote>

... If a literal is specified the ids must be space delimited. Any of the keywords "@this", "@form", "@all", "@none" may be specified in the id list. If not specified, the default value of "@this" is assumed. For example, @this clientIdOne clientIdTwo.

</blockquote>

Recommend

  • Richfaces editable dataTable not setting updated values in Bean
  • error@malformedXML with ajax requests in JSF
  • Python adding lots of things to PATH. How do I stop?
  • Undefined navigator.push React-native 0.43.4
  • Google OAuth: can't get refresh token with authorization code
  • redirect_to root_url and return unless @user.activated
  • Django Haystack Rebuild Index
  • jQuery: How to AJAXify WordPress Search?
  • Possible to “watch” both HAML and SASS at the same time?
  • How to install node-mysql?
  • Selenium to click on a javascript button corresponding to a text
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • Django invalid literal for int() with base 10
  • Adjust width of select element according to selected option's width
  • MySQL Order by column = x, column asc?
  • Ensure fsync did its job
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • How to set ini file attributes during an Inno install
  • Yii2: Config params vs. const/define
  • Django rest serializer Breaks when data exists
  • Google Custom Search with transparent background
  • Python CGI os.system causing malformed header
  • Insert into database using onclick function
  • NetLogo BehaviorSpace - Measure runs using reporters
  • What is Eclipse's Declaration View used for?
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Modifying destination and filename of gulp-svg-sprite
  • WinForms: two way TextBox problem
  • Can I make an Android app that runs a web view in Chrome 39?
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • Calling of Constructors in a Java
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?