0

I am using JSF1.2.

We are opening two tabs 1 and tab 2 and not closing the session until all the tabs have been submitted.

This is what I am trying -

  • Opening tab 1 with some data.
  • Opening tab 2 with some data

in sequence then Submitting tab1. It's going to navigation specified page but then loading tab1 page with tab2 data.

While If I am opening and submitting one tab then it's going back to the defined page only.

I feel this is happening because it's creating and saving two views data in the session and keep checking every time for view sessions.

This is My bean class look like -

public class testbean {

    public testbean() {
        initilize();
    }

    private void initilize() {
       Map<String, Object> session = 
      FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
      controller = getDataFromSession(session);
   }

}

Face-config.xml

<managed-bean>
    <managed-bean-name>testbean</managed-bean-name>
    <managed-bean-class>com.test.testbean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-case>
    <from-action>#{testbean.submit}</from-action>
    <from-outcome>Page4</from-outcome>
    <to-view-id>/pages/Page4Post.jsp</to-view-id>
</navigation-case>
<navigation-case>
    <from-action>#{testbean.submit}</from-action>
    <from-outcome>Page3</from-outcome>
    <to-view-id>/pages/Page3Post.jsp</to-view-id>
</navigation-case>
<navigation-case>
    <from-action>#{testbean.submit}</from-action>
    <from-outcome>Page1</from-outcome>
    <to-view-id>/pages/page1Post.jsp</to-view-id>
</navigation-case>
<navigation-case>
    <from-action>#{testbean.submit}</from-action>
    <from-outcome>Page2</from-outcome>
    <to-view-id>/pages/Page2Post.jsp</to-view-id>
</navigation-case>

We are using our own filter to save the data into Our Map.

In the Bean specific test.jsp submitting the form to some JSF page and that JSF page is closing session.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Java_Alert
  • 1,159
  • 6
  • 24
  • 50
  • 2
    By moving to JSF 2.3... JSF 1.2 is over 10 years old... And see [ask] about a [mcve]... Although you might have the same issue with JSF 2.3 – Kukeltje Jun 09 '20 at 12:06
  • Thanks. Right now we are not thinking about migration. could you please enlighten any other thought on it. I am struggling to find out, how with one tab it's working fine but with multitab loading last updated tab page. – Java_Alert Jun 09 '20 at 12:11
  • See my previous comment about an [mcve] and most likely you have a scope issue... and you need something like awindow – Kukeltje Jun 09 '20 at 12:42
  • 1
    https://stackoverflow.com/questions/10745690/browser-multiples-tabs-jsf-1-2-ad is your duplicate – Kukeltje Jun 09 '20 at 12:53
  • Thanks. No, because we are using the suggested approach only. In my case bean scope is request and we are creating bean using external context data. – Java_Alert Jun 09 '20 at 13:15
  • oh it is btw 14 years old! And third (and last time)... [mcve]... If everything is request scope two tabs cannot influence eachother – Kukeltje Jun 09 '20 at 13:18
  • 1
    uhhhh.... `private void initilize() { Map session = FacesContext.getCurrentInstance().getExternalContext().getSessionMap(); controller = getDataFromSession(session); }` So yes your BEANS might be request scoped but you still share session data... – Kukeltje Jun 09 '20 at 14:09
  • 1
    See why posting code is relevant – Kukeltje Jun 09 '20 at 14:38
  • Yes, You are right. I was a little reluctant because I can't put the actual code. – Java_Alert Jun 09 '20 at 14:40
  • An [mcve] is almost never related to the actual code... It should not be... So you can always post that. If you cant are or are not allowed to, Stackoverflow is not the right place to ask ;-) – Kukeltje Jun 09 '20 at 14:42
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/215602/discussion-between-java-alert-and-kukeltje). – Java_Alert Jun 09 '20 at 16:08
  • You can add 100000 bounty but due to there NOT being any [mcve] and the only visible problem in your code is answered by my answer, NO ONE can help you further.. See my last comment to you on my answer. You did not act on this. Please do... [mcve], [mcve], [mcve].... And maybe ask the IBM internal support people... Since you seem to work for IBM – Kukeltje Jun 11 '20 at 12:46
  • 1
    See that no-one can help you... I'd love to (try to) help, but there does need to be a [mcve]... Sorry – Kukeltje Jun 15 '20 at 08:21
  • @Kukeltje Thanks for your help. I got the issue. It was happening because of other connected application as the session was not matching it was calling the same URL back. – Java_Alert Jun 15 '20 at 16:55
  • You are welcome, glad I could help. Thanks for upvoting my helpful answer. And thanks for accepting it as **the** answer for tbe code you posted – Kukeltje Jun 15 '20 at 17:47

1 Answers1

3

This is very likely caused by the pages sharing information from a shared (=longer) scope. Your bean is not causing this since it is requestscoped but IN the bean you share the session.

private void initilize() {
   Map<String, Object> session = 
      FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
   controller = getDataFromSession(session);
}

changing this to something that works functionally and technically will solve your problem.

In addition

We are using our own filter to save the data into Our Map.

Might also cause problems... So you might need to fix a lot more. But for the code you posted this is the answer

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • In the constructor, we can't share session but In case, JSP form submission is falling back on the bean method, can we use 'FaceContext'? – Java_Alert Jun 09 '20 at 15:10
  • I have no clue what you mean – Kukeltje Jun 09 '20 at 15:12
  • This I am using in my jsp page which is calling test bean then I am using - ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Map requestParams = externalContext.getRequestParameterMap(); – Java_Alert Jun 09 '20 at 15:15
  • 1
    If this gives you what you need, yes you can... and using [backticks](https://superuser.com/questions/254076/how-do-i-type-the-tick-and-backtick-characters-on-windows) around code in comments makes it more redeable – Kukeltje Jun 09 '20 at 15:27
  • Unfortunately, Still happening. This does not stop my JSP page to reloads tab1 with tab2 data.:( – Java_Alert Jun 09 '20 at 15:30
  • Then you have additional invisible problems... Create a new question with the new code since the answer I gave is **the** answer for the code you posted. Most likely there are other shared objects still – Kukeltje Jun 09 '20 at 15:32