无法通过ajax请求更新视图

时间:2014-09-06 15:23:01

标签: ajax jsf richfaces

该方法在服务器端调用,字段在托管bean中更新,但视图不会更新。

<h:panelGroup id="grupoPergunta" rendered="#{gameController.view.mostrarPergunta}">
    <h:outputLabel id="pergunta" readonly="true" value="#{gameController.view.pergunta.descricao}" />
    <h:selectOneRadio styleClass="centro" value="#{gameControllerView.repostaEscolhida}">
        <f:selectItem itemValue="#{gameController.view.r1.alternativa}" itemLabel="#{gameController.view.r1.descricao}"></f:selectItem>
        <f:selectItem itemValue="#{gameController.view.r2.alternativa}" itemLabel="#{gameController.view.r2.descricao}"></f:selectItem>
        <f:selectItem itemValue="#{gameController.view.r3.alternativa}" itemLabel="#{gameController.view.r3.descricao}"></f:selectItem>
        <f:selectItem itemValue="#{gameController.view.r4.alternativa}" itemLabel="#{gameController.view.r4.descricao}"></f:selectItem>
        </h:selectOneRadio>
</h:panelGroup>
<!-- span onclick="sortearDado();"> Girar dado</span-->
<a4j:commandButton value="Pergunta" action="#{gameController.buscarPergunta()}" onclick="sortearDado();" render="grupoPergunta pergunta"/>

我也尝试使用<f:ajax>但没有效果。

1 个答案:

答案 0 :(得分:0)

我把内部渲染最多并在渲染中使用,它设法解决了我的问题

<a4j:outputPanel id="painelPergunta">
                        <h:outputLabel id="pergunta" readonly="true" value="#{gameController.view.pergunta.descricao}"  rendered="#{gameController.mostraPergunta}"/>
                        <h:selectOneRadio style="border:0px;" styleClass="centro" value="#{gameControllerView.repostaEscolhida}" rendered="#{gameController.mostraPergunta}">
                            <f:selectItem itemValue="#{gameController.view.r1.alternativa}" itemLabel="#{gameController.view.r1.descricao}"></f:selectItem>
                            <f:selectItem itemValue="#{gameController.view.r2.alternativa}" itemLabel="#{gameController.view.r2.descricao}"></f:selectItem>
                            <f:selectItem itemValue="#{gameController.view.r3.alternativa}" itemLabel="#{gameController.view.r3.descricao}"></f:selectItem>
                            <f:selectItem itemValue="#{gameController.view.r4.alternativa}" itemLabel="#{gameController.view.r4.descricao}"></f:selectItem>
                        </h:selectOneRadio>
                    </a4j:outputPanel>






<h:commandButton value="Pergunta2" onclick="sortearDado();">
        <f:ajax execute="@form" event="click" render="painelPergunta" listener="#{gameController.buscarPergunta()}"></f:ajax>
    </h:commandButton>