According to the tag library for http://xmlns.jcp.org/jsf/html, a h:panelGroup
is
Intended for use in situations when only one UIComponent child can be nested, such as in the case of facets. If the "style" or "styleClass" attributes are present, and the "layout" attribute is present with a value of "block", render a "div" element, outputting the value of the "style" attribute as the value of the "style" attribute and the value of the "styleClass" attribute as the value of the "class" attribute. Otherwise, if the "layout" attribute is not present, or the "layout" attribute contains a value other than "block", render a "span" element, outputting the value of the "style" attribute as the value of the "style" attribute, and the value of the "styleClass" attribute as the value of the "class" attribute.
In case of
<h:panelGroup id="id" layout="block">
<!-- ... --->
</h:panelGroup>
or
<h:panelGroup layout="block" style="margin-right: 10px;">
<!-- ... --->
</h:panelGroup>
a div
is being rendered:
<div id="id">
</div>
respective
<div style="margin-right: 10px;">
</div>
but when omitting the id
(if one don't want to update
the panelGroup
) or the style
(if one don't want to style the panelGroup
) no div
is being rendered and the resulting HTML can mess up ones layout. Furthermore exploring the realm of JSF, a panelGroup
can also be used to conditionally render child elements using its rendered
flag but as mentioned before when omitting the two mentioned attributes the result is rendered conditionally but without a div
, such as
<h:panelGroup layout="block" rendered="true">
<it>Without DIV.</it>
</h:panelGroup>
leads to
<it>Without DIV.</it>
After this inquiry I want to check with the Stackoverflow community that I understood it right that when not using a panelGroup
as a naming container or to customary style its elements one is better off solving the conditional rendering part (if needed) using a ui:fragment
and the layouting part with a hard-coded div
. Is this so?