This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes myfaces-impl-1.1.3 instantiates the request scope bean  Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "myfaces-impl-1.1.3 instantiates the request scope bean  " Watch "myfaces-impl-1.1.3 instantiates the request scope bean  " New topic
Author

myfaces-impl-1.1.3 instantiates the request scope bean

Elliot Khazon
Greenhorn

Joined: Jun 28, 2006
Posts: 3
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

Joined: Jul 11, 2001
Posts: 15230

Why are you doing...



Elliot Khazon
Greenhorn

Joined: Jun 28, 2006
Posts: 3
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

Joined: Jun 28, 2006
Posts: 3
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)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: myfaces-impl-1.1.3 instantiates the request scope bean
 
Similar Threads
JSF Dependency Injection inheritence issue
Error: Target Unreachable, identifier 'StoreNameBean' resolved to null
Resolved: Error getting property; first JSF attempt
The requested resource (Servlet Faces Servlet is not available) is not available.
illegalArgumentException