简体   繁体   English

JSF Ajax调用不在上下文中

[英]JSF Ajax call is out of context

I have a Facelet which has a div called "gameinfo" , by clicking on a certain button this div should be reloaded with Ajax. 我有一个Facelet,它具有一个称为"gameinfo"的div,通过单击某个按钮可以将该div重新加载Ajax。

Problem: 问题:

The call does't work, it throws the following error: 该调用不起作用,它引发以下错误:

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

I don't know how to fix it, maybe the div needs to be nearer the button, or maybe only elements in the h: namespace can be called with ajax? 我不知道如何解决它,也许div需要靠近按钮,或者也许只能使用ajax调用h:名称空间中的元素?

Code: 码:

            <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>

And the Ajax Call: 和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>

Edit: solved! 编辑:解决了! I changed the <div> into <h:Panelgroup> and deleted the <h:form> in which the button was. 我将<div>更改为<h:Panelgroup>并删除了按钮所在的<h:form>

<f:ajax should point to a JSF component <f:ajax应该指向一个JSF组件

Replace 更换

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

With

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

<h:panelGroup layout="block" will turn into a html div <h:panelGroup layout="block"将变成一个html div

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM