user1516364
user1516364

Reputation: 1

oncomplete and update of remoteCommand in PrimeFaces not working

I am passing parameters from Javascript functions to ManagedBeans using hidden values and primeface's remoteCommand.In managed bean, I am making some webservice call. I need to update primeface datatable after the webservice call is made using update attribute and in oncomplete I am calling JS.Botn update and oncomplete are not working for me.

<h:form id ="pForm"> 
<p:dataTable style="height:500px;" id="activeStoreTable" var="stIter" value="#   {flowScope.str}"  >
    <p:column width="140"  filterBy="#{stIter.Name}">
           <p:commandLink update="@form"
                 onclick="setCenter('#{stIter.Name}' );"/>                                  
      </p:column>
</p:dataTable> 

<h:inputHidden id="update" value="#{updateBean.value}" />
<p:remoteCommand name="remoteCommand" process="update" update=":pForm:activeTable"      oncomplete="init('flowScope.Str');"/>
<p:commandButton value="save" onclick="check();" name="saves" >
</h:form>

Upvotes: 0

Views: 16459

Answers (2)

wiggin200
wiggin200

Reputation: 331

i think that you haven't done it properly I guess that the remotecommand isn't been called, because to call it you should have to substitute onclick="setCenter('#{stIter.Name}' to onclick="remoteCommand()", to pass the '#{stIter.Name}' parameter you can do this

then you would get something like that:

<h:form id ="pForm"> 
<p:dataTable style="height:500px;" id="activeStoreTable" 
      var="stIter" value="#   {flowScope.str}"  >
    <p:column width="140"  filterBy="#{stIter.Name}">
           <p:commandLink update="@form"
                 onclick="remoteCommand()"
                 oncomplete="javascript:init('flowScope.Str');"
 />                                  
      </p:column>
</p:dataTable> 

<h:inputHidden id="update" value="#{updateBean.value}" />

<p:remoteCommand name="remoteCommand" process="update" 
        update=":pForm:activeTable"  >
<f:setPropertyActionListener value="#{stIter.Name}" 
        target="#{bean.methodName()}" />
</p:remoteCommand>

<p:commandButton value="save" onclick="check();" name="saves" >
</h:form>

I don't know exactly what you're doing but in your code, but I think that you're not calling the remote component comand.

Also I guess that the oncompleteAttribute may not been working because it lacks something, you maybe could try with this:
oncomplete="javascript:init('flowScope.Str');"

you can also pass variables from jsf like
oncomplete="javascript:somefunction('${bean.StringAttribute}');"

I hope that it will be helpful

Upvotes: 0

Kennet
Kennet

Reputation: 5796

Looks like a typo, you want to update :pForm:activeTable but the table is called activeStoreTable

Upvotes: 1

Related Questions