2

I've created a web application that opens up pages inside an iFrame on the main page. Each iFrame is viewable via a tab on the page and uses JSF2.2 with Mojarra view state beans to populate the page.

This works fine when I open up something under 10 tabs; but when I try to open up more, the beans that held the first pages are destroyed and get recreated when I make any calls to the bean thus losing any prior changes the user may have made.

I'm using Apache Tomcat 7 with Catalina, and this issue is happening on my XP and Windows Server 2008 machines.

This is my current web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>SCMPage</display-name>
  <filter>
    <filter-name>IEFilter</filter-name>
    <filter-class>com.Filter.IEFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>IEFilter</filter-name>
    <url-pattern>*.xhtml</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <context-param>
    <description>Location of the Config file for the web application and the engine</description>
    <param-name>configFile</param-name>
    <param-value>C:\Users\ravil7148084\workspace\SCMPage\config.properties</param-value>
  </context-param>  
  <context-param>
    <param-name>com.sun.faces.numberOfViewsInSession</param-name>
    <param-value>30</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.numberOfLogicalViews</param-name>
    <param-value>30</param-value>
  </context-param>
</web-app>

I've also tried setting this environment variable thinking that it might be a memory limit on tomcat's end, but it didn't make a difference

set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m

Any help would be appreciated!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
ravila
  • 21
  • 2

1 Answers1

1

You've there just a severe design error. To include server side page fragments, you're using 90's style iframes instead of true server side include components. Each iframe has its own view state and won't reuse the main document's view state. Just replace all those <iframe> things by <ui:include> and world should be well.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks @BalusC, I'll test out the ui:include and see if it'll work for me because I have buttons(links) that dynamically add the pages to the site and I've been reading about the include tag not playing nicely with repeat tags. I don't have the iframe's using the view state of the main document once they've been created, so do you have any clue as to why the beans would be recreating themselves? Again this only happens when I go over a certain number of beans, but works fine otherwise. – ravila Aug 21 '14 at 16:18