[英]<rich:popupPanel buttons not working in JSF Project
[英]Show bean values in rich:popupPanel
我有一個rich:dataTable,並且喜歡在用戶單擊詳細信息按鈕時在rich:popupPanel中的每一行顯示詳細信息。
我這樣做
<h:panelGrid columns="3" columnClasses="titleCell">
<h:form id="form">
<rich:dataScroller for="table" maxPages="5" />
<rich:dataTable value="#{tournSelectionBean.tournaments}"
var="tourn" id="table" rows="10">
<rich:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{tourn.name}" />
</rich:column>
<rich:column>
<a4j:commandButton value="Detail"
action="#{tournSelectionBean.setCurrentTournament(tourn)}"
render=":detailpopup"
oncomplete="#{rich:component('detailpopup')}.show();" />
</rich:column>
</rich:dataTable>
<rich:dataScroller for="table" maxPages="5" />
</h:form>
</h:panelGrid>
<rich:popupPanel id="detailpopup" modal="true" resizeable="false"
autosized="true">
<f:facet name="header">
<h:outputText value="#{tournSelectionBean.currentTournament.name}" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('detailpopup')}.hide(); return false;">
</h:outputLink>
</f:facet>
<h:panelGrid columns="2" columnClasses="titleCell">
<h:outputLabel value="City" />
<h:outputLabel
value="#{tournSelectionBean.currentTournament.city}" />
</h:panelGrid>
<a href="#" onclick="#{rich:component('detailpopup')}.hide()">Close</a>
</rich:popupPanel>
setPropertyActionListener正確設置了ID,並且彈出窗口按預期方式打開。 但是彈出窗口會顯示創建視圖時在bean中的錦標賽的詳細信息(而不是由propertyactionlistner設置的視圖)。
我該如何實現?
編輯:更新了上面的代碼並添加了Bean:
@Named("tournSelectionBean")
@ViewScoped
public class TournamentSelectionBean implements Serializable {
@EJB
private TournamentControllerInterface tournamentController;
private List<Tournament> tournaments;
private Tournament currentTournament;
@PostConstruct
public void init() {
tournaments = tournamentController.loadTournaments(true, false);
}
/**
* @return the tournaments
*/
public List<Tournament> getTournaments() {
return tournaments;
}
/**
* @param tournaments
* the tournaments to set
*/
public void setTournaments(List<Tournament> tournaments) {
this.tournaments = tournaments;
}
/**
* @return the currentTournament
*/
public Tournament getCurrentTournament() {
return currentTournament;
}
/**
* @param currentTournament the currentTournament to set
*/
public void setCurrentTournament(Tournament currentTournament) {
this.currentTournament = currentTournament;
}
}
您需要告訴JSF重新呈現彈出窗口html,然后再打開它:
<a4j:commandButton value="Detail"
action="#{tournSelectionBean.setCurrentTournament(tourn)}"
render=":detailpopup"
oncomplete="#{rich:component('detailpopup')}.show();" />
注意:如果popupPanel中有一個<h:form>
,則在重新渲染整個彈出窗口時可能會遇到問題。 將所有內容放入表單內的<h:panelGroup>
,然后重新呈現該內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.