【问题标题】:jsf facelets menu image in header标头中的 jsf facelets 菜单图像
【发布时间】:2013-06-14 07:25:24
【问题描述】:

我已经使用 jsf facelets 开发了 web 应用程序,我已经为 ui 页眉、菜单、内容和页脚配置了一个 facelet。但是问题是我在登录时在标题中使用了一个图像,当我单击菜单中的链接并重定向到下一页时,它显示图像,该图像仅在登录时才显示它显示,否则它不会显示

这是我的 facelet 模板 xhtml 页面

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      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">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>

        <h:body>

            <p:layout fullPage="true">

                <p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
                    <p:graphicImage value="logo.gif" />  
                </p:layoutUnit>

                <p:layoutUnit position="south" size="100" closable="true" collapsible="true">
                    Footer
                </p:layoutUnit>

                <p:layoutUnit position="west" size="180" header="Menu" collapsible="true">
                    <ui:insert name="leftmenu">
                        <div>
                            <ui:include src="leftmenu.xhtml" />
                        </div>
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit position="center">
                   <ui:insert name="content">
                        Select one of the links on the left to proceed.
                    </ui:insert>
                </p:layoutUnit>

            </p:layout>

        </h:body>

    </f:view>
</html>

我的左侧菜单 xhtml 页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      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"> 
<h:head></h:head> 
<body> 
<h:form>
    <h:link value="Home" outcome="homePage"></h:link>
    <br />
    <h:link value="Create User" outcome="addUser"></h:link>
    <br />
    <h:link value="Change Password" outcome="addUser"></h:link>
    <br />
    <h:link value="Allocation Tan" outcome="addUser"></h:link>
    <br />
    <h:link value="Batch Upload" outcome="addUser"></h:link>
    <br />
    <h:link value="XML Validation" outcome="addUser"></h:link>
    <br />
    <h:link value="Logout" outcome="login"></h:link>
</h:form>
</body> 
</html>

我的添加用户 xhtml 页面

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition template="/templates/template.xhtml">       
            <ui:define name="content">
               <h:form id="form">  

    <p:panel id="panel" header="New Person">  

        <p:messages id="msgs"/>  

        <p:commandButton id="btn" value="Save" update="panel" actionListener="#{user.save}"/>  
    </p:panel>  

</h:form>  
            </ui:define>
        </ui:composition>
    </h:body>
</html>

谁能帮我解决这个问题

【问题讨论】:

    标签: jsf facelets


    【解决方案1】:

    由于您的其他模板看起来位于另一个目录中,您只需将图像的路径更改为绝对路径即可。您甚至可以在验证呈现页面的源代码时验证您的浏览器是否正在尝试获取此图像。

    这应该可以解决问题:

    <p:graphicImage value="/logo.gif" />
    

    【讨论】:

      猜你喜欢
      • 2010-09-10
      • 1970-01-01
      • 2012-07-19
      • 2011-02-10
      • 2010-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多