我有一个 JSF 绑定组件的问题。
我的 xhtml 页面有一个具有绑定属性的面板组。
<h:panelGroup binding="#{formularioBean.panelGroup}" layout="block" id="campoDinamico" />
烘焙豆中的代码是
public HtmlPanelGroup getPanelGroup() {
HtmlPanelGroup panelGroup = new HtmlPanelGroup();
Field field = new Field();
HtmlOutputText textoLabel = new HtmlOutputText();
textoLabel.setValue(JSFUtils.getStringFromBundle("formulario.label.TEXTO_1"));
textoLabel.setStyle("font-weight: bold; font-size: 12px");
field.getChildren().add(textoLabel);
int count = 0;
for (String textoParcial : this.listaTextoSugerencia) {
InputText input = new InputText();
input.setId("id_tx" + count);
input.setValue(textoParcial);
input.setImmediate(true);
count++;
field.getChildren().add(input);
}
panelGroup.getChildren().add(field);
}
下面以相同的形式,我有一个 primefaces 命令按钮
<p:commandButton value="Añadir" actionListener="#{formularioBean.addInputText}" update="campoDinamico"/>
我的问题是,当我单击此按钮时,bingind 组件会在调用 actionListener 之前调用其支持 bean 绑定方法。
我如何防止这种情况并在 actionListener 完成后更新?
我使用 primefaces 3.5、primefaces mobile 0.9.4、JSF 2 并且 Bean 是视图范围的
谢谢