3

I came across with a code snippet which has the line of code as given below,

<apex:commandButton styleClass="process-block-button" value="Process Selected" action="{!DoSomethingMany}"
                        status="ProcessButtonStatus" rerender="nothing" />

What is the difference between rerender="nothing" and without a rerender attribute above? Also, there is no component in the name "nothing" to rerender. Please suggest.

5

If you have defined some value for the reRender parameter of the command button it will be recognized as an element ID and this element will be refreshed. So it is not important what value is used, but is should be an ID of some element that exists on the page. If there is no elememt with such ID, then nothig will be rerendered.

Another important thing is that a visualforce command button with defined "reRender" element is represented on the page as an input element with a type="button" and an AJAX.submit event so the apex method is called asynchronous:

<!-- Visualforce markup -->
<apex:commandButton action="{!someMethod}" value="My Button" reRender="none"/>

<!-- Generated HTML element -->
<input type="button" value="My Button" class="btn" id="j_id0:j_id4:j_id5" name="j_id0:j_id4:j_id5" onclick="A4J.AJAX.Submit('j_id0:j_id4',event,{'similarityGroupingId':'j_id0:j_id4:j_id5','parameters':{'j_id0:j_id4:j_id5':'j_id0:j_id4:j_id5'} } );return false;"  >

With an empty "reRender" parameter the button is represented as an input element of a type submit: type="submut". This means by click on this button it will SUBMIT the entire form and the page will completely reloaded (synchronous in this case):

 <!-- Visualforce markup (without reRender parameter) -->
<apex:commandButton action="{!someMethod}" value="My Button"/>

<!-- Generated HTML element -->
<input type="submit" value="My Button" class="btn" name="j_id0:j_id4:j_id6" >

Here is a good topic about difference between those types: Difference between type=button and type=submit

  • Thanks @mastOr. Excellent notes. Now i understood the difference. – Bforce Sep 24 '14 at 15:40
1

If you don't write rerender attribute the full page will be rerender but if you add this attribute with value the full page will not be refreshed. If there is any component with name (in you case "nothing") then that component will be rerender other nothing will be rerender. It will be same as you defined javascript method and at the end can write "return true;" or "return false;".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.