I'm programming with Primefaces a I use p:wizard.
I have a problem. When I´m on step 1 I have access to all my variables, but when I change to step 2 to generate the panelGrid, the variables that were available on step 1 are now empty in the method 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>
And the bean:
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
...
}
From the documenation:
To begin with create your backing bean, it's important that the bean lives across multiple requests so avoid a request scope bean. Optimal scope for wizard is viewScope.
Basically, annotate your class with @ViewScoped
and make sure your wizard is within <f:view>
tags.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.