Erythrozyt
Erythrozyt

Reputation: 804

p:remoteCommand not executing / not called

I'm facing the following problem:

The Primefaces remoteCommand is not executing, does it depend on the lifecycle of my portlet?

 <h:form id="controllayer">
 .
 .
 .
 <p:remoteCommand name="updatePageId" actionListener="#{formView.updatePageId}" />
 </h:form>
 <script>   
    var pageID;

    Liferay.on('eventFire', function(event)
     {
      console.log("Recieved");
      console.log(event.name);
      pageID = event.name;
      update();
     });

    function update() {

      console.log("Recieved PageID: " + pageID);
      updatePageId({newPageId: pageID});
    }

 </script>

I also tried it without a parameter but even this isn't working.

@SessionScoped
@ManagedBean(name="formView")
public class MainViewBean implements PagesUploadCallback, PageUploadCallback, PageActionCallback, Serializable
{
 .
 .
 .
 public void updatePageId()
 {
  LOG.info("Update Page ID");
  String pageIdString = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("newPageId");
  long pageId = Long.valueOf(pageIdString);
  LOG.debug("Setting Page: " + pageId);
  pageService.setActivePage(pageId);
 }
.
.
.
}

My JavaCode is never called.

Upvotes: 3

Views: 4519

Answers (1)

kishore kingmaker
kishore kingmaker

Reputation: 476

<p:remoteCommand name="docheck" 
         process="@form,box1,box2"
         update="box1,box2"
         action="#{testBean.myAction()}" />

this is an example how u need to change your code so. This will fix your issue. For Further reference refer the link below:

https://forum.primefaces.org/viewtopic.php?p=61733&sid=bf526834599e119a2d8a4e0f9a6989fb#p61733

Upvotes: 2

Related Questions