PanelGroup without style or styleClass is not displayed if no ID is specified

According to the tag library for http://xmlns.jcp.org/jsf/html , h:panelGroup -

Designed for use in situations where only one UIComponent Child can be nested, for example, in the case of facets. If the attributes are "style" or "styleClass", and the "Location" attribute is present with the value "block", displays the "div" element, the output of the value of the attribute "style" as the value of the attribute "style" and the value of the attribute "styleClass" 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", visualize the "span" element, displaying the value of the "style" attribute as the value of the "style" attribute, as well as the value of the "styleClass attribute "as the value of the" class "attribute.

When

 <h:panelGroup id="id" layout="block"> <!-- ... ---> </h:panelGroup> 

or

 <h:panelGroup layout="block" style="margin-right: 10px;"> <!-- ... ---> </h:panelGroup> 

a div :

 <div id="id"> </div> 

relevant

 <div style="margin-right: 10px;"> </div> 

but if there is no id (if you do not want to update panelGroup ) or style (if you do not want to erase panelGroup ), then there is no div and the resulting HTML can ruin the layout. In addition, exploring the JSF domain, a panelGroup can also be used to conditionally render children using its rendered flag, but, as mentioned earlier, when omitting the two specified attributes, the result is rendered conditionally, but without a div , for example

 <h:panelGroup layout="block" rendered="true"> <it>Without DIV.</it> </h:panelGroup> 

leads to

 <it>Without DIV.</it> 

After this request, I want to check with the Stackoverflow community that I correctly understood that when you do not use panelGroup as a naming container or for the usual style of its elements, it is better to solve the conditional rendering part (if necessary) using ui:fragment and the mock part with hard-coded div . This is true?

+7
jsf
source share
1 answer

Note: we are talking about if h:panelgroup will display any HTML component, but if render="false" internal components will not be blocked from rendering in any case.

The h:panelgroup behavior tree consists of two checks:

  • Is at least one of the id or style or styleClass attributes set?
    Yes:
    but. Shows a <div> if layout = "block", otherwise
    b. Displays a <span> (layout = "gibberish" or nonexistent)

    Not:

  • Does not display the html component. Still useful if you want to use "visualized" or when you can only attach one component (i.e. <f:facet> )

The test for the layout attribute appears only after 1. , above. Since your third example is on the no branch, it is ignored.

0
source share

All Articles