• Post Reply Bookmark Topic Watch Topic
  • New Topic

myfaces-impl-1.1.3 instantiates the request scope bean  RSS feed

 
Elliot Khazon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
myfaces-impl-1.1.3 instantiates the request scope bean every request (like it suppose to), however it doesn't retain any state information about the bean even though t:saveState tag is specified.
When I use myfaces-impl it works just fine.
Here is how i use the bean.

Bean.java
---------------
private String value = "";
private int number = 0;
public Bean() {

}


getValue() {
return value;
}


setValue (String v) {
value = v;
.
.
.
initBean (int n)
number= n;
}


page.jsp
------------
<f:view>
<%
int number = req.getParameter ("number");
if (number != INVALID_VALUE) {
//if value wasn't invalid then init the bean

FacesContext facesCtxt = FacesContext.getCurrentInstance();
VariableResolver variableResolver = facesCtxt.getApplication().getVariableResolver();
Bean myBean = (Bean) variableResolver.resolveVariable(
facesCtxt, "Bean" );

myBean.initBean (number);
}
%>


<t:saveState id="Bean" value="#{Bean}">
.
.
.
.

</f:view>

faces-config.xml
-------------------------
<?xml version="1.0"?>

<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config>
.
.
.
<managed-bean>
<managed-bean-name>Bean</managed-bean-name>
<managed-bean-class>com.mypackage.Bean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
.
.
.
</faces-config>

Thanks in advance,

Elliot
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you doing...



 
Elliot Khazon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Application has some jsf and non-jsf pages on it. when the transition is done from a non-jsf page to jsf page a number is passed to initialize all the DB persistent objects. Basically the non-jsf page has a table with things to edit and every entry in the table has an id (number). When user clicks on the item to edit the request is sent with this parameter via URL string. The receiving page (jsf page) extracts the parameter and initilizes the model with data from database. The way it used to work before is that all the initilized objects in the bean were retained using the state tag. However now it is not.
 
Elliot Khazon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To expand on the issue: the reason why is because the value is collected by a javascript function which then posts to the form (that is a form inside jsf file)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!