简体   繁体   English

Oracle ADF h:commandButton f:ajax无法正常工作

[英]Oracle ADF h:commandButton f:ajax not working

Trying to update a page through Ajax. 尝试通过Ajax更新页面。 Click a button and print out a counter on the page. 单击一个按钮,然后在页面上打印一个计数器。

The following code works when deployed with JSF 2.0 mojarra on a Tomcat 7. It does not work when deployed from JDeveloper 11g to the built in Weblogic server. 以下代码在Tomcat 7上与JSF 2.0 mojarra一起部署时有效,而从JDeveloper 11g部署到内置Weblogic服务器时则无效。 The count variable does get incremented, but the page is reloaded each time when using ADF. count变量确实会增加,但是每次使用ADF时都会重新加载页面。

Backing 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-page: 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>

I found the answer myself: 我自己找到了答案:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM