p:selectManyCheckbox location incorrect on p:dialog using jsf 2.3

UI Components for JSF
Post Reply
johng
Posts: 4
Joined: 23 Apr 2018, 21:10

23 Apr 2018, 22:27

After upgrading to JSF 2.3, the selectManyCheckbox on our p:dialog has mysteriously moved to the bottom of the dialog, below the buttons. This was not an issue using JSF 2.2.15 with PrimeFaces 6.1 or 6.2. This problem occurs only when using JSF 2.3/javax.servlet 4.0.0 (with either PrimeFaces 6.1 or 6.2). This is running on apache-tomcat 9.0.2.

The following image illustrates the problem:

ImageselectManyCheckboxProblem by John Gravell, on Flickr

More details:
The layout of the selectManyCheckbox is "grid"; using "responsive" does not produce the problem

The behavior can be avoided by doing any of the following (that we do not want to do)
- Changing the number of columns to a number that evenly divides into the number of the selectmanyCheckbox selectitems
- Removing all the selectitems from the preceding p:selectOneMenu
- Changing the preceding p:selectOneMenu to an h:selectOneMenu


Below is the code for the template, the page, and the popup dialog

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:sec="http://www.springframework.org/security/tags">

  <f:view contentType="text/html; charset=UTF-8">
    <h:head>
      <ui:insert name="headIncludes"/>   
      <title><ui:insert name="title">Default title</ui:insert></title>
    </h:head>
	  
    <h:body>
      <table class="documentContainer">
        <tr><td><ui:insert name="baseContent"><p>Default base content</p></ui:insert></td></tr>
      </table>
    </h:body>
  </f:view>
    
</html>


<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:sf="http://www.springframework.org/tags/faces"
  xmlns:p="http://primefaces.org/ui"  
  template="/WEB-INF/templates/baseTemplate.xhtml">

   <ui:define name="title">Users</ui:define>
   <ui:define name="baseContent">
   <h:form id="form"> 
                               
       <h3><h:outputText value="Administer Users"/></h3>
       
       <p:commandButton value="New User"
                        id="newUserButton"
                        oncomplete="PF('userDialog').show();" />   
 
     <ui:include src="userDialog2.xhtml" />    
  
    </h:form>    
    </ui:define>

</ui:composition>



<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:sf="http://www.springframework.org/tags/faces"
  xmlns:p="http://primefaces.org/ui">

    <p:dialog header="Edit User"
               id="userDialogId"
               widgetVar="userDialog"
               modal="true"
               width="700"
               height="auto" >

    <h:panelGrid columns="2" >		
			<p:outputLabel for="editCustomerIn">Customer Name:</p:outputLabel>
			<h:panelGroup id="customerNamePanelGroup">
			  <p:selectOneMenu id="editCustomerIn"
		  		               style="width:400">
	        <f:selectItem itemLabel="Exxon" itemValue="Exxon" />
	        <f:selectItem itemLabel="Kellogs" itemValue="Kellogs" />
	        <f:selectItem itemLabel="Target" itemValue="Target" />	
			  </p:selectOneMenu>	
			</h:panelGroup>			
    </h:panelGrid>
		   
    <h:panelGrid id="rolesPanel" columns="2">
			<p:outputLabel for="roles">Companies:</p:outputLabel>
				<p:selectManyCheckbox label="Roles"
				                      id="roles"
				                      layout="grid" 
				                      columns="3" 
					                    style="text-align:left">					                    
					<f:selectItem itemLabel="Exxon" itemValue="Exxon" />
	        <f:selectItem itemLabel="Kellogs" itemValue="Kellogs" />
	        <f:selectItem itemLabel="Target" itemValue="Target" />
	        <f:selectItem itemLabel="Ford" itemValue="Ford" />
	        <f:selectItem itemLabel="Boeing" itemValue="Boeing" />
	        <f:selectItem itemLabel="Google" itemValue="Google" />
	        <f:selectItem itemLabel="IBM" itemValue="IBM" />
	        <f:selectItem itemLabel="Trek" itemValue="Trek" />
	        <f:selectItem itemLabel="Alcoa" itemValue="Alcoa" />
	        <f:selectItem itemLabel="Dell" itemValue="Dell" />      
				</p:selectManyCheckbox>			
	  </h:panelGrid>


    <p:panel style="margin: 10px auto; text-align: center; border:none" >
      <h:panelGroup id="commandButtonPanel" >
		    <p:commandButton id="saveButton"
                                                               value="Save"
                                                               onclick="PF('userDialog').hide(); return false;"/>
						             
        <p:commandButton id="cancelButton"
                         value="Cancel"
                         onclick="PF('userDialog').hide(); return false;" />			
		  </h:panelGroup>
  	</p:panel>	

	</p:dialog>
