JSF2 - selectOneMenu在overlayPanel外部打开

时间:2014-11-12 16:03:15

标签: jsf jsf-2 primefaces overlay selectonemenu

我正在使用<p:overlayPanel>,其中包含几个<p:selectOneMenu>以及其他几个组件。当<p:selectOneMenu>打开时,某些字段会落在<p:overlayPanel>之外,点击它们会导致面板关闭。 (见下图)。

enter image description here

。 。

一种解决方案是修改<p:overlayPanel>,如下所示:

dismissable="false"
showCloseIcon="true"

另一种方法是修改<p:selectOneMenu>

height="50"

我正在为尽可能简单的解决方案寻找一些选项,并且最好不要对UI进行更改(以上解决方案都会更改UI)。有没有办法让<p:overlayPanel>在其外部的点击属于<p:selectMenu&gt;之一时保持打开状态?

更完整的代码

<p:overlayPanel styleClass="col-settings-panel" 
            id="colSettingsPanel" 
            for="columnSettingsBtn" 
            hideEffect="fade"
            widgetVar="wvcolSettingsPanel"
            rendered="#{empty rendered ? 'true' : rendered}" >   
    <p:pickList id="pickList" 
            value="#{fileSearchPersonalizationBean.columns}" 
            var="column"
            showSourceFilter="true" 
            itemLabel="#{column}" 
            itemValue="#{column}" 
            itemDisabled="#{column eq 'Ref No'}">
            <p:ajax event="transfer" listener="#{fileSearchPersonalizationBean.onTransfer}" update="pickList availableCount selectedCount selectSortBy" />
            <f:facet  name="sourceCaption">
                <h:outputText value="Available Columns ("/>
                <h:outputText id="availableCount" value="#{fileSearchPersonalizationBean.sourceCount}"/>
                <h:outputText value=")"/>
            </f:facet>
            <f:facet name="targetCaption">
                <h:outputText value="Selected Columns ("/>
                <h:outputText id="selectedCount" value="#{fileSearchPersonalizationBean.targetCount}"/>
                <h:outputText value=")"/>
            </f:facet>
     </p:pickList>

  <p:panelGrid columns="1">
    <p:outputPanel styleClass="col-settings-panel-option">
        <h:outputLabel value="Sort By: " />
        <p:selectOneMenu id="selectSortBy" 
                value="#{fileSearchPersonalizationBean.sortBy}" >
            <p:ajax listener="#{fileSearchPersonalizationBean.sortByChanged}"   />
            <f:selectItems id="sortByList" value="#{fileSearchPersonalizationBean.columns.target}" />
        </p:selectOneMenu>
    </p:outputPanel>     
    <p:outputPanel styleClass="col-settings-panel-option">
         <h:outputLabel value="Items per Page:"/> 
         <p:selectOneMenu id="selectRows" value="#{fileSearchPersonalizationBean.sRows}" >
            <f:selectItem itemLabel="10" itemValue="10" />
            <f:selectItem itemLabel="25" itemValue="25" />
            <f:selectItem itemLabel="50" itemValue="50" />
            <f:selectItem itemLabel="100" itemValue="100" />
         </p:selectOneMenu>
    </p:outputPanel>
  </p:panelGrid>

  <p:panelGrid styleClass="toolbar" columns="2">
    <p:outputPanel>
        <p:commandButton styleClass="btn-secondary" 
                         id="loadDefaults" 
                         value="Reset Defaults" 
                         update="selectSortBy pickList selectRows" 
                         actionListener="#{fileSearchPersonalizationBean.loadDefaultVO}" />
    </p:outputPanel>
    <p:outputPanel styleClass="toolbar-right">
        <p:commandButton styleClass="btn-secondary" 
                         id="columnClose" 
                         value="Cancel" 
                         actionListener="#{fileSearchPersonalizationBean.panelCancel}"
                         immediate="false">
            <f:attribute name="panelId" value="#{formId}:colSettingsPanel" />
        </p:commandButton>
        <p:commandButton styleClass="btn-primary" 
                         id="columnSubmit" 
                         value="Save &amp; Apply" 
                         actionListener="#{fileSearchPersonalizationBean.panelSave}"
                         oncomplete="refreshSearchResults();" >
            <f:attribute name="panelId" value="#{formId}:colSettingsPanel" />
        </p:commandButton>
    </p:outputPanel>
  </p:panelGrid>    

</p:overlayPanel>`

0 个答案:

没有答案