gpt4 book ai didi

java - 以丰富的方式显示 bean 值 :popupPanel

转载 作者:太空宇宙 更新时间:2023-11-04 15:23:59 24 4
gpt4 key购买 nike

我有一个 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,并且弹出窗口按预期打开。但弹出窗口显示了创建 View 时 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();" />

小心:如果您有 <h:form>在 popupPanel 内,重新渲染完整的弹出窗口时可能会遇到问题。将所有内容放入 <h:panelGroup>在表单内,然后重新渲染该表单。

关于java - 以丰富的方式显示 bean 值 :popupPanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20058058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com