2011-11-17 93 views
2

尝试通过Ajax更新页面。点击一个按钮并在页面上打印一个计数器。Oracle ADF h:commandButton f:ajax不工作

以下代码在Tomcat 7上与JSF 2.0 mojarra一起部署时工作。从JDeveloper 11g部署到内置Weblogic服务器时,它不起作用。计数变量会增加,但每次使用ADF时都会重新加载页面。

辅助Bean:

import javax.faces.bean.*; 
import javax.faces.event.ActionEvent; 

@ManagedBean(name="countBean") 
@SessionScoped 
public class CountBean { 
    Integer count=1; 
    public void incrementCount(ActionEvent event) { 
     ++count; 
    } 
    public Integer getCount() { return count;} 
    public void setCount(Integer count) { this.count = count; }   
} 

JSF页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:f="http://java.sun.com/jsf/core"> 
<h:head><title>Ajax commandButton test</title></h:head> 
<h:body> 
<h3>Ajax count</h3> 
<h:form> 
<h:commandButton id="cb" value="Increment count" 
    actionListener="#{countBean.incrementCount}"> 
    <f:ajax event="click" execute="cb" render="ot" /> 
</h:commandButton> 
<br/><br/> 
Counter = <h:outputText id="ot" value="#{countBean.count}"/> 
</h:form> 
</h:body> 
</html> 
+0

打开页面。你是否看到两个服务器的HTML源代码存在差异?我*猜* jsf.js'丢失/破坏莫名其妙。 Firebug/Chrome会告诉你更多关于JS错误的信息。 – BalusC

回答

0

,我发现自己的答案:在浏览器中,右击和*查看源文件*

<af:commandButton text="increment count" id="cb1" actionListener="#{countBean.incrementCount}" partialSubmit="true"/> 

Counter = <af:outputText id="ot" value="#{countBean.count}" partialTriggers="cb1"/>