0

During working with JSF 1.2 one page code is too large and JDeveloper gave too large code in service method exception. Now I want to split my JSF file in smaller files. During splitting I need some help and suggestion.

Beacuse the whole page binds with a single bean, is it also necessary to split the bean? If not, then how to overcome this? What is the best way to split JSF file and include in main page?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
seeker
  • 79
  • 2
  • 16

1 Answers1

2

You don't need to split the bean. You could just split the page fragments over multiple files which you include by <jsp:include> (and not by @include as that happens during compiletime and you would end up with still the same exception!). Note that you should store those include files in /WEB-INF folder to prevent direct access by enduser.

So given this example of an "extremely large" page,

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <div>
            large chunk 1
        </div>
        <div>
            large chunk 2
        </div>
        <div>
            large chunk 3
        </div>
    </body>
</html>

You could split it as follows while keeping the beans:

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <jsp:include page="/WEB-INF/includes/include1.jsp" />
        <jsp:include page="/WEB-INF/includes/include2.jsp" />
        <jsp:include page="/WEB-INF/includes/include3.jsp" />
    </body>
</html>

and /WEB-INF/includes/include1.jsp:

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
    large chunk 1
</div>

and /WEB-INF/includes/include2.jsp:

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
    large chunk 2
</div>

and /WEB-INF/includes/include3.jsp:

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
    large chunk 3
</div>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • thanks a lot its works for me:). Actually i was confused about use of one bean in split pages.One thing more to ask if i use in include1.jsp,include2.jsp,include3.jsp pages then what difference or impact ? – seeker Feb 13 '13 at 16:28