我使用 p:repeat
创建滑雪者列表
<p:repeat value="#{skiingBean.listSkierCompetitionsByRefCompetition(competition.competitionId)}" var="skier">
<hr />
<h:panelGrid columns="2" style="width:100%">
<p:column>
<h:outputLink value="DisplayImage?Image_id=#{skier.skier.photo.photoId}" target="_blank" >
<h:graphicImage value="DisplayImage?Image_id=#{skier.skier.photo.photoId}" width="50" height="50"></h:graphicImage>
</h:outputLink>
</p:column>
<p:column>
<h:panelGrid columns="2" style="width:100%">
<h:outputText value="Name: " style="color:#000000;font-size: 11px;display: flex"/>
<h:outputText value="#{skier.skier.skierFullName}" style="font-size: 10px;display: flex"/>
<h:outputText value="Profession: " style="color:#000000;font-size: 11px;display: flex"/>
<h:outputText value="#{skier.skier.skierProfession}" style="font-size: 10px;display: flex"/>
<h:outputText value="Score: " rendered="#{competition.status.statusId == 1}" style="color:#000000;font-size: 11px;display: flex"/>
<p:spinner id="aaa" value="#{skiingBean.skierScore}" style="font-size: 10px;display: flex;width : 150px; height:25px" />
<p:commandButton value="Give Score"
ajax="false" update="@all"
actionListener="#{skiingBean.giveScore(skiingBean.skierScore, skier.skier.skierId, competition.competitionId)}"/>
</h:panelGrid>
</p:column>
</h:panelGrid>
</p:repeat>
方法 giveScore 是:
public void giveScore(int score, int skierId, int competitionId)
{
SkierCompetition sc = new SkierCompetition();
sc = eDao.findSkierCompetitionssByRafSkierAndRefCompetition(skierId, competitionId);
sc.setSkierCompetitionScore(score);
eDao.updateSkierCompetition(sc);
}
我的问题是,如果我将分数添加到第一个或第二个滑雪者并且点击“给予分数”按钮后,我获得了一个空值。 但是,当我影响到最后一名滑雪者的分数时,没关系,我得到了像Screenshot那样的分数。
请你解决这个问题。非常感谢。