我们试图通过 primefaces-extensions remoteCommand 传递一个对象,如下所示:
function dispatchOurObject(ourObject) {
sendMessageToServer(ourObject);
}
这是我们的 remoteCommand 标签:
<pe:remoteCommand name="sendMessageToServer" process="@this"
actionListener="#{ourController.dispatchOurObject}">
<pe:methodSignature
parameters="com.package.OurObject" />
<pe:methodParam name="ourObject">
<pe:convertJson />
</pe:methodParam>
</pe:remoteCommand>
最后但同样重要的是,这是我们在 backing bean 中的方法:
public void dispatchOurObject(OurObject ourObject) {
//Do some stuff.
}
这是我们得到的错误:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
编辑:at com.google.gson.Gson.fromJson(Gson.java:803)