• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to get session scope backbean

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created on backbean which is define as a session scope backbean in face_config.xml.

Now how can retrieve this session bean's object? Which API I can use to get this session bean's Object?

Thank a lot in advance.
 
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread may help you.

Link to page
 
Sam Sunamin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Himanshu,

Thank you very much for your reply. However, the link didn't have an exact answer.

Do you have any other link to solve this out?
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code should do it.
 
Saloon Keeper
Posts: 28429
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The session bean is the object. JSF doesn't use magical constructs for managed beans. Managed Beans are just ordinary POJOs that are managed by the JSF framework.

So to get the session bean in non-JSF code (such as a servlet), just use the HttpServletRequest.getSession().getAttribute("beanname"); code construct and to get the session bean in JSF code, use JSF's faces-config.xml to inject it into the bean that references the session object.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys... I rearly sufferd with getting jsf frame work handled bean object refernce. But i got the solution. Hope it will usefull to all.
To get that reference object you have to manitain the <managed-bean> as applicaton scope


public class Report {

Report report;
int count;

public void updateCount()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ValueBinding vlBinding = app.createValueBinding("#{report}");
Report uObj = (Report) vlBinding.getValue(facesContext);
uObj.setCount(uObj.getCount() + 1);
}
}

Can send feedback to [email protected]
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic