[英]Primefaces - update datatable with commandButton doesn't work
[英]PrimeFaces commandButton doesn't navigate or update
我正在使用 Primefaces 使我的應用程序更漂亮一點。 我注意到p:commandButton
和h:commandButton
工作方式不同。
p:commandButton
調用該方法並且沒有其他事情發生。 h:commandButton
調用該方法並返回導航。
使用p:commandButton
時按下登錄按鈕后重定向時遇到問題。 怎么處理?
我確實有一個更新參數:
<p:commandButton value="Login" action="#{login.login}" type="submit" update="msgs" />
<p:commandButton>
需要以下其中一項才能正常工作:
update
屬性(對於 AJAX 請求)ajax="false"
進行正常的非 ajax 提交。如果兩者都沒有,則該按鈕默認會執行沒有 UI 反饋的 AJAX 請求。
此外,當周圍的<h:form>
具有enctype
屬性時,我遇到了兩個選項都不起作用的問題。
我認為 Cagatay ment 是:
不導航頁面:
<p:commandButton action="home.xhtml" value="Go Home"/>
作品(重定向頁面):
<p:commandButton action="home.xhtml?faces-redirect=true" value="Go Home"/>
有效(重定向頁面)
<p:commandButton action="home?faces-redirect=true" value="Go Home"/>
如果 .xhtml 是您在 web.xml 中定義的默認后綴:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
更多信息可以在 primefaces 論壇中找到,例如在這個關於導航的討論中
我希望這有點幫助...
如果您正在進行導航並且請求是使用 ajax 完成的,則必須使用重定向。
我有個類似的問題。
我正在使用 primefaces 和 primefaces mobile,並且在使用<p:commandButton>
和 ajax="false" 和 action="find.xhtml?faces-redirect=true" 時,Firefox 中的導航失敗。
我可以讓它在 Firefox 中工作的唯一方法是使用<h:commandButton>
:
<h:commandButton value="#{msg.find}" process="find"
action="find.xhtml?faces-redirect=true" />
上述解決方案都不適合我。 你仍然可以使用簡單的 javascript
<p:commandButton onclick="window.location.href =home.xhtml"
style="height: 20px" type="button" title="title" icon="ui-icon-transferthick-e-w"/>
<h:commandButton
styleClass="btn btn-primary-active upgrade" data-dismiss="modal"
value="Upgrade Account"
action="profile.do?faces-redirect=true&tab=plan"
oncomplete="$('#freeGiftModal').hide();" process="@this" partialSubmit="true" immediate="true"/>
我使用命令按鈕導航到個人資料頁面,它對我來說工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.