JSF分页 [英] JSF page splitting

查看:71
本文介绍了JSF分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用JSF 1.2的过程中,一页代码太大,并且JDeveloper在服务方法中给太大的代码给出了异常.现在,我想将我的JSF文件拆分为较小的文件.拆分期间,我需要一些帮助和建议.

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.

因为整个页面都绑定了一个bean,是否也有必要拆分bean?如果没有,那么如何克服呢?拆分JSF文件并将其包含在主页中的最佳方法是什么?

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?

推荐答案

您不需要拆分bean.您可以将页面片段仅拆分为多个文件,并按<jsp:include>(而不是按@include),因为在编译时会发生这种情况,最终会出现同样的异常!).请注意,应将这些包含文件存储在/WEB-INF文件夹中,以防止最终用户直接访问.

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>

/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>

/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>

/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>

这篇关于JSF分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