2

私はrichfacesのstrageの振る舞いに出くわしました。私のビュー構造に関する背景:

  • これは主<rich:extendedDataTable>に、行をクリックするとその行に関する情報が表示される場所です。<a4j:outputPanel>

  • また、各行には、「作成」、「編集」などの項目を含むコンテキストメニューがあります。<rich:popupPanel>

コンポーネントの構造は次のとおりです。

<h:panelGrid columns="2">
    <h:column>
        <rich:dataScroller for="testTable" maxPages="7"/>
        <rich:extendedDataTable id="testTable" value="#{testController.items}" rendered="#{testController.items.rowCount != 0}"
        selection="#{testController.selectedRow}" noDataLabel="No results to show" var="test" rows="20"
        style="width: 790px" selectionMode="single">

            <a4j:ajax execute="@form"
                event="selectionchange" 
                listener="#{testController.selectionListener}"
                render=":res"/>

            {columns to display}

        </rich:extendedDataTable>
    </h:column>

    <a4j:outputPanel id="res">
        <rich:panel header="Selected Rows:" rendered="#{not empty testController.selectedRows}">
            <rich:list type="unordered" value="#{testController.selectedRows}" var="t">
                <h:outputText value="#{t.name}"/>
                <br/>
                <h:outputText value="#{t.details}" converter="#{testConverter}"/>
            </rich:list>
        </rich:panel>
    </a4j:outputPanel>
</h:panelGrid>

<rich:contextMenu target="testTable" mode="ajax" id="contextMenu">
    <rich:menuItem label="Edit" render="popupEdit" oncomplete="#{rich:component('popupEdit')}.show();" mode="ajax"/>
</rich:contextMenu>

<rich:popupPanel id="popupEdit" modal="true" autosized="true" resizeable="false" moveable="false" domElementAttachment="form">
    <rich:hotKey key="esc" onkeyup="#{rich:component('popupEdit')}.hide(); return false;"/>
    <f:facet name="header">
        <h:outputText value="Edit Test"/>
    </f:facet>
    <f:facet name="controls">
        <h:outputLink value="#" onclick="#{rich:component('popupEditar')}.hide(); return false;">
            <h:graphicImage value="/resources/css/images/fechar_janela.png" width="20" height="20"/>
        </h:outputLink>
    </f:facet>

    <h:panelGrid id="popupEditContent" columns="2">
        ... {display of info}

            <a4j:commandButton value="Salvar" actionListener="#{testeController.update()}" render="tabelaTestes, contextMenu"/>
            <h:panelGroup id="messagePanel" layout="block">
                <rich:messages ajaxRendered="true" />
            </h:panelGroup>
    </h:panelGrid>
</rich:popupPanel>

そして今、奇妙な振る舞い(NetBeansを使用):

  • NetBeansからアプリをデプロイします。
  • デプロイされたプロジェクトのURLをブラウザ(Firefox)で開きます。テーブルの<a4j:ajax>インライン化は機能しません。これは、「testController.selectionListener」が呼び出されず、詳細が表示されないためです(currentバッキングBeanに属性を設定します)。contextMenuは機能しますが、popupPanelはすべてのフィールドにnullまたは空のプロパティを表示します(current属性は設定されていません)。
  • IDEに戻り、すべての<rich:popupPanel>セクションを削除してファイルを保存します。
  • ブラウザに戻り、F5キーを押して行をクリックします。これで、<a4j:ajax>作業と呼び出しがtestController.selectionListener行われ、の詳細が表示され<a4j:outputPanel>ます。コンテキストメニューは機能しますが、(明らかに)パネルはポップしません。
  • IDEで、セクションを元に戻し、<rich:popupPanel>ファイルを保存します。
  • ここでページを再度更新すると、すべてが機能し、詳細が表示され、[編集]ポップアップに選択した行の正しい情報が表示されます。

セクションなしでデプロイしようとしました<rich:popupPanel>が、selecionListenerが呼び出されます。<a4j:ajax>問題は、とセクションの両方を含むページをデプロイすることであると思います<rich:popupPanel>。したがって、「競合」です。

  1. 私はrichfacesショーケースから構造を取り、変更を加えました。ショーケースでは、はタグ<rich:popupPanel>の外側に<h:form>配置され、プロジェクトではtemplate.xhtmlに配置されていることに気付きました(トップメニューページが機能するように)。この配置が原因でエラーが発生した可能性はありますか?

  2. これはrichfacesプロジェクトにファイルするバグと見なすことができますか、それとも何かが足りませんか?

  3. 回避策または解決策はありますか?

どうもありがとうございます!

4

1 に答える 1

1

私はそれを解決したと思います。idtemplate.xhtmlのタグで属性を「form」に設定した<h:form>ので、次のようになります。

<h:body>
    <h:form id="form">
        <div id="top" class="top">
            <ui:insert name="top">Top</ui:insert>
        </div>
        <div id="content" class="center_content">
           <ui:insert name="content">Content</ui:insert>
        </div>
    </h:form>
</h:body>

これが私が行った唯一の変更であり、すべてのコンポーネントが最初のデプロイ後に機能するようになりました。

編集:別の問題を検索するときに解決策を見つけました:seconクリックでのJSFアクション呼び出し

于 2012-10-11T12:42:18.270 に答える