Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between render and reRender attributes in jsf

Tags:

jsf

jsf-2

What is the Difference between render and reRender attribute in jSf. Can we use reRender with JSf Core library or it can be used only with ajax4Jsf library.what are the function of both?.

like image 356
Shardendu Avatar asked Apr 30 '14 08:04

Shardendu


People also ask

What is the difference between render and ReRender?

Rendered is bound to a Boolean variable in controller which can be switched between true and false making the vf component display or hide depending on Boolean value. ReRender : Rerender is used to refresh a particular section of the visualforce page.

What is ReRender JSF?

reRender - attribute that defines id(s) of JSF component(s) that should be rerendered after an Ajax request. ... It's also possible to use JSF EL expression as a value of the reRender attribute. It might be a property of types Set, Collection, Array or simple String. ( commas are valid, not sure about spaces)

What is ReRender in VF page?

ReRender is used to refresh a particular section of the visual force page. We have to just mention the id of the page section (in the ReRender attribute) that needs to be refreshed. In the following example Clicking of the command button “Refresh Lower Page Block” refreshes the lower page block.


1 Answers

<f:ajax event="change" render=":moons :suns" />    
<a4j:support event="onchange" reRender=":moons, :suns" />   
<p:ajax event="change" update=":moons, :suns" />

1. Note those three ajax calls. The first one is a standard JSF ajax that belongs to java.sun.com/jsf/core it uses renders attribute to update the required components in DOM.

render - A space-separated list of IDs for components that will be updated after an Ajax request. (only spaces are valid)


2. The second one belongs to RichFaces 3, note the difference on event attribute

reRender - attribute that defines id(s) of JSF component(s) that should be rerendered after an Ajax request. ... It's also possible to use JSF EL expression as a value of the reRender attribute. It might be a property of types Set, Collection, Array or simple String. (commas are valid, not sure about spaces)

  • in RichFaces 4 the reRender attribute has been renamed to render

3. The third one belongs to PrimeFaces and uses an update attribute (in my opinion the most meaningful name of those three)

update - Component(s) to update with ajax. (spaces and commas are valid)


So as you can see they basically do the same job with minor differences in how to use them. No, You can't mix them. Use render with jsf/core, reRender with ajax4Jsf in Richfaces 3, and update with PrimeFaces components. Note that in RichFaces 4 the reRender attribute has been renamed to render.

What concerns events - PrimeFaces and jsf/core use actual DOM-event names (unprefixed), RichFaces on the other hand uses prefixed events eg. onchange as opposed to change. Note that the new RichFaces 4(<a4j:ajax> replaced <a4j:support>) <a4j:ajax>'s event attribute works the same as <f:ajax>'s event.

like image 194
Kuba Avatar answered Oct 03 '22 03:10

Kuba