</ui:composition>



kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

24 Apr 2018, 12:03

offtopic: replace the jsf pre 2.2 namespaces (xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core") with their 2.2+ counterparts.

On-topic: also post the '2.2' image... and try making an mcve... http://stackoverflow.com/help/mcve / https://stackoverflow.com/tags/jsf/info

johng
Posts: 4
Joined: 23 Apr 2018, 21:10

24 Apr 2018, 18:53

Here is the appearance of using jsf 2.2.15:

Image

Using jsf 2.2.15, the selectManyCheckbox is in the expected location

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

24 Apr 2018, 21:26

So your code is an mcve already? Anything you remove makes it work normally? So not using

Code: Select all

<ui:include src="userDialog2.xhtml" />
but putting the dialog xhtml directly at that place does make it work normally? Or not using a template? Or....

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

24 Apr 2018, 21:40

And did you check if there are any differences in the JSF 2.3 components (css wise?) Or e.g. if in 2.2 something is a div and in 2.3 a span or...

johng
Posts: 4
Joined: 23 Apr 2018, 21:10

25 Apr 2018, 17:50

Here the code is simplified:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:p="http://primefaces.org/ui"
  xmlns:sec="http://www.springframework.org/security/tags">

  <f:view contentType="text/html; charset=UTF-8">
    <h:head>
      <ui:insert name="headIncludes"/>   
      <title><ui:insert name="title">Default title</ui:insert></title>
    </h:head>
    
    <h:body>
	    <h:form id="form">
			    <h:panelGrid columns="2" >    
			      <p:outputLabel for="editCustomerIn">Customer Name:</p:outputLabel>
			      <h:panelGroup id="customerNamePanelGroup">
			        <p:selectOneMenu id="editCustomerIn">
			          <f:selectItem itemLabel="Exxon" itemValue="Exxon" />
			          <f:selectItem itemLabel="Kellogs" itemValue="Kellogs" />
			          <f:selectItem itemLabel="Target" itemValue="Target" />  
			        </p:selectOneMenu>  
			      </h:panelGroup>     
			    </h:panelGrid>
			       
			    <h:panelGrid id="rolesPanel" columns="2">
			      <p:outputLabel for="roles">Companies:</p:outputLabel>
			        <p:selectManyCheckbox label="Roles"
			                              id="roles"
			                              layout="grid" 
			                              columns="3">                              
			          <f:selectItem itemLabel="Exxon" itemValue="Exxon" />
			          <f:selectItem itemLabel="Kellogs" itemValue="Kellogs" />
			          <f:selectItem itemLabel="Target" itemValue="Target" />
			          <f:selectItem itemLabel="Ford" itemValue="Ford" />
			          <f:selectItem itemLabel="Boeing" itemValue="Boeing" />   
			        </p:selectManyCheckbox>     
			    </h:panelGrid>
			
			    <p:panel>
			      <h:panelGroup id="commandButtonPanel" >
			        <p:commandButton id="cancelButton"
			                         value="Cancel"
			                         onclick="PF('userDialog').hide(); return false;" />      
			      </h:panelGroup>
			    </p:panel>  		
	    </h:form>
    </h:body>
  </f:view>
    
</html>
And here is the appearance inf jsf 2.3:

Image


vs the (desired) appearance as in jsf 2.2.15:

Image

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

25 Apr 2018, 21:46

Great, So it is not that difficult for you to check with a browser developer tool if there are any differences in the generated html? In the applied css?

johng
Posts: 4
Joined: 23 Apr 2018, 21:10

26 Apr 2018, 22:18

This section of my primefaces xhtml shows the h:panelGrid for the rolesPanel, and the p:panel for the commandButtonPanel:

Code: Select all

			    <h:panelGrid id="rolesPanel" columns="2">
			      <p:outputLabel for="roles">Companies:</p:outputLabel>
			        <p:selectManyCheckbox label="Roles"
			                              id="roles"
			                              layout="grid" 
			                              columns="3">                              
			          <f:selectItem itemLabel="Exxon" itemValue="Exxon" />
			          <f:selectItem itemLabel="Kellogs" itemValue="Kellogs" />
			          <f:selectItem itemLabel="Target" itemValue="Target" />
			          <f:selectItem itemLabel="Ford" itemValue="Ford" />
			          <f:selectItem itemLabel="Boeing" itemValue="Boeing" />   
			        </p:selectManyCheckbox>     
			    </h:panelGrid>
			
			    <p:panel>
			      <h:panelGroup id="commandButtonPanel" >
			        <p:commandButton id="cancelButton"
			                         value="Cancel"/>      
			      </h:panelGroup>
			    </p:panel>  		

Upon examination of the generated html, a curious difference is observed:

jsf 2.2.15 generates this:

Code: Select all

        <table id="form:rolesPanel">
            <tbody>
               <tr>
                  <td><label id="form:j_idt13" class="ui-outputlabel ui-widget" for="form:roles">Companies:</label></td>
                  <td>
                     <table id="form:roles" role="presentation" class="ui-selectmanycheckbox ui-widget">
                        <tr>
                           <td>
                              <div class="ui-chkbox ui-widget">
                                 <div class="ui-helper-hidden-accessible"><input id="form:roles:0" name="form:roles" type="checkbox" value="Exxon" data-p-label="Roles" data-p-hl="manychkbox" data-p-grouped="true" /></div>
                                 <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank ui-c"></span></div>
                              </div>
                              <label for="form:roles:0">Exxon</label>
                           </td>
.
.
.
                     </table>
                     <script id="form:roles_s" type="text/javascript">$(function(){PrimeFaces.cw("SelectManyCheckbox","widget_form_roles",{id:"form:roles"});});</script>
                  </td>
               </tr>
            </tbody>
         </table>
		 
         <div id="form:j_idt20" class="ui-panel ui-widget ui-widget-content ui-corner-all" data-widget="widget_form_j_idt20">
            <div id="form:j_idt20_content" class="ui-panel-content ui-widget-content">
               <span id="form:commandButtonPanel">
                  <button id="form:cancelButton" name="form:cancelButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="PrimeFaces.ab({s:&quot;form:cancelButton&quot;});return false;" type="submit"><span class="ui-button-text ui-c">Cancel</span></button><script id="form:cancelButton_s" type="text/javascript">PrimeFaces.cw("CommandButton","widget_form_cancelButton",{id:"form:cancelButton"});</script>
               </span>
            </div>
         </div>
         <script id="form:j_idt20_s" type="text/javascript">PrimeFaces.cw("Panel","widget_form_j_idt20",{id:"form:j_idt20"});</script><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="e8s1" />

However, jsf 2.3 generates this code. Here, rather than appearing after the rolesPanel table, the div for the commandButtonPanel is included within the rolesPanel table!?!

Code: Select all

     <table id="form:rolesPanel">
         <tbody>
            <tr>
               <td><label id="form:j_idt13" class="ui-outputlabel ui-widget" for="form:roles">Companies:</label></td>
               <td>
                  <table id="form:roles" role="presentation" class="ui-selectmanycheckbox ui-widget">
                     <tr>
                        <td>
                           <div class="ui-chkbox ui-widget">
                              <div class="ui-helper-hidden-accessible"><input id="form:roles:0" name="form:roles" type="checkbox" value="Exxon" data-p-label="Roles" data-p-hl="manychkbox" data-p-grouped="true" /></div>
                              <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank ui-c"></span></div>
                           </div>
                           <label for="form:roles:0">Exxon</label>
                        </td>
 .
 .
 .
                     </tr>
                     <script id="form:roles_s" type="text/javascript">$(function(){PrimeFaces.cw("SelectManyCheckbox","widget_form_roles",{id:"form:roles"});});</script>
                  </table>
               </td>
            </tr>
         </tbody>
         
         <div id="form:j_idt20" class="ui-panel ui-widget ui-widget-content ui-corner-all" data-widget="widget_form_j_idt20">
            <div id="form:j_idt20_content" class="ui-panel-content ui-widget-content">
               <span id="form:commandButtonPanel">
                  <button id="form:cancelButton" name="form:cancelButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="PrimeFaces.ab({s:&quot;form:cancelButton&quot;});return false;" type="submit"><span class="ui-button-text ui-c">Cancel</span></button><script id="form:cancelButton_s" type="text/javascript">PrimeFaces.cw("CommandButton","widget_form_cancelButton",{id:"form:cancelButton"});</script>
               </span>
            </div>
         </div>
         <script id="form:j_idt20_s" type="text/javascript">PrimeFaces.cw("Panel","widget_form_j_idt20",{id:"form:j_idt20"});</script><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="e3s1" />
      </table>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests