【发布时间】:2017-10-12 20:16:00
【问题描述】:
在 JSF2 中,我有一个这样的 XHTML:
<h:form id="myForm">
...
<c:forEach items="#{myController.header}" var="hd" varStatus="count">
#{hd}
<h:selectOneMenu value="#{myController.type[count.index]}" id="formtype" >
<f:selectItem itemValue="Nop" itemLabel="Nop" />
<f:selectItem itemValue="Yep" itemLabel="Yep" />
<f:ajax render="@form" />
</h:selectOneMenu>
#{myController.type[count.index]}
<h:selectBooleanCheckbox value="#myController.valid[count.index]}" id="valid">
<f:ajax render="@form"/>
</h:selectBooleanCheckbox>
#{myController.valid[count.index]}
</c:forEach>
...
</h:form>
我的托管 bean 有:
private String[] type;
private boolean[] valid;
我在第一次加载命名 bean 时初始化(type = new String[...]; 并为每个位置分配一个值)。
如果我修改组合或复选框,它可以工作,托管 bean 中的值会更改,并且新值会在 JSF 页面中打印(呈现)。但只有第一次。接下来的更改根本不会修改任何内容。这很奇怪,因为我在其他应用程序中有类似的代码并且工作正常,所以我做错了一些事情但找不到它。我的模板有一个h:header,我在 JS 控制台或 TomEE 中看不到任何日志(我只看到 .INFO - The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myApp]] after start() had already been called. The second call will be ignored,但我认为它不相关)。我曾尝试添加execute="@this"/execute="@form" 和其他未成功,并检查了this post 的所有要点,但似乎没有什么适用于我。
我没有看到什么错误?
编辑
@Named(value = "myController")
@ViewScoped
public class MyController implements Serializable {
...
我的模板中还有一个<h:messages globalOnly="true" showDetail="true" showSummary="true" />。
【问题讨论】:
标签: jsf-2