Session scoped beans other than SessionBean1

Let's say I want to provide a logout action. I can end the session by using the below in my logoutButton_action method:
try {
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
session.invalidate();
this.getExternalContext().redirect("Page1.jsp");
} catch (Exception e) {
log("Logout exception: " + e.getMessage());
I would not have been able to figure out even that much if it wasn't for this forum. BUT, what about if I have other managed beans (i.e. just plain classes registered in managed-beans.xml) that have session scope, such a class to a hold a logged-in user's details during the session. How do I destroy that when the user logs out?

{color:#333399}*hi*
you can set any Object in ur sessionBean1 to be NULL,, by this way , ur session will hold no more data.
{color}

Similar Messages

  • Using Query String Parameters with Session Scoped bean

    I would like to pass query string parameters from a product page (user clicks on a specific product commandLink) that is request scope to a details page that is session scoped.
    The problem is that the session scoped page only handles the first request. If you view the details of a product and then navigate back to the product page and choose another product ... the details page will not handle the new query string parameters and display the details for the first product chosen.
    Is there a way to make the session scoped bean recognize the query string parameters past the first request?

    I was able to replicate this problem with a very simple app that performs a redirection... just like the real app. Here's the simple app that I put together:
    From request scope page:
    <f:view>
             <h:form>
               <h:commandButton value="Link 1" action="#{reqbean.Link1}"/>
               <br/><br/>
              <h:commandButton value="Link 2" action="#{reqbean.Link2}"/>
            </h:form>
           </f:view>
    From request scope bean:
    public String Link1() throws IOException
        // Add event code here...
        //redirect the user
        FacesContext.getCurrentInstance().getExternalContext().redirect("untitled2.jspx?p=1");
        return null;
      public String Link2() throws IOException
        // Add event code here...
        //redirect the user
        FacesContext.getCurrentInstance().getExternalContext().redirect("untitled2.jspx?p=2");
        return null;
      }At this point... I put a println in the constructor of the session scoped bean because this is where I want to get the query string params. The constructor only gets called the first time a redirect is performed.

  • Add FacesMessage to FacesContext in an session scoped bean HOWTO?

    I have an simple question. How can I add an FacesMessage to the FacesContext in a session scoped bean.
    This code works fine for request scoped beans.
    String message = "Some message";          
    FacesMessage curentMessage = new FacesMessage(message, message);
    curentMessage.setSeverity(FacesMessage.SEVERITY_ERROR); //Mark as ERROR
    context.addMessage(�userForm�, curentMessage);          When I change bean scope to "session" I am getting java.lang.IllegalStateException at the last line when adding message to context.
    Thanks:
    -- Nermin

    I have an simple question. How can I add an
    FacesMessage to the FacesContext in a session scoped
    bean.
    This code works fine for request scoped beans.
    String message = "Some message";          
    FacesMessage curentMessage = new FacesMessage(message,
    message);
    curentMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
    //Mark as ERROR
    context.addMessage(�userForm�, curentMessage);          When I change bean scope to "session" I am getting
    java.lang.IllegalStateException at the last line when
    adding message to context.
    Thanks:
    -- NerminHow do you get "context"? If you are storing it as an instance variable of the bean, then you
    should expect to get an exception. The FacesContext is scoped only to one request. Instead
    of storing it in the bean, use FacesContext.getCurrentInstance() each time you need to use it.

  • NullPointerException When trying to Get Session Scoped Bean data in another ManagedBean

    hello
    i wont to access to some data in my session scoped bean from a request bean so when i try to get this data all i get is 
    com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection
    on managed bean «discussionlaoder»
    in the end of the exception there is
    Caused by: java.lang.NullPointerException at Hiber.discussionlaoder.init(discussionlaoder.java:35)
    this is my code:
    1-the request scoped bean
    @ManagedBean
    @RequestScoped
    public class discussionlaoder {
      private MyadmninHelper halper;
    @ManagedProperty(value="#{serviceBean}")
         private ServicesBean  serviceBean;
        @PostConstruct
        public void init() {
          halper=getServiceBean().getHalper();  // line 35
    //seter and geter code
    2-the sesions scoped bean
    @ManagedBean (eager=true)
    @SessionScoped
    public class ServicesBean {
        private MyadmninHelper halper;
    //seter and geter code
    am using glassfish server 3.1
    thank's for help

    What you need to do is fix all those typos in your code, then you don't have to override names.
    - the proper Java class name is DiscussionLoader, not discussionlaoder (fix english typo also)
    - if you want to inject a class named ServicesBean, then also call the property the same.
    @ManagedProperty
    public ServicesBean servicesBean;
    But what you're doing now is call the class 'ServicesBean' and then in your managed bean declaration you seem to change your mind and it should all of a sudden be 'serviceBean'. Well then rename the class so you don't have your typo anymore!

  • Are session-scoped beans singleton

    Hi all, I miss something in the bean lifecycle within JSF. Assume that a page action navigates toward another page, linked to a session-scoped bean: this is created for the duration of this session. Then a button leads back to the original page, so that another action will lead to another page with its associated bean. Is this a new bean or the previous one ?
    This question is linked to the topic of bean dependencies through managed properties: it works fine, but since a bean is declared per class and not per instance, I miss the overall instantiation philosophy.

    Once the bean is created the first time in session, it will not be created again (until the session dies and you attempt to access the bean again of course).
    So in your scenario, the first time you access the page the bean gets created. When you go back and then go forward to the page again, a new bean is not created. The originally created one is re-used. Which means the constructor is not called again.
    CowKing

  • Spring framework - Error with session scoped Beans

    Hello guys,
    I'm trying execute my Java Application inside Netweaver Application Server, but I'm having problems with serviceBeans with scope session. Anyone have already used Spring with session scope?
    Thanks,
    Cleiton.

    After many attempt, when I declared the bean with <aop:scoped-proxy  /> it works, however it could cause performance problem. I don't need refer this bean by another singleton bean, i did a wrong configuration in order to make a work a round...
    When I run my application on tomcat server, the DWR starts perfectly the "session scope bean form IOC container", but in the WEBAS maybe it's running in other thread. Is it possible?
    Anyone had a problem like this?
    I got a detailed error with log4j,
    ERROR Application [1] org.directwebremoting.impl.DefaultCreatorManager - Error loading class for creator 'SpringCreator[CounterSpringFacade]'.
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'counterSpringFacade': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:312)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
         at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
         at org.directwebremoting.spring.SpringCreator.getInstance(SpringCreator.java:145)
         at org.directwebremoting.spring.SpringCreator.getType(SpringCreator.java:107)
    Edited by: Cleiton dos Santos Garcia on Jan 7, 2009 5:02 PM

  • Create session scoped bean in servlet?

    I am working on a log in porgram for a jsp page using servlet.
    I need to create a bean in that servlet after user enter correct username and password, and the bean must have scope of session.
    How do I do this?
    How do I control the scope of variables in a servlet?
    thank you

    come on people! i just answered this 2 minutes ago! search the forums first! or a servlet book.
    servlet...
    Bean bean = new Bean();
    bean.setValue("value");
    request.getSession().setAttribute("bean", bean);
    jsp...
    <jsp:useBean id="bean" class="Bean" scope="session" />
    <%= bean.getValue() %>
    OR
    <%
    Bean bean = (Bean)session.getAttribute("bean");
    %>

  • Running the batchinput session other than sm35

    Hi
    Can any one please tell how to know when a batch input session was run other than SM35?
    Thanks,

    Hi Anand,
      Check for the following transactions:
    SM36 -  Define Background Job
    SM37 -  Simple job Selection
    Hope this helps you,
    Regards.
    Chandra Sekhar

  • PLZ Help: how to get value of a request scoped Bean/Attribute in JSF ?!!!

    hi,
    I noticed this part of code to retrieve session scoped beans/vars in an ActionListener or other jsf classes, but it does not work for request scoped beans/vars :( what's the problem then ? what shall i do ?
    Type var = (Type)Util.getValueBinding("myBeanInRequest")).getValue(context);
    I have also set that getPhaseId() returns UPDATE_MODEL_VALUES or APPLY_REQUEST_VALUES.
    Any comment or idea ?

    I have declared my Bean in my JSP page not in the
    faces-config.xml. Does this make any problem ? Also I
    have tried the way you told me as well, but still the
    returned attribute is null.
    P.S. My bean is declared in my JSP page this way:
    <jsp:useBean id="newSurveyVar" class="SurveyModel"
    scope="request" />
    This declaration causes the SurveyModel instance to be created in request scope when the page is rendered, but that doesn't help you when the form is submitted -- that is going to happen on the next request (so the request attribute created here goes away). Basically, <jsp:useBean> is not typically going to be useful for request scope attributes (it's ok for session or application scope, though).
    and further I have this jsf code:
    <h:command_button label="Create" commandName="create"
    action="create" >
    <f:action_listener
    r type="CreateNewSurveyActionListener"/>
    </h:command_button>
    and this is my
    CreateNewSurveyActionListener.processAction(ActionEvent
    e) {
    if (actionCommand.equals("create_the_survey")) {
    FacesContext context =
    t = FacesContext.getCurrentInstance();
    SurveyModel survey =
    y =
    (SurveyModel)(Util.getValueBinding("newSurveyVar")).get
    alue(context);
    if (survey==null) // returns true :(((
    And since I've declared my beans here there is nothing
    special declared in my faces-config.xml
    For me again it is really strange why it is not
    working !!!
    Any idea ? Because the event listener is fired in a separate request, so the one you created in the page is gone.
    This is why the managed bean creation facility was created. If your component contains a valueRef that points at the bean name (or you evaluate a ValueBinding as illustrated earlier in the responses to your question), then the bean will get instantiated during the processing of the form submit.
    Craig McClanahan

  • We should NEVER use the session back bean?

    Because the user can open a new window by right click the link, and the session scope back bean is not thread-safe.
    So we should forget it?

    Your concern makes really no sense, or you must be storing request scoped data in a session scoped bean instead of a request scoped bean, which can indeed lead to undesireable behaviour in multiple requests on the same session.

  • How to enable remote debugging for a session other than the current one

    Hi all,
    I am trying to figure out how to enable remote debugging for a session other than the one I am currently using.
    More specifically, we have an application that is making database calls to Oracle 11gR2. Something is causing an exception during this invocation. My system is currently not set up to recompile said application, so I can't just add the debug call to the code and recompile. Therefore I would like to be able to log into the database (as sys, if necessary) and invoke dbms_debug_jdwp.connect_tcp on the desired session.
    The docs indicate that I should be able to do so:
    dbms_debug_jdwp.connect_tcp(
    host IN VARCHAR2,
    port IN VARCHAR2,
    session_id IN PLS_INTEGER := NULL,
    session_serial IN PLS_INTEGER := NULL,
    debug_role IN VARCHAR2 := NULL,
    debug_role_pwd IN VARCHAR2 := NULL,
    option_flags IN PLS_INTEGER := 0,
    extensions_cmd_set IN PLS_INTEGER := 128);
    But when I try (even as sys), I get the following:
    exec dbms_debug_jdwp.connect_tcp('1.2.3.4',5678,<session id>,<session serial>);ORA-00022: invalid session ID; access denied
    ORA-06512: at "SYS.DBMS_DEBUG_JDWP", line 68
    ORA-06512: at line 1
    00022. 00000 - "invalid session ID; access denied"
    *Cause:    Either the session specified does not exist or the caller
    does not have the privilege to access it.
    *Action:   Specify a valid session ID that you have privilege to access,
    that is either you own it or you have the CHANGE_USER privilege.
    I've tried granting the 'BECOME USER' privilege for the relevant users, but that didn't help. I read something about having to set some kind of ACL as of 11gR1, but the reference documentation was very confusing.
    Would someone be able to point me in the right direction? Is this even possible, or did I misread the documentation?

    Interesting deduction, that would be very useful indeed. I hate recompiling just to add the debug call, and it can't be done in our production environment. But it seems unlikely to me it would be implemented this way.
    I would cross-post this in the SQL AND PL/SQL forum though, as this is really a database issue, not with the SQL Developer tool. Do add the links to the other posts in each.
    Regards,
    K.

  • Specify name of session id cookie to be something other than jsessionid?

    I was browsing the contents of the orion-web.xml and noted that there is an id attribute in the session-config element. Can this be used to specify an alternative name other than jsessionid for the session id? If not is there a way of specifying an alternative name in some other way in Oracle 10g AS? This might aid migration from another appllication server to Oracle.

    Hi,
    no, you can't. The session-config allows you to e.g. set the time out for an idle session
    Frank

  • Oracle-ADF inlineFrame initializing view scoped bean twice

    I am facing strange issue related with af:inlineFrame component. Trying to display/render ADF page inside of af:popup within af:inlineFrame component. The weird thing is when the popup displayed; view scoped bean's @PostConstruct method called twice. That means bean is initialized twice. However it needed to be initialized once since bean is referenced from the page that is going to be displayed inside af:inlineFrame.
    Correct flow gotta be:
    Click to button openPopup() method called.
    openPopup() sets URI then opens popup.
    inlineFrame source property set as it's going to display framePage.jspx.
    JSF scans framePage.jspx code finds out there is a reference to FrameBean inside af:outputLabel
    Construct FrameBean then call @PostConstruct method.
    Call appropriate getter and render page.
    What happens in my case:
    Click to button openPopup() method called.
    openPopup() sets URI opens popup.
    inlineFrame source property set as it's going to display framePage.jspx.
    JSF scans framePage.jspx code finds out there is a reference to FrameBean inside af:outputLabel
    Construct FrameBean then call @PostConstruct method.
    Call appropriate getter and render page.
    Construct FrameBean then call @PostConstruct method.
    Call appropriate getter and render page.
    Popup located like:
    <af:popup id="mainPopup" binding="#{mainBean.mainPopup}">
    <af:dialog id="mainDialog">
      <af:inlineFrame source="#{mainBean.URI}"> </af:inlineFrame>
      </af:dialog>
    </af:popup>
    Showing popup via af:button action="#{mainBean.openPopup}":
    public void openPopup() {
    this.setURI("http://localhost:7001/app/framePage.jspx");
      RichPopup.PopupHints hints = new RichPopup.PopupHints();
    this.getMainPopup().show(hints);
    framePage.jspx:
    <?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <jsp:directive.page contentType="text/html;charset=UTF-8" />
    <f:view>
    <af:document title="Frame Demo" id="demoDocument">
      <af:form id="demoForm">
    <af:outputLabel value="#{frameBean.commonId}">   </af:outputLabel>
      </af:form>
      </af:document>
    </f:view>
    </jsp:root>
    FrameBean:
    @ManagedBean
    @ViewScoped
    public class FrameBean {
    private String commonId;
      @PostConstruct
      public void afterInit() {  } 
      public String getCommonId() {
    return commonId;
    public void setCommonId(String commonId) {
    this.commonId = commonId;
    Making FrameBean @SessionScoped solves this issue since bean is kept with session but I don't want to keep it within session. Also setting source property of af:inlineFrame in jspx as hardcoded not fixing the problem.

    im using ADF Essential on Glassfish 3.1 with no problem, but glassfish is heavyweight. I think Oracle ADF is not dependent to Application Server , then i tried to use my project with Tomcat 7. I deployed my application on Tomcat 7 , but im getting some exceptions.
    Not all application servers support Oracle ADF.
    Refer the certification matrix, Tomcat 7 is not listed as being supported.
    http://www.oracle.com/technetwork/developer-tools/jdev/index-091111.html

  • Pageflow-scoped bean "disappearing" during postbacks

    Hello,
    I'm getting crazy with an error with a pageflow-scoped bean which suddenly "disappers"...
    What I need to do is to use a bean to mantain the visibility status of 2 components (one is visible while the other isn't), an edit form and a warning message:
      <af:outputText value="some warning text"
                     visible="#{!pageFlowScope.untitled1.editFormViewable}"/>
      <af:panelFormLayout visible="#{pageFlowScope.untitled1.editFormViewable}">
      </af:panelFormLayout>the editFormViewable boolean variable is updated within the selectionListener of a tree (which also resides in the same bean), according to the node
    selected by the user:
    public class Untitled1Bean implements Serializable {
      private Boolean editFormViewable;
      public Untitled1Bean() { }
      public void treeSelectionListener(SelectionEvent event) {
        // manipulates editFormViewable
    }so I either show the form or the warning message. I need to retain editFormViewable across requests so backingBean scope isn't fully appropriate, but I'm also in a bounded taskflow so according to the guide viewscope is not supported. So I went for pageFlow scope.
    Here's the definition for the managed bean in my bounded taskflow:
        <managed-bean>
          <managed-bean-name>untitled1</managed-bean-name>
          <managed-bean-class>test.view.backing.Untitled1Bean</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
          <managed-property>
            <property-name>editFormViewable</property-name>
            <property-class>java.lang.Boolean</property-class>
            <value>false</value>
          </managed-property>
        </managed-bean>Now, when I enter the taskflow and load the page everything is fine, editFormViewable is correctly initialized to false (same if I set it to true) and the page displays correctly.
    However, as soon as I expand a node of the tree to access its children, my app dies with the following exception:
    javax.el.PropertyNotFoundException: Target Unreachable, 'untitled1' returned null
         at com.sun.el.parser.AstValue.getTarget(AstValue.java:88)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:153)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1264)
         at org.apache.myfaces.trinidad.component.HierarchyUtils.__handleBroadcast(HierarchyUtils.java:81)
         at org.apache.myfaces.trinidad.component.UIXTree.broadcast(UIXTree.java:227)
         at oracle.adf.view.rich.component.rich.data.RichTree.broadcast(RichTree.java:220)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:153)
         at org.apache.myfaces.trinidad.component.UIXTree.broadcast(UIXTree.java:231)
         at oracle.adf.view.rich.component.rich.data.RichTree.broadcast(RichTree.java:220)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:754)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:282)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:175)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         ...So it seems that during postbacks on that page the managed bean is no longer accessibile? How can a pageFlow bean disappear at that point? The bounded taskflow only has a view activity with my page, I'm in, why is the bean getting instanced correctly and then lost?
    Can someone please shed some light on this? I've used beans with scope longer than backing bean before, but never encountered such a problem.

    Sorry but that can't be right, probably just a leftover from previous versions or a mistake in the doc.
    JDeveloper itself on the "Managed Beans" tab of any taskflow, when registering a managed bean, presents you with a combobox offering 7 choices including pageFlow scope.
    Why would JDeveloper offer a non-existant feature in its UI?
    Also, I've used and seen them before. Check custRegBasicInformationBean, custRegDefineAddressesBean and welcomeUserRegistrationBean in FOD, they're pageflow-scoped beans and they do work.
    Mine works too, except that it breaks completely on postbacks from a tree.

  • Reentrant lock with Orchestra conversation scoped bean on second AJax call

    I'm just trying to set us a fairly straightforward JSF 2.0 / Spring / PrimeFaces application. Since backing bean expiry has been such a nuisance I thought I'd give Orchestra's conversation scope mechaniism a go.
    the problem I'm getting seems to occur on the second Ajax transaction for the page.
    WARNING: Waited for longer than 30000 milliseconds for access to lock org.apache.myfaces.orchestra.lib._ReentrantLock@2e8da6a9 which is locked by thread http-8084-5
    22-Mar-2011 11:16:13 org.apache.myfaces.orchestra.lib._ReentrantLock lockInterruptiblyThis message repeats, and the Ajax transaction never returns.
    I know that Orchestra locks the coversation scoped beans during the processing of a transaction to avoid threading issues (since they may contain non-reentrant objects like EntityMangers etc.) I'm assuming that, somehow, the backing bean is not unlocked at the end of the first Ajax transaction. But the configuration of listeners etc. should be being done automatically.
    Anyone tried a combination like this?

    never even heard of it. If I'd need a conversation scope (and I rarely do), I'd go for Seam 3 in stead even if it is not final yet.

Maybe you are looking for

  • Display a day of outlook calendar on ipphone

    Hi, I'm loking to display the calendar of a conference room on an ipphone. Does Somebody know how to do that ? Thanks !

  • Error while sending SOAP message to PI

    Hi Guyz, I have a sync-asyn scneario SOAP to File via PI. When I test the scenario using test tool i.e SOAP UI , scenario runs fine. But when user is trying to send a message they are getting Error message as response . "No SOAP Envelope but 1 {}. An

  • Can I use this G4 as a server?

    I've got a Mac Pro, a G5 and a Powerbook (non-intel) that I use as primary machines. I have an old G4 running 10.4.11. I'd like to use it as an always-on server, but can I reach it from the Mac Pro network? It doesn't show up as a normal networked ma

  • Help needed with iTouch not appearing as a hard drive ?

    Hi all,  I need some important data that I had saved in my itouch as disk drive.  Usually when I plug my itouch into pc, it will auto-play on windows and will show it as disk drive. It will also auto-sync to my itunes. I can also find the disk drive

  • Extreme with n and modem question

    Hi, my Airport extreme base station (n) has just arrived. I was about to set it up and notice on the little diagram that there is a modem attached! I thought this was a wireless router that I was buying. Now have I got this wrong but do I now have to