我正忙着将参数playerName和clubName发送到forEach循环。使用commandButton正确发送它们,所以我确信它们中有值。但似乎他们没有及时评估forEach ???如您所见,变量未保存在bean中。
<h:panelGrid columns="2">
<h:outputText value="Spelare"></h:outputText>
<h:selectOneMenu id="playerMenu" value="#{playerName}">
<f:selectItems value="#{serviceHCP.allPlayers}" />
</h:selectOneMenu>
<h:outputText value="Klubb"></h:outputText>
<h:selectOneMenu id="ClubMenu" value="#{clubName}">
<f:selectItems value="#{serviceHCP.clubs}" />
</h:selectOneMenu>
</h:panelGrid>
Players
<c:forEach var="list" items="#{serviceSeries.getSeriesForPlayer(clubName, playerName)}">
<--- More code --->
</c:forEach>
<h:commandButton value="Spara" action="#{serviceHCP.saveSerieTotal(clubName, playerName, serieName, noSeries, serie) }"></h:commandButton>
答案 0 :(得分:0)
JSTL标记不是组件,因此它们不会涉及每个阶段。
考虑这个视图片段:
<c:forEach var="_foo" items="#{bar.list(baz)}" />
<h:form>
<h:inputText value="#{baz}" />
<h:commandButton value="foo" />
</h:form>
绑定到这个bean:
@ManagedBean
@RequestScoped
public class Bar {
public List<String> list(String baz) {
PhaseId phase = FacesContext.getCurrentInstance()
.getCurrentPhaseId();
System.out.println(phase + " " + baz);
return Collections.emptyList();
}
}
list方法在调用时打印出当前生命周期阶段及其参数。当我输入一个值并提交表格时,它会打印在服务器日志中:
INFO: RESTORE_VIEW 1
INFO: RENDER_RESPONSE 6 hello
JSF servlet接收字段值作为参数。在更新模型值阶段之前,它不会被推入模型(此处为请求范围)。如果某些内容导致生命周期快捷方式渲染响应(如验证失败),则根本不会发生这种情况。
<强> TL; DR 强>
了解表达式的评估时间和频率。