0

I have strange problem on my simple form in JSF 2.0. In this form, I use two selects, if the first select is chosen, the second should be reload with new options. I use the same mechanism as on Primefaces demo page : Primefaces demo page. My bean is @ViewScoped. I also run my app on jetty-maven plugin by "mvn jetty:run". No problem so far. My form works well.

The problem occurs when I change something while my server is running, jetty is reloading. And after that these two selects don't work - if I choose option on the firts one, second one isnt responding. I have to clear all session by logout in Spring Security and after that my form come back to work.

When i changed my bean to @SessionScoped, problem disappeared. Is this working proper? I dont want to have my form on session scoped, I prefer ViewScoped.

Cichy
  • 1,319
  • 3
  • 20
  • 36

1 Answers1

1

Try to check your context is postback like this on postConstruct in your bean.

@PostConstruct
public void init() {
    if (!FacesContext.getCurrentInstance().isPostback()) { 
        //Write your code here...
    }

Or try close to partial state saving on your web.xml if jsf version is 2.0, but with this method, your application may need more memory allocation

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>

Good Luck!

gokhansari
  • 2,379
  • 1
  • 27
  • 33