簡體   English   中英

JSF Ajax調用不在上下文中

[英]JSF Ajax call is out of context

我有一個Facelet,它具有一個稱為"gameinfo"的div,通過單擊某個按鈕可以將該div重新加載Ajax。

問題:

該調用不起作用,它引發以下錯誤:

<f:ajax> contains an unknown id 'gameinfo' - cannot locate it in the context of the component dice

我不知道如何解決它,也許div需要靠近按鈕,或者也許只能使用ajax調用h:名稱空間中的元素?

碼:

            <div id="gameinfo" class="info">
                <h2>Spielinformationen</h2>
                <table summary="Diese Tabelle zeigt Informationen zum aktuellen Spiel">
                    <tr><th id="leaderLabel" class="label">F&uuml;hrender</th><td id="leader" class="data"><h:outputText value="#{spiel.getLeader()}" /></td></tr>
                    <tr><th id="roundLabel" class="label">Runde</th><td id="round" class="data"><h:outputText value="#{spiel.getRound()}" /></td></tr>
                    <tr><th id="timeLabel" class="label">Zeit</th><td id="time" class="data"><h:outputText value="#{spiel.getTime()}" /></td></tr>
                    <tr><th id="computerScoreLabel" class="label">W&uuml;rfelergebnis <em>Super C</em></th><td id="computerScore" class="data"><h:outputText value="#{spiel.getComputerScore()}" /></td></tr>
                </table>  
                <h2>Spieler</h2>
                <table summary="Diese Tabelle listet die Namen der Spieler auf">
                    <tr><th id="player1NameLabel" class="label">Spieler 1</th><td id="player1Name" class="data">Super Mario</td></tr>
                    <tr><th id="player2NameLabel" class="label">Spieler 2</th><td id="player2Name" class="data">Super C</td></tr>
                </table>          
            </div>

和Ajax調用:

            <div id="player" class="player">
                <h2 class="accessibility">W&uuml;rfelbereich</h2>
                <span class="accessibility">An der Reihe ist</span><div id="currentPlayerName">Super Mario</div>
                <h:form id="form">
                    <h:commandButton id="dice" alt="W&uuml;rfel mit einer Eins" image="resources/img/wuerfel1.png" action="#{spiel.dice()}" tabindex="4" title="W&uuml;rfel mit einer Eins">
                        <f:ajax render="gameinfo" />
                    </h:commandButton>
                </h:form>
            </div>

編輯:解決了! 我將<div>更改為<h:Panelgroup>並刪除了按鈕所在的<h:form>

<f:ajax應該指向一個JSF組件

更換

<div id="gameinfo" class="info">

<h:panelGroup layout="block" id="gameinfo" styleClass="info">

<h:panelGroup layout="block"將變成一個html div

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM