将自己的Object作为参数传递给RemoteCommand

时间:2015-11-29 00:54:48

标签: jsf primefaces-extensions remotecommand

我们正在尝试将我们自己的对象作为参数传递给Primefaces的remotecommand。

我们使用了以下示例: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)。导致找不到异常的方法。

0 个答案:

没有答案