PF 6.0.RC3 - p:selectOneMenu width problem

UI Components for JSF
Post Reply
Marqus
Posts: 49
Joined: 28 Apr 2013, 09:25

05 May 2016, 11:16

When upgrading from PrimeFaces 5.2 to 6.0.RC3, I've noticed undesired effect with p:selectOneMenu width. PrimeFaces 5.3 gives me the same.
5.2
Image
5.3
Image
6.0.RC3
Image

Code: Select all

<style>
            .aCol1 {
                text-align: right;
                width: 40%;
            }
            .aCol2 {
                text-align: left;
                width: 60%;
            }
        </style>
        <h:form id="form" >  
            <p:panel style="width: 30%;"
                     header="SelectOneMenu width test - PrimeFaces 5.3">
                <h:panelGrid columns="2" width="100%" cellspacing="5"
                             columnClasses="aCol1,aCol2">
                    
                    <p:outputLabel value="Sth1"/>
                    <p:commandButton type="button" value="Test1" style="width: 100%"/>
                    
                    <p:outputLabel value="Sth2"/>
                    <p:commandButton type="button" value="Test2" style="width: 100%"/>
                    
                    <p:outputLabel value="Sth3"/>
                    <p:selectOneMenu value="#{someBean.propertyVal}"
                                     style="width: 100%">
                        <f:selectItem noSelectionOption="true" itemLabel="" itemValue=""/>
                        <f:selectItem itemLabel="val1" itemValue="val1"/>
                        <f:selectItem itemLabel="val2" itemValue="val2"/>
                    </p:selectOneMenu>

                    <p:outputLabel value="Sth4"/>
                    <p:commandButton type="button" value="Test3" style="width: 100%"/>
                </h:panelGrid>
                <p:separator/>
            </p:panel>
        </h:form>
PrimeFaces 8.0;
Mojarra 2.2.12, GlassFish 4.1.1, NetBeans 8.2
Mozilla Firefox 105.0.2

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

05 May 2016, 11:23

Check the issuelist. Has been reported before iirc. Using a "width: calc(100% -20px)" might be a workaround. Where you have to determine the real value instead of my guestimate of 20px yourself

Marqus
Posts: 49
Joined: 28 Apr 2013, 09:25

05 May 2016, 12:03

Sorry, I overlooked that issue.
PrimeFaces 8.0;
Mojarra 2.2.12, GlassFish 4.1.1, NetBeans 8.2
Mozilla Firefox 105.0.2

nokiajavi
Posts: 61
Joined: 24 Feb 2013, 15:03
Location: España
Contact:

14 Jun 2016, 13:25

I have the same problom with primefaces 6.0.

By default, primefaces add the attribute min-width, with a value of the total length of elements into panel (Items).


This causes not well renderize the component and leave the panels . So far I have solved by adding a class with min- whdth : 0px important!

¿Ist a Issue Pirmefaces 6.0?

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

14 Jun 2016, 16:27

Hi Marqus,

Please use "ui-fluid" class for width:100%;

Code: Select all

...
<p:panel style="width: 30%;"  header="SelectOneMenu width test - PrimeFaces 5.3 or 6.0">
    <h:panelGrid columns="2" width="100%" cellspacing="5"  columnClasses="aCol1,aCol2" styleClass="ui-fluid">
                    
           <p:outputLabel value="Sth1"/>
           <p:commandButton type="button" value="Test1"/>
                    
           <p:outputLabel value="Sth2"/>
           <p:commandButton type="button" value="Test2" />
                    
           <p:outputLabel value="Sth3"/>
           <p:selectOneMenu value="#{someBean.propertyVal}">
                <f:selectItem noSelectionOption="true" itemLabel="" itemValue=""/>
                <f:selectItem itemLabel="val1" itemValue="val1"/>
                <f:selectItem itemLabel="val2" itemValue="val2"/>
            </p:selectOneMenu>

            <p:outputLabel value="Sth4"/>
            <p:commandButton type="button" value="Test3"/>
    </h:panelGrid>
    <p:separator/>
</p:panel>
...
Hi Nokiajavi,
This causes not well renderize the component and leave the panels . So far I have solved by adding a class with min- whdth : 0px important!
Please try;

Code: Select all

<p:selectOneMenu autoWidth="false" .../>
Github issue; https://github.com/primefaces/primefaces/issues/244

josechuah
Posts: 1
Joined: 21 Jun 2017, 04:29

22 Jul 2017, 09:49

In case for anyone who wanted a fixed width for <p:selectonemenu> under these scenario. Hope following setting helps.

1. initial width with loaded different length of data.
2. select a data from the select one menu list or re-loaded during run time using ajax from other component(such as p:inputText)

1. Create a css class in the local css file.
.ui-selectonmenu_full_width{
min-width: 178px;
max-width: 178px;
}

2. at the xhtml form
...
<p:selectOneMenu styleClass="ui-selectonmenu_full_width" autoWidth="false" .../>
...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests