Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jsf 2 - difference between render and reRender attributes in jsf

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?.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...