function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chioikbhchioikbh 

command button doesnn't rerender component

Hi,

 

I have a complex commandButton for voting idea. The function is everytime I click it, it votes for an idea in the controller, and in the front end I would like to popup a windows showing it is successful vote or any error. If it is success, then I hope the idea's likes point is refreshed partially and get increased.

 

The pop up windows is get rerendered and works well, but not the singleIdeaPanel which I would like to rerender, so the likes number is get increased.

 

Thanks in advance for the kind help

 

My code:

<apex:form >

    <apex:outputPanel id="jspanelLV">

      <script> 

          function onControllerReturn() {

            alert('{!listViewMessage}')

          }

      </script>  

  </apex:outputPanel>

 

 

<apex:outputPanellayout="block"class="list_item"id="singleIdeaPanel">

<

apex:commandButtononclick="voteJS('{!JSENCODE(visualData.recordId.value)}');" reRender="jspanelLV, singleIdeaPanel"styleClass="{!IF(visualData.canVote,'icon icon_like small','icon icon_like small is-liked')}"rendered="{!$ObjectType.Idea.createable}"/>

{!visualData.likes.value}

</apex:outputPanel>

 

<

apex:actionstatusid="voteStatusLV"onstop="onControllerReturn();">

  

</apex:actionstatus>

 

<apex:actionFunctionaction="{!vote}"name="voteJS"reRender="singleIdeaPanel, jspanelLV"status="voteStatusLV">

          

<apex:paramname="IdeaId"assignTo="{!voteIdeaId}"value=""/>              

      

</apex:actionFunction>

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9
This means the page component is rerendering and seems like the problem is somewhere else.
Anyways I guess you are aware about the fact rerender doesnt mean you are reloading the page it is just as good as re drawing the component.

Problem is happening because the underlying wrapper/object is not getting updated. You have to update the object with the action. Once that is updated the page will reflect the change

All Answers

Avidev9Avidev9

Your code seems good doesnt seem to have a problem.

Well lets confirm the panel is reloading or not. Try adding an alert inside the panel. something like

 

<apex:outputPanel layout="block" class="list_item" id="singleIdeaPanel">
   <script>alert("loaded");</script>  
</apex:outputPanel>

 So the alert will popup if it refereshes. 

Let me know your finding after changing the code

chioikbhchioikbh

Thank you for the reply.

 

I did the change, and actually it alerts!!! So it is just the likespoint doesn't get change before the rerender?! Because if I manually refresh the page, then it will get the increased likespoint. Hmmmm, I am confused. 

Avidev9Avidev9
This means the page component is rerendering and seems like the problem is somewhere else.
Anyways I guess you are aware about the fact rerender doesnt mean you are reloading the page it is just as good as re drawing the component.

Problem is happening because the underlying wrapper/object is not getting updated. You have to update the object with the action. Once that is updated the page will reflect the change
This was selected as the best answer
chioikbhchioikbh

Thanks for the inspiration. I got it. The problem is in controller, I didn't refresh the model data which used in the rerender component.