I am developing a JSF 2.1 project. I am using primefaces 3.5 components. There are two managedbean with viewscoped, WizardBean and CreateInputBean. They are used in wizard component(primefaces). The last point first wizard, I click a button then dialog is opened. There is also wizard in dialog. Here with CreateInputBean a instance of domain object is created. After a instance created again when dialog is opened, there are information last instance because CreateInputBean is life. I want to destroy CreateInputBean with ViewScoped without going another page.
I tried these but they are not working.
@ManagedBean(name = "cbean")
@ViewScoped
public class CreateInputBean {
public void addUsage() {
...
FacesContext.getCurrentInstance().getViewRoot().getViewMap().remove("#{cbean}");
or
FacesContext.getCurrentInstance().getViewRoot().getViewMap().remove("cbean");
}
}
<p:wizard flowListener="#{wizard.onFlowProcess}">
<p:tab id="personal" title="Kullanıcı ile ilgili bilgiler">
...
</p:tab>
<p:tab id="confirm" title="Kullanım Verileri">
<p:panel style="height: 600px;">
<p:dataTable id="liste" value="#{ubean.usages}" var="usage">
...
</p:dataTable>
<p:commandButton value="Ekle" onclick="dlg.show();" type="button" />
</p:panel>
<p:dialog header="Usage Ekleme" widgetVar="dlg" showEffect="fold"
hideEffect="fold" height="600" width="600">
<p:wizard flowListener="#{cbean.onFlowProcess}">
<p:tab title="Servis Tipi">
...
</p:tab>
<p:tab title="Kullanim Tipi">
...
</p:tab>
<p:tab title="İşlem Süresi/Adedi/Miktarı">
<p:panel style="height: 500px; width: 500px;">
<h:panelGrid columns="2">
<p:outputLabel value="Term:" />
<p:inputText value="#{cbean.term}" />
<p:commandButton value="Save"
actionListener="#{cbean.addUsage}" oncomplete="dlg.hide()"
update="liste" />
</h:panelGrid>
</p:panel>
</p:tab>
</p:wizard>
</p:dialog>
</p:tab>
</p:wizard>
@RequestScoped
andELFlash
to store transient data between ajax requests – kolossus