在p panelgrid中显示selectonemenu primefaces时的错误

时间:2013-05-12 14:20:41

标签: css jsf-2 primefaces panel

我有这个问题: enter image description here

这是代码:

    <p:panelGrid styleClass="newArticlePanelGrid" >

<!-- __________________________________________row1________________________________________________ -->
<p:row>

<p:column>
<h:outputLabel value="Designation : " />                        
</p:column>
<p:column colspan="3" >
<p:inputText id="new-article-designation"  style="width: 449px;"
                            value="#{articlesMB.article.designation}" required="true"
                            requiredMessage="designation requise" />

</p:column>

</p:row>

<p:row>

<p:column />
<p:column colspan="3" >
<p:message id="for-new-article-designation"
                            for="new-article-designation" display="text" />
</p:column>


</p:row>
<!-- __________________________________________row2________________________________________________ -->
<p:row>

<p:column>
<h:outputLabel value="Type : " />

</p:column>
<p:column>
    <p:selectOneMenu id="new-article-typeggg" required="true"
                            requiredMessage="type requis" converter="#{typeConverter}"
                            style="width:100%" value="#{articlesMB.article.type}">
                            <!--        <f:selectItem itemLabel="Selectionner Type" itemValue="" />-->
                            <f:selectItems value="#{articlesMB.listTypes}" var="v"
                                itemLabel="#{v.libelle}" itemValue="#{v}" />
                        </p:selectOneMenu>

</p:column>
<p:column>
    <h:outputLabel value="Unité : " />

</p:column>
<p:column>
    <p:selectOneMenu id="new-article-unite" required="true"
                            widgetVar="uniteselect" requiredMessage="unité requise"
                            converter="#{uniteConverter}" style="width:100%"
                            value="#{articlesMB.article.unite}">
                            <!--            <f:selectItem itemLabel="Selectionner Unite" itemValue=""  /> -->
                            <f:selectItems value="#{articlesMB.listUnites}" var="v"
                                itemLabel="#{v.libelle}" itemValue="#{v}" />
                        </p:selectOneMenu>

</p:column>

</p:row>

<p:row>

<p:column />
<p:column>

我不知道应该怎么做才能解决这个问题:我测试了width:100%,但是你发现它没有改变

我该如何解决?

提前谢谢

1 个答案:

答案 0 :(得分:7)

问题来自style="100%",它只改变了selectonemenu的宽度,你应该在selectonemenu中设置标签的宽度(在这种情况下):

            <style type="text/css">
                .ui-selectonemenu-label{
                    width:100% !important;
                }
            </style>

如果你想设置所有selectonemenu:

             <style type="text/css">
                .ui-selectonemenu-label{
                    width:100% !important;
                }
                .ui-selectonemenu{
                    width:100% !important;
                }
            </style>

更一般,您可以包含在css文件中。

另请参阅: What is the JSF resource library for and how should it be used?