[英]How to make commandButton don't reload / refresh the page
實際上,我只有一個輸入,並且我想發送請求而無需重新加載頁面(可能是Ajax)。 我的代碼在下面,但是首先我要說我已經看到了這個問題,並且不能解決我的問題。
以下是我的代碼:
<h:form>
<div class="form-group">
<div class="col-md-10">
<h:inputText styleClass="form-control" id="disciplina" value="#{disciplinaMBean.nome}" valueChangeListener="#{disciplinaMBean.atualizarListagemPesquisa}">
<f:ajax event="keyup" render=":meuForm:minhaTabela"/>
</h:inputText>
</div>
<div class="col-md-2">
<h:commandButton value="Adicionar" styleClass="btn btn-md btn-success" action="#{disciplinaMBean.cadastrar}">
<f:ajax event="click" execute="@form" render=":meuForm:minhaTabela"/>
</h:commandButton>
</div>
</div>
</h:form>
“渲染”中的內容是更新頁面中的dataTable。
所以,我做錯了什么?
記住,我想要:
謝謝!
我在Google中進行搜索,找到了一些解決方案,因此我將所找到的答案用於自己的問題。
以下是我最新的代碼:
<h:form id="inserirDisciplina">
<h:inputText id="disciplina" value="#{disciplinaMBean.nome}" />
<h:commandButton value="Adicionar" action="#{disciplinaMBean.cadastrar}">
<f:ajax event="click" listener="#{disciplinaMBean.cadastrar}"/>
</h:commandButton>
</h:form>
如果您遇到相同的問題,則可能需要的是在listener
屬性內帶有#{yourBean.yourMethod}
的標記f:ajax
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.