0

のデフォルト値の設定に問題があります<p:selectOneRadio>。関連するトピックをいくつか読みましたが、問題に対する答えが見つかりませんでした。それが今どのように機能するかです:

  1. <p:commandButton>をクリックした後、showLogEntryClassificationDlg() を使用して、バッキング Bean (セッション スコープを持つ) に値を設定しました。

    <p:commandButton value="#{text['button.add']}" id="treeAdd"    
        styleClass="btn btn-primary" icon="fa fa-plus"
        actionListener="#{eventLogDetails.showLogEntryClassificationDlg()}"
        update=":logEntryClassificationDialogForm"
        oncomplete="PF('dlgLogEntryClassification').show(); return false;" />
    

    ジャワ

    public void showLogEntryClassificationDlg(){
        mode = MODE.ADD;
        logEntryClassification = new LogEntryClassification();
        logEntryClassification.setLogEntryType(LogEntryType.LOG_ENTRY_CATEGORY);
        //some other code
    }
    
  2. ダイアログは表示されますが、ラジオボタンの値が選択されていません。バッキング Bean でゲッターをチェックしたところ、正しい値が返されました (ただし、数回呼び出されます)。ダイアログのどこか(!)を選択すると、ラジオボタンが選択されます(ゲッターは呼び出されません)。

    (ほぼ) 完全な xhtml ファイル:

    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:o="http://omnifaces.org/ui">
    
        <ui:composition template="/layouts/default.xhtml">
        <ui:define name="title">#{text['eventLogDetail.title']}</ui:define>
        <ui:param name="menu" value="EventLogMenu" />
    
        <ui:define name="body">
            <h:outputScript name="jsf.js" library="javax.faces" target="head" />
    
            <h:form id="eventLogDetailsForm">
    
                //some code
    
                <div class="row">
                    <div class="col-md-12">
                        <div class="portlet">
                            <h4 class="portlet-title">
                                <u><i class="fa fa-sitemap"> </i>
                                    #{text['eventLogDetail.heading.classification']}</u>
                            </h4>
                            <div class="portlet-body">
                                <div class="row dt-rt">
                                    <div class="col-sm-12">
                                        <p:panel id="treeButtonPanel" styleClass="no-style-panel">
                                            <div class="btn-group">
    
                                                <p:commandButton value="#{text['button.add']}" id="treeAdd"
                                                    styleClass="btn btn-primary" icon="fa fa-plus"
                                                    actionListener="#{eventLogDetails.showLogEntryClassificationDlg}"
                                                    update=":logEntryClassificationDialogForm, :logEntryClassificationDialogForm:logEntryTypeRadioPanel"
                                                    oncomplete="PF('dlgLogEntryClassification').show(); return false;" />
    
                                                //other commandButtons
    
                                            </div>
                                        </p:panel>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </h:form>
    
        <!-- dialogs -->
            <p:dialog
                header="#{text['logEntry.logEntryClassification.add.title']}"
                widgetVar="dlgLogEntryClassification" appendTo="@(body)" modal="true"
                dynamic="true" height="300" resizable="false"
                styleClass="custom-popup-xs" id="logEntryClassificationDialog">
    
                <h:form id="logEntryClassificationDialogForm">
                    <o:resourceInclude path="/common/messages.jsp" />
    
                    <div class="row">
                        <div class="col-sm-12 form-group">
                        <p:panel id="logEntryTypeRadioPanel" styleClass="no-style-panel">
                            <p:selectOneRadio id="logEntryTypeRadio"
                                value="#{eventLogDetails.logEntryClassification.logEntryType}"
                                converter="LogEntryTypeConverter">
                                <f:selectItem itemLabel="Kategoria zdarzeń"
                                    itemValue="LOG_ENTRY_CATEGORY" />
                                <f:selectItem itemLabel="Rodzaj zdarzenia"
                                    itemValue="LOG_ENTRY_TYPE" />
                            </p:selectOneRadio>
                            </p:panel>
                        </div>
                    </div>
    
                //some code
    
                </h:form>
            </p:dialog>
    
        </ui:define>
        </ui:composition>
    </html>
    

を入れ<p:selectOneRadio><p:panel>更新しようとしまし:logEntryClassificationDialogForm:logEntryTypeRadioPanelたが、結果は同じでした。

編集:私は何かをテストしましたが、これはある種のプライムフェイスのバグである可能性があります:最初の項目が選択されていることを設定しようとした場合にのみ機能しません。最初にもう 1 つ項目を追加した後、項目が選択されます (以下を参照)。何かご意見は?

<f:selectItem itemLabel="Rodzaj zdarzenia" itemValue="LOG_ENTRY_TYPE" />
<f:selectItem itemLabel="Kategoria zdarzeń" itemValue="LOG_ENTRY_CATEGORY" />
<f:selectItem itemLabel="Rodzaj zdarzenia" itemValue="LOG_ENTRY_TYPE" />

で動作し<h:selectOneRadio>ますが、使用する必要があります<f:selectOneRadio>

4

1 に答える 1

0

どうやらprimefacesのバグのようです。<p:selectOneRadio>フォームの最初の要素でない場合は機能します。ただし、(Tab キーを使用して) フォーカスしたときに最初の要素ではない場合でも、項目の選択が失われます。もう一度タブを押すと、選択が元に戻ります。<p:selectOneRadio>今のところ、追加する前に<p:focus for=someId>where someIdis inputText (の 2 番目の要素<p:dialog>)

于 2014-09-17T06:59:18.283 に答える