我们正在尝试将我们自己的对象作为参数传递给 Primefaces 的远程命令。
我们使用了以下示例:http: //www.primefaces.org/showcase-ext/sections/remoteCommand/methodParam.jsf
<p:growl id="growl" showDetail="true" />
<pe:remoteCommand id="applyDataCommand" name="applyData" process="@this" update="growl" actionListener="#{remoteCommandController.printMethodParams}">
<pe:methodSignature parameters="java.lang.String, java.util.Date, org.primefaces.extensions.showcase.model.Circle" />
<pe:methodParam name="subject"/>
<pe:methodParam name="date">
<f:convertDateTime type="both" dateStyle="short" locale="en"/>
</pe:methodParam>
<pe:methodParam name="circle">
<pe:convertJson />
</pe:methodParam>
</pe:remoteCommand>
<script type="text/javascript">
circle = {
radius: 50,
backgroundColor: "#FF0000",
borderColor: "#DDDDDD",
scaleFactor: 1.2
};
circle2 = {
radius: 32,
backgroundColor: "#FF0320",
borderColor: "#DDFFFD",
scaleFactor: 1.6
};
</script>
<p:commandButton value="Apply Data" type="button" onclick="applyData('hello world', '5/14/07 12:55:42 PM', JSON.stringify(circle))" />
<p:commandButton value="Apply Second Data" type="button" onclick="applyData('hello user', '7/11/01 11:55:42 PM', JSON.stringify(circle2))" />
然而,服务器试图在没有参数的情况下调用该方法。因此,它尝试调用 printParams(),而不是 printParams(String, Date, Circle)。导致方法未找到异常。