Search code examples
javajsfvaluechangelistener

ValueChangeEvent not firing when values are returned


In my jsf page I have a inputtext field and a hidden field. I have an edit button and upon clicking the edit button a popup screen appears and I selects a value and selected value returns back to my hidden field.

I added a valueChangeListener to my hidden field and added the following code in my bean.

public void processChange(ValueChangeEvent event){        
    try  {           
        logger.info("event new value "+event.getNewValue().toString());

    } catch (Exception ex)  {                        
    } 

However every time when I change value using the edit popup window and returns value back to my hidden field, valueChangeListener is not firing I guess.

Any idea why valueChangeListener is not firing? My page scope is session and using JSF 1.1.

Idea behind this approach is to re-query and based on values from popup, I would like refresh data in JSF page.


Solution

  • You should not catch at first the most superclass Exception and especially without logging anything. Maybe your object from event.getNewValue() is null, then you get a NullPointerException and you don't will be noticed about that.

    Use something like that:

    public void processChange(ValueChangeEvent event){        
    try  {           
        logger.info("event new value "+event.getNewValue().toString());
    
    } catch (NullPointerException ex)  { 
         logger.error("object is null: "+ex.getMessage());              
    } catch (Exception ex)  { 
         logger.error(ex);              
    } 
    

    http://download.oracle.com/javase/tutorial/essential/exceptions/index.html