开发者

JSF template not applied

开发者 https://www.devze.com 2023-01-14 11:49 出处:网络
I created template (template.xhtml) which resides in root context of application. I wanted to apply it to page (newTemplateClient.xhtml) which resides in the folder \'public\'.

I created template (template.xhtml) which resides in root context of application. I wanted to apply it to page (newTemplateClient.xhtml) which resides in the folder 'public'. So newTemplateClient.xhtml looks like this:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns="http://www.w3.org/1999/xhtml"
            template="./../template.xhtml">
                            .
                            .
                            .

I have links to this page in index.xhtml:

<h:link outcome="/public/newTemplateClient" value="Login"/>

<h:commandLink action="/public/newTemplateClient?faces-redirect=true" value="Login"/>

<h:commandLink action="/public/newTemplateClient" value="Login"/>

And only last works. When I use first two page displays but template isn't applied. So it works only when page is redirected, not forwarded. Why?

Thanks in advance

Okay it seems that template is applied but css files aren't. I'm using NetBeans wizards to create templates and templates clients. The css files are located /resources/css/ directory. They are referenced from template.xhtml:

`

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    <link href="./resources/css/cssLayout.css" rel开发者_如何学编程="stylesheet" type="text/css" />
    <title><ui:insert name="title">template</ui:insert></title>
</h:head>

<h:body>

    <div id="top">
        <ui:insert name="top">Top</ui:insert>
    </div>

    <div id="content" class="center_content">
        <ui:insert name="content">Content</ui:insert>
    </div>

    <div id="bottom">
        <ui:insert name="bottom">Bottom</ui:insert>
    </div>

</h:body>

`

How can I reference that css files other way? Folder structure:

Root
  public
    newClientTemplate.xhtml
  template.xhtml
  index.xhtml


Okay problem solved. Solution was to use:

<h:outputStylesheet name"css/default.css"/>
<h:outputStylesheet name"css/cssLayout.css"/>

Instead:

<link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
<link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号