简体   繁体   中英

How to stop JSF1.2 to stop reloading same page

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM