ui:composition template=“<template from jar>”

南笙酒味 提交于 2019-12-06 10:49:23

问题


I would like to place the Facelets template file for JSF in a JAR file.

I tried to reference it by EL as

<ui:composition template="#{resource['templates:template_pe_layout.xhtml']}">

which works perfect for CSS or images, but not for the composition template.

How could I achieve the goal?


回答1:


The #{resource} expression is initially designed for use inside CSS files only like so

.someclass {
    background-image: url(#{resource['somelibrary:img/some.png']});
}

It's not intented for usage in <h:outputStylesheet>, <h:outputScript> or <h:graphicImage> which should rather be used as follows:

<h:outputStylesheet library="somelibrary" name="css/some.css" />
<h:outputScript library="somelibrary" name="js/some.js" />
<h:graphicImage library="somelibrary" name="img/some.png" />

As to the templates, just specify the full /META-INF/resources relative path in there.

<ui:composition template="/templates/template_pe_layout.xhtml">

See also:

  • Packaging Facelets files (templates, includes, composites) in a JAR
  • Changing JSF prefix to suffix mapping forces me to reapply the mapping on CSS background images


来源:https://stackoverflow.com/questions/10953066/uicomposition-template-template-from-jar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!