I am migrating from JSF1.2 to 2.1, I changed entries for beans in faces-config.xml to annotations. I try use @ViewScoped instead @RequestScoped and @ManagedProperties(To many params in few classes), but every time i click submit for my form bean with annotated as @ViewScoped is recreated. For @SessionScoped everything works correctyl.
I read few Q&A here, and This article, but i didn't force it to work.
I change JSTL tags to rendered atribute, or c:if with ui:param rendered.
in my web.xml i set params:
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>CLIENT</param-value>
</context-param>
I tried javax.faces.PARTIAL_STATE_SAVING = true, but didn't work too. With javax.faces.STATE_SAVING_METHOD = SERVER the same problem.
I removed tags handler for test, but it didn't help too.
In project is used: Mojarra 2.1.13, hibernate 3.6, spring 3.1(far as i know updated form 2.x by my predecessor), acegi-security-1.0.5, tomahawk20, urlrewrite-3.2.0.
I use tomcat 6
EDIT:
This is my bean: package my.package;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import my.package.MyOtherBean;
@ManagedBean(name="someNameBean")
@ViewScoped
//@SessionScoped
public class MyBean extends MyOtherBean {
public MyBean(){
super();
//XXX
System.out.println("-->> someNameBean is being created");
}
}
package my.package;
@ManagedBean(name="someNameMyOtherBean")
//@ViewScoped
@SessionScoped
public class MyOtherBean extends BaseBean {
private ClassWithFormFields dataIn; //getter & setter exist
//a lot of code here
}
Example use of bean
<h:selectOneMenu value="#{someNameBean.dataIn.currencyId}" id="currencyId" tabindex="2" >
<f:selectItems value="#{someNameBean.dataIn..availableCurrencies}"/>
</h:selectOneMenu>
Update serviceLocalizator is managed by Spring xml files ans JSF annotation
@ManagedBean
public class BaseBean implements Serializable {
private static final long serialVersionUID = 1L;
protected transient Logger log = Logger.getLogger(this.getClass());
@ManagedProperty(value="#{serviceLocalizator}")
protected transient ServiceLocalizator serviceLocalizator;
//few more lines
}
Update 2: It's My fault. Thanks for @kolossus that he the indicated direction. I i was looking for answer and I found and read BalusC article And now i now, i shouldn't return string in backing bean action. With null instead string it works. I badly understood concept of a view, I thought that ViewSoped bean id live as long as tab/windows is the same. Now i know that is it JSF View. I'am sory for a trouble.
Maybe is a way to use @ViewSoped with redirect to new page?