3

We are trying to pass an object of our own as a parameter to Primefaces' remotecommand.

We used the following example from: 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))" />

Yet the server is trying to invoke the method without parameters. So instead of printParams(String, Date, Circle), it tries to invoke printParams(). Resulting in a method not found exception.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Lewis
  • 225
  • 1
  • 6
  • 18

0 Answers0