[英]Why Primefaces commandButton does not redirect to the page?
我將 primefaces 6.2 版與 jsf 和 trinidaad 結合使用。 在項目中,我有一個表格,每行包含一個按鈕,用於根據所選行將此頁面重定向到另一個頁面。 jsf 和 trindad commandLink 和 commandButton 可以完成這項工作,但 primefaces commandLink 和 command button 沒有。
我已經做了什么:
type="button"
immediate="true"
actionListener="#{coolingBean.view(row)}"
而不是action="#{coolingBean.view}"
。任何人都知道為什么以及我應該改變什么?
<p:column id="viewButtonColumn" exportable="false" style="text-align: center" >
<tr:commandLink textAndAccessKey="&view " id="viewButton" action="#{coolingBean.view}" styleClass="commandLinkMediumSmallFont" onclick="PF('bui').show()">
<tr:image source="/imgs/view.png" styleClass="commandLinkImageWithText"/>
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</tr:commandLink>
</p:column>
<p:column id="viewButtonColumn1" exportable="false" style="text-align: center" >
<h:commandLink textAndAccessKey="&view " id="viewButton1" action="#{coolingBean.view}" styleClass="ui-priority-primary" onclick="PF('bui').show()">
<i class="fa fa-search" ></i>
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</h:commandLink>
</p:column>
<p:column id="viewButtonColumn2" exportable="false" style="text-align: center" >
<p:commandLink value="View" id="commandLinkView" action="#{coolingBean.view}" styleClass="ui-priority-primary" onclick="PF('bui').show()">
<i class="fa fa-search" ></i>
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</p:commandLink>
</p:column>
<p:column id="viewButtonColumn3" exportable="false" style="text-align: center" >
<p:commandButton id="viewButton2" value="View" action="#{coolingBean.view}" icon="fa fa-search" immediate="true" type="button" onclick="PF('bui').show()">
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</p:commandButton>
</p:column>
內部托管 Bean
public String view(Row selectedRow) {
if(criteria == null)
criteria = new criteriaBean();
criteria.setNummer(selectedRow.getNummber());
searchBean.selectedId = selectedRow.getId();
//FacesContext.getCurrentInstance().getExternalContext().dispatch("view.jsp");
return view();
}
public String view(){
return"view';
}
這個實際上幫助了我。
基本上添加以下其中一項對我有用:
ajax="false"
添加到 commandButton?faces-redirect=true
附加到 url (例如return "view?faces-redirect=true';
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.