1

My JSF backing bean is ViewScoped.
Since I've added another action listener, the bean gets re-created even the view hasn't changed.

@ManagedBean (name="EncryptionBean")
@ViewScoped
public class EncryptionBean extends ClientBeanBase implements Serializable, ActionListener 
{
    .
    .
    .

    @Override
    public void processAction(ActionEvent arg0) throws AbortProcessingException 
    {
       refresh();
    }
}

HTML

<p:commandButton value="OK" type="submit" actionListener="#{FileSelectBean.actionOk}" oncomplete="dlgFileSelect.hide();" update=":formEncryptionDialog,:formTranscodingPage:streamInfoId" styleClass="buttonOK">        
    <f:actionListener type="com.company.rews.webclient.beans.EncryptionBean" />
</p:commandButton>

When I press OK button, I wouldn't expect that the bean is created again since it is ViewScoped, however it gets re-created (constructor called) and I loose some variables. When I remove the <f:actionListener> line, the been is not re-created on OK.

What should I do?

Danijel
  • 8,198
  • 18
  • 69
  • 133

1 Answers1

1

Found the answer here: Session scoped managed bean and actionListener

Instead of type one needs to use binding:

<f:actionListener binding="#{BackingBean}"/>
Community
  • 1
  • 1
Danijel
  • 8,198
  • 18
  • 69
  • 133