我需要A4J推送组件来重复刷新textArea。 xhtml部分是: -
<a4j:push interval="500" eventProducer="#{clientBean.addListener}"
reRender="msgArea" id="push"/>
支持bean clientBean
如下: -
@ManagedBean(name="clientBean")
@SessionScoped
public class ClientBean {
public String msg="", input;
public GossipClient client=new GossipClient();
public ClientThread thd;
PushEventListener listener;
public void addListener(EventListener listener) {
synchronized (listener) {
if (this.listener != listener) {
this.listener = (PushEventListener) listener;
}
}
}
public void start() throws UnknownHostException, IOException
{
client.connect();
client.start();
thd=new ClientThread(this);
thd.start();
}
public void send(){
client.setSendMessage(input);
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public GossipClient getClient() {
return client;
}
public void setClient(GossipClient client) {
this.client = client;
}
}
但是当我转到特定页面时,我收到此错误: -
exception
javax.servlet.ServletException: /client.xhtml: Property 'addListener' not found on type com.chat.viewbeans.ClientBean
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause
javax.el.ELException: /client.xhtml: Property 'addListener' not found on type com.chat.viewbeans.ClientBean
com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)