Is it possible to return a value using RemoteCommand?

-2

I would like to know if just like it is possible to pass parameters to a function of a "remoteCommand" if it is possible to receive the return? Like the example:

Xhtml: <p:remoteCommand name="myRemoteCommand" actionListener="#{testBean.testRemote }" />

JavaSctript: myRemoteCommand([{name:"id", 1}]);

Bean:

public void testRemote()
    {
        String[] id = JSFUtil.getRequestParameterMap().get("id");
        System.out.println(id);     
    }

I need my "testRemote" function to return a value, and I capture this value after the call, as an example:

JavaSctript: alert(myRemoteCommand([{name:"id", 1}]));

Bean:

public String testRemote()
    {
        String[] id = JSFUtil.getRequestParameterMap().get("id");
        System.out.println(id);     
        return “Test Success”;
    }
    
asked by anonymous 08.10.2015 / 15:07

1 answer

0

Well you can do the following:

public String testRemote()
{
    String[] id = JSFUtil.getRequestParameterMap().get("id");
    System.out.println(id); 
    RequestContext.getCurrentInstance().execute("alert(myRemoteCommand([{name:'id', 1}]));");
    return “Test Success”;
}

Within execute you can have JavaScript executed . I believe that remoteCommand has no return event.

    
08.10.2015 / 16:45