File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Problem in valueChangeListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem in valueChangeListener" Watch "Problem in valueChangeListener" New topic
Author

Problem in valueChangeListener

liliane fahmy
Greenhorn

Joined: Aug 24, 2012
Posts: 22
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

Joined: Sep 13, 2007
Posts: 2416
    
    7

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
liliane fahmy
Greenhorn

Joined: Aug 24, 2012
Posts: 22
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

Joined: Jun 25, 2001
Posts: 16065
    
  21

"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.


Customer surveys are for companies who didn't pay proper attention to begin with.
liliane fahmy
Greenhorn

Joined: Aug 24, 2012
Posts: 22
Thanks a lot Sir
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in valueChangeListener