我正在使用 Primefaces 进行编程,我使用 p:wizard。
我有个问题。当我在第 1 步时,我可以访问所有变量,但是当我更改到第 2 步以生成 panelGrid 时,第 1 步中可用的变量现在在方法 createForm 中为空:
<p:wizard widgetVar="wiz">
<p:tab id="stepone" title="Step 1">
<p:panel>
<h:panelGrid >
<h:outputLink value="#" onclick="wiz.loadStep (wiz.cfg.steps [1], true)">next</h:outputLink>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="step2" title="Step 2">
<p:panel>
<h:panelGrid >
<h:panelGrid binding="#{ingresoBean.panelGrid}">
</h:panelGrid>
<h:panelGrid >
<h:outputLink value="#" onclick="wiz.loadStep (wiz.cfg.steps [0], true);">return</h:outputLink>
</h:panelGrid>
</p:panel>
</p:tab>
</p:wizard>
还有豆子:
List<Element> listElement;
private transient UIComponent panelGrid;
public IngresoBean() {
this.initForm();
}
public UIComponent getPanelGrid() {
if (panelGrid == null) {
panelGrid = createForm();
}
return panelGrid;
}
.....
public void setPanelGrid(UIComponent panelGrid) {
this.panelGrid = panelGrid;
}
public UIComponent createForm(){
//here the listElement isnull
for(SiacFrmdinamico campo:listElement){
....
}
}
public void initForm(){
...
// populate listElement
...
}