1

We're trying to pass an object through primefaces-extensions remoteCommand like this:

function dispatchOurObject(ourObject) {
                sendMessageToServer(ourObject);
}

This is our remoteCommand tag:

        <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>

And last but not least, this is our method in the backing bean:

public void dispatchOurObject(OurObject ourObject) {
    //Do some stuff.

}

This is the Error we're getting :

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2

EDIT: at com.google.gson.Gson.fromJson(Gson.java:803)

Lewis
  • 225
  • 1
  • 6
  • 18
  • How does `ourObject` look like? Does it have javascript properties corresponding to java object? In PrimeFaces Extensions examples they are converted to Json format by `JSON.stringify`. Do you have such conversion? – Geinmachi Nov 29 '15 at 12:58
  • When we debug the javascript code we can see the right content into ourObject, so it's corresponding to our Java Object. – Lewis Nov 29 '15 at 13:04
  • Exception says it expects BEGIN_OBJECT at line 1 so there should be `{` but there is BEGIN_ARRAY which is`[`. Can you post sent json? – Geinmachi Nov 29 '15 at 13:36
  • Additionally check out [this](http://stackoverflow.com/questions/9598707/gson-throwing-expected-begin-object-but-was-begin-array). – Geinmachi Nov 29 '15 at 13:44
  • @Geinmachi I can't get the JSON because it's done by this : – Lewis Nov 29 '15 at 14:19
  • So it formats your object to an array (maybe to an array with one element) instead of an object. You cannot see it in web console (F12) during POST request? – Geinmachi Nov 29 '15 at 14:24

0 Answers0