如何解决Primefaces remoteCommand停止设置someValue-为什么?
我已经完成了这项工作,但我必须进行了一些更改,但看不到什么更改可能导致这种情况。我将代码简化为重要的内容。我是否想让它正常工作?我希望可以通过p:remoteCommand调用来设置someValue(就像在我弄乱东西之前一样)。 预先感谢!
我的豆子:
@Scope("session")
@Component("myBean")
public class MyBean {
private String someValue;
// these used to be called (but not any more - not ever!)
public int getSomeValue() { return someValue; }
public void setSomeValue(String value) { someValue=value; }
public void myMethod() {
// at this point,I'm expecting someValue to have the value set by the
assert(someValue.length() > 0); // fails
}
}
.xhtml页面:
<?xml version="1.0" encoding="UTF-8"?>
<!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"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<h:head>
<h:outputScript library="js" name="my.js" target="head" />
</h:head>
<h:body>
<h:form id="myForm">
<p:inputTextarea id="someText" value="#{myBean.someValue}" widgetVar="someText" readonly="true" />
<p:commandButton value="callJsFunction" onclick="callJsFunction();" type="submit">
<p:remoteCommand name="callRemoteCommand" action="#{myBean.myMethod}" />
</h:form>
</h:body>
</html>
javascript文件:
// my.js:
function callJsFunction() {
PF('someText').jq.val("This string is placed in the inputTextarea,but doesn't get pushed to the server when callRemoteCommand() is called next"));
callRemoteCommand();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。