• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Bean value not maintained in RequestScoped

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my project am using @ManagedBean, @RequestScoped. I am new for JSF. Am using 4 pages in my project. My problem was bean values not maintain in the second, third and fourth pages. In First page only bean values maintained properly. Could you please advise me how to solve this issue. I have copied some sample code for reference

@ManagedBean
@RequestScoped

public class ArticlePrepToolManagedBean implements Runnable, Serializable {
@ManagedProperty (value="#{param.jidName}")
private String jidName;
@ManagedProperty (value="#{param.aidName}")
private String aidName;

private List<com.elsevier.ArticlePrepTool.db.ItemZipContains> usabilityDetailList = null;

public String getAidName() {
return aidName;
}
public void setAidName(String aidName) {
this.aidName = aidName;
}
public String getJidName() {
return jidName;
}
public void setJidName(String jidName) {
this.jidName = jidName;
}

public List<ItemZipContains> getUsabilityDetailList() {
return usabilityDetailList;
}

public void setUsabilityDetailList(List<ItemZipContains> usabilityDetailList) {
ArticlePrepToolManagedBean.usabilityDetailList = usabilityDetailList;
}

}

Thanks for looking into this.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Maria,
as the name of the 'request scope' suggests, the bean lives only during a request. Then it's forgotten. You could use a view/session scoped bean. Then you cannot use #params, but can bind the textfields into the bean attributes directly. Another approach is to resend the parameters from each page, but it may create some security / consistency issues.
Carpe diem
Gabriel
 
maria edwin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gabriel Vince wrote:Hello Maria,
as the name of the 'request scope' suggests, the bean lives only during a request. Then it's forgotten. You could use a view/session scoped bean. Then you cannot use #params, but can bind the textfields into the bean attributes directly. Another approach is to resend the parameters from each page, but it may create some security / consistency issues.
Carpe diem
Gabriel



Thanks Gabriel. My project url is (http://localhost:8080/articlepreptool/) but input of my project is jidName=AEA and aidName=10663. that input given by some other web page that is if user trigger using the following link http://localhost:8080/articlepreptool/usability.jsf?jidName=AEA&aidName=10663.

Based on that input i fetched some data in my DB (using JPA) and list out that data in the first page. But if i goes to the next page all previous data stored in that list which i got from DB was cleared that is all list values and variables which set in the bean becomes null. That problem occurred only if i used the @ManagedProperty. I used @ManagedProperty to fetch the input values comes through url, because the input values of my project comes through other web page.

Is it possible to solve this issue, if i use the view/session scoped bean? Kindly advise me.
 
Gabriel Vince
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Maria,

I'm sending you a sample. Actually - view scoped beans are alive until you stay on the same view (page), so moving between pages you rather use session beans. I've created a session scoped bean:



and then I've created a JSF page with parameter mapping:


please note the metadata tag, it can be used in the faces-config.xml as well.

where page2 is as follows:



you can use a request scoped bean, but then you will have to have your parameters in hidden form fields in each of your pages. And Voila! It works too.

as well have a look at the JSF 2.0 - Bookmarability/View Parameters , there are some hints to process requests parameters too.

Kind regards
Gabriel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic