Kis*_*ash 1 javascript jsf primefaces
我正在使用p:remoteCommand
,它的工作正常update
,process
除了它没有调用任何action
方法也没有actionListener
Xhtml代码
<h:form id="mainForm">
<h:outputLabel id="tempAge" value="#{remoteBean.tempAge}"/>
<h:inputText id="age" value="#{remoteBean.age}" onkeypress="callRem()">
<f:validateLongRange minimum="18"/>
</h:inputText>
<script type="text/javascript">
var timex=0;
function callRem(){
clearTimeout(timex);
timex = setTimeout("remote()",2000);
}
</script>
<p:remoteCommand name="remote"
process="age"
update="tempAge"
action="#{remoteBean.act}"
actionListener="#{remoteBean.listen}">
</p:remoteCommand>
</h:form>
Run Code Online (Sandbox Code Playgroud)
托管Bean代码
@ManagedBean
public class RemoteBean {
private int age=18;
private int tempAge=20;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
System.out.println("Setting age :"+age);
}
public int getTempAge() {
return tempAge;
}
public void setTempAge(int tempAge) {
this.tempAge = tempAge;
}
public void act(){
System.out.println("in action()");
tempAge+=age+2;
}
public void listen(ActionEvent event) {
System.out.println("in Action Listener");
tempAge+=age+2;
}
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚我做错了什么,可能是我写的Javascript代码.
如果有人面对并解决了同样的问题,请帮忙.
使用:Primefaces 3.5
Dar*_*rka 10
我试过你的例子,发现问题.当你只处理age(process ="age")时,它只执行age输入并忽略remoteCommand actionListener和action.所以你可以把它改成:
process="@form"
Run Code Online (Sandbox Code Playgroud)
要么
process="@this age"
Run Code Online (Sandbox Code Playgroud)
为我工作.
PS.我在这里使用View范围.
归档时间: |
|
查看次数: |
7043 次 |
最近记录: |