问题
The question says all what is important. When it is necessary to use a a4J:outputpanel and when a4j:region?
回答1:
The documentation says it all:
The
<a4j:region>component specifies a part of the JSF component tree to be processed on the server. The region causes all the a4j and rich Ajax controls to execute: decoding, validating, and updating the model. The region causes these components to execute even if not explicitly declared. As such, processing areas can more easily be marked using a declarative approach.
This is like naming all components explicitly in the execute attribute to an action. Take this example:
<h:inputText id="outerStuff" value="#{bean.blubb}" />
<a4j:region id="innerRegion">
<h:inputText id="stuff1" value="#{bean.bla}" />
<h:inputText id="stuff2" value="#{bean.bla2}" />
<a4j:commandButton action="#{bean.process}" value="click me" />
</a4j:region>
all following three commandButton definitions are equivalent:
<a4j:commandButton action="#{bean.process}" value="click me"
execute="stuff1,stuff2,@this" />
<a4j:commandButton action="#{bean.process}" value="click me"
execute="@region" />
<a4j:commandButton action="#{bean.process}" value="click me" />
The third works because the showcase documentation says:
However, if the controls wrapped with the a4j:region tag and have no execute definitions, they use execute="@region" instead.
In contrast to that, an <a4j:outputPanel> is modelled after an <h:panelGroup> with the added feature of the ajaxRendered attribute. If you leave it off, it behaves like a panelGroup (renders a span or div element). If you enable it, it causes it's contents to be rendered with each AJAX request (unless the component causing the request was annotated limitRender).
To summarize: <a4j:region> influences how Richfaces executes the view/updates the model and <a4j:outputPanel> changes the way the view is rendered.
来源:https://stackoverflow.com/questions/21719451/what-are-the-difference-between-a4joutputpanel-and-a4jregion