0

我正在研究如何使用 Primefaces 3.4.1 的示例p:TabMenu

主页:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>

    </h:head>
    <h:body>

        <div id="settingsHashMapz" class="settingsHashMap" style="width:1150px; height:400px; position:absolute; top:20px; left:1px">

            <p:tabMenu id="tabs" activeIndex="0" >  
                <p:menuitem value="tab1" url="/tab1.jsf" />  
                <p:menuitem value="tab2" url="/tab2.jsf" />  
                <p:menuitem value="tab3" url="/tab3.jsf" />

            </p:tabMenu>  
        </div>   
    </h:body>
</html>

选项卡 1 页:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>

    </h:head>
    <h:body>
        <ui:composition>
            <h:panelGroup>
                <h:form id="tab1" >
                    ................. 
                </h:form>         
            </h:panelGroup>
        </ui:composition>
    </h:body>
</html>

当我尝试使用p:tabMenu. 我不能ui:composition正常使用。我必须在每个标签页中声明名称空间,因为它们不能使用 JSF 主页面中的名称空间。如果我将所有命名空间声明到标签页中,我必须等待约 3 秒才能从服务器传输 Javascript 库。如您所见,这是浪费资源:

GET http://server:8080/DCProfileTabGenerators.jsf 200 OK 29ms                              jquery....min.js (line 4)
GET http://server:8080/javax.f...uery/jquery.js.jsf?ln=primefaces&_=1349526707969 200 OK 11ms   jquery....min.js (line 4)
GET http://server:8080/javax.f.../primefaces.js.jsf?ln=primefaces&_=1349526708568 200 OK 8ms   jquery....min.js (line 4)
GET http://server:8080/javax.f...source/jsf.js.jsf?ln=javax.faces&_=1349526708949 200 OK 8ms   jquery....min.js (line 4)
GET http://server:8080/resources/js/tabs.js?_=1349526709016 200 OK 10ms

如何使用在 JSF 主页面中声明的名称空间进入选项卡 JSF 页面?

4

1 回答 1

2

Declaring namespaces at the top of the page does not impart any real performance loss. It just declares which namespaces you wish to use on a given page file. In essence there is no real way to do this however it is not necessary.

The GET requests below are for downloading the necessary javascript libraries, stylesheets and images to the client. Depending on the client browser settings, these should be cached after the first request so that this client will not have to download them multiple times as they navigate pages throughout your application.

于 2012-10-07T13:35:26.437 回答