• 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

immediate=true for value change events

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was working on the following: jsf for auto-filling
[A zipcode field is filled by user, the state and city fields are auto-filled(Taking example from JSF 2.0 Complete Reference book)]
In the form, there are four input text fields(name,zipcode,city,state), a submit button and a hidden commandButton(id=autofill).This hidden button is clicked on
value change of zipcode field using javascript onchange="document.getElementById('autofill').click();"
Here,
-the zipcode,city and state fields have immediate="true" (so that they are validated)
- added f:validateLength to the zipcode field
Following are my doubts:
1.Correct me if I'm wrong.
The sole purpose of immediate=true for value change events is to avoid validation errors and needs to be used with a hidden commandButton with
immediate=true.
2. Always if immediate=true for any input field,there will be a hidden commandButton whose immediate=true.Hence it will never go through the Process Validations phase.It will go through Restore View,Apply Request Values and Then Render Response phase.If so who does the validations that are attached to fields with immediate=true.
3.Now the zipcode is validated as I run the application.But, when I attach MyPhaseListener class to this,it is not printing processValidations phase at all.Is it because the hidden commandButton immediate=true.If so, who does the validations if immediate="true" for hidden commandButton?
 
An Me
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF zipcode field Autofilling is not working if I'm not setting prependId=false in the <h: form> tag..Any reason??
 
Saloon Keeper
Posts: 27763
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
Totally wrong, I'm afraid.

As I explained elsewhere, what the "immediate="true"" attribute does is fire the action without submitting any of the form data.

One of the most common uses of "immediate" is on Cancel buttons where the validity of the form data is not required, since you won't be processing any of the form data anyway.

It is a fundamental architectural stricture of JSF that NO invalid data will EVER be presented to a backing bean(s) unless EACH and EVERY control on the submitted form has a valid value. If even one of them fails validation, the submit request will short-circuit, the bean will not be updated and the action method (and/or action listeners ) will not fire.

If you are looking to do something like automatically supply a ZIP code when a certain city/state are entered, that requires AJAX and partial form submission (which can only be done using AJAX).
 
reply
    Bookmark Topic Watch Topic
  • New Topic