pe:methodparam conversion problem

Community Driven Extensions Project
Post Reply
fabatka
Posts: 2
Joined: 19 Jun 2020, 18:22

19 Jun 2020, 18:29

Hi All,

I am trying to pass a javascript variable to the backing bean through pe:remotecommand with a single String parameter.
Problem is that on the backend I receive [Object object] (what is that by the way?) instead of the actual String parameter.
What am I doing wrong?

Code snippets:

XHTML + JS:

<h:body onload="function storeWindowID() {
if (window.name === ' ') {
window.name = Math.floor(Math.random() * Math.floor(100)).toString();
}
sendWindowID([{name: 'windowId', value: window.name}]);
} storeWindowID()">
<h:form>
<pe:remoteCommand name="sendWindowID" process="@this" actionListener="#{artifactDetailsBean.setWindowId}">
<pe:methodSignature parameters="java.lang.String"/>
<pe:methodParam name="windowId" />
</pe:remoteCommand>
</h:form>

Java:

@Named
@SessionScoped
public class ArtifactDetailsBean {

private String windowId;

public String getWindowId() {
return windowId;
}

public void setWindowId(String windowId) {
this.windowId = windowId;
}


// etc.

}

Thanks upfront for any help!

Melloware
Posts: 2322
Joined: 22 Apr 2013, 15:48

20 Jun 2020, 15:01

I think your problem might be because you are doing it OnLoad. I bet the onLoad is being called before the remote command is set up?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 8.0.3 / PF Extensions 8.0.4

fabatka
Posts: 2
Joined: 19 Jun 2020, 18:22

21 Jun 2020, 11:50

Not the case - I just noticed that it works if I simply call the method like this:
sendWindowID(window.name)
(and not like sendWindowID([{name: 'windowId', value: window.name}]) which is really weird to me as it contradicts the documentation...

Melloware
Posts: 2322
Joined: 22 Apr 2013, 15:48

21 Jun 2020, 14:20

Hmm the documentation example here: https://www.primefaces.org/showcase-ext ... dParam.jsf

Just shows it calling...

Code: Select all

onclick="applyData('hello user', '7/11/01 11:55:42 PM', JSON.stringify(circle2))"
Which is normal Javscript calling it with 3 params? So I would expect your "sendWindowID(window.name)" is correct just passing it one param.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 8.0.3 / PF Extensions 8.0.4

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests