Closed ren-zhijun-oracle closed 14 years ago
@javaserverfaces Commented Reported by glister
@javaserverfaces Commented @edburns said: start eval at 11:15 EDT
@javaserverfaces Commented @edburns said: I found another problem while investigating this a masked exception.
I've fixed that one and am running the automated tests to make sure the fix didn't break anything.
I also blogged about the experience at
http://www.java.net/blog/edburns/archive/2010/07/09/lean-team-agressive-schedule-software- ghetto
@javaserverfaces Commented @edburns said: The system is performing as specified.
Because the bean is request scoped, the value of the int property always starts out as 0 because that's what the JLS says ints should be if they're not assigned something else at declaration time.
The valueChangeEvent is not fired when the input value is 0 because the valueChangeEvent is only fired if the value changed.
If you add an assignment to the bean declaration, then you'll see the event being fired.
I've added an automated test to show this works, and to catch if it stops working.
Bean:
package com.sun.faces.systest.model;
import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.context.FacesContext;
/*
/* Creates a new instance of test / public Bean1729() { }
private int input1 = -1;
public int getInput1()
{ return input1; }
public void setInput1(int input1)
{ this.input1 = input1; }
public void doIt()
{ FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().getFlash().put("processActionListenerMessage", "Aufgerufen: " + System.currentTimeMillis()); }
}
Listener:
package com.sun.faces.systest;
import javax.faces.context.FacesContext; import javax.faces.event.AbortProcessingException; import javax.faces.event.ValueChangeEvent; import javax.faces.event.ValueChangeListener;
/*
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException
{ FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().getFlash().put("processValueChangeMessage", "Hello from processValueChange: " + System.currentTimeMillis()); }
}
XHTML file:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
actionListenerMessage: # {flash['processActionListenerMessage']}
valueChangeListenerMessage: # {flash['processValueChangeMessage']}
i implemented a valueChangeListener inside an inputText as a child-element.
<h:inputText id="test" value="#
{test.input1}
" >
</h:inputText>
input1 is an int Value inside a @RequestScoped Bean with set and get-Methods
private int input1;
public int getInput1()
{ return input1; }
public void setInput1(int input1)
{ this.input1 = input1; }
The ValueChangeListener is defined as:
package app;
import javax.faces.event.AbortProcessingException; import javax.faces.event.ValueChangeEvent; import javax.faces.event.ValueChangeListener;
public class listener implements ValueChangeListener {
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException
{ System.out.println("Hello from processValueChange"); }
}
Scenario
if i insert, for example a int like 1 an submit the form, the listener gets triggered correctly.
i insert a 2 and submit, the listener gets triggered.
i insert a 0 and submit, the listener should trigger too, but doesn't.
i assume, he doesn't trigger against the component tree, but against the managed bean.
Environment
Operating System: Windows XP Platform: All URL: http://pastebin.org/386722
Affected Versions
[2.0.3]