This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in valueChangeListener

 
liliane fahmy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem in valueChangeListener:

I want to change the local ,as when the user change the value of combo box from English to French ,the page reload by the new local.

The problem is:the valueChangeListener didn't fired unless the form get submitted which I don't want anymore.

So:what I can do to fired the event immediately when change the value of combo box.

The code of page is the following:



Is something wrong in my code?
Please help me
 
K. Tsang
Bartender
Posts: 3401
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Normally for valueChangeListener, the onchange="this.form.submit()" is needed. Since you don't the form to submit, try to the f:ajax tag to do the same thing. Remember to use the proper execute and render attributes.

 
liliane fahmy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help,

it 's working well now but please I want to understand the functionality of onchange attribute need more explanation.

Thanks and best regards.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"onchange" does exactly the same thing in JSF as it does for HTML. When focus leaves the control with the onchange attribute and the control's value has changed, then the javascript code that the onchange attribute defines will be executed.

AJAX does not avoid an HTTP submit, it merely constrains the data that is sent and received and keeps the same page (document) in the client. So the actual operation of valueChangeListener remains the same, whether it's a full-form submit or a partial submit.

Web browser windows are not the same thing as stand-alone desktop application windows, nor are HTTP protocols as interactive as general-purpose client-server protocols. This is by design, since the traditional client-server protocols did not have to endure the longer delays that occur over the Internet or the fact that the Internet can route requests through unpredictable channels.

What that means specifically, is that a "valueChangeListener" is NOT something that fires on the client when a value changes. It is something that gets invoked on the server when data is submitted to the server and the data coming in doesn't match what JSF saw going out when the page was previously rendered. Furthermore, the JSF lifecycle rules state that if ANY of the incoming submitted data value is invalid, the incoming request will be short-circuited: the listeners will not be invoked, the data will not be updated and the action method/listener or AJAX listener will not be invoked. JSF will only process a request when all incoming data is valid.
 
liliane fahmy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Sir
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic