标签: facelets

春天mvc与facelets

是否可以将facelets用作Spring MVC的视图技术?官方文档中没有提及它,但我听说Facelets非常方便易用,我想尝试一下,我只是不知道如何...

java facelets spring-mvc

6
推荐指数
1
解决办法
4395
查看次数

如何在JSF中创建现有组件的组合?

我想知道是否有可能组成我自己的组件(或称之为Widget,Object).

我的意思是,而不是(例如)使用h:panelGroup和在h:outputLabel里面,使用我自己的h:panelMarkzzz,作为panelGroup和outputLabel的组合.

在JSF上有可能吗?

jsf components facelets

6
推荐指数
1
解决办法
2375
查看次数

将操作方法​​添加到复合组件

我正在学习使用JSF 2.0的复合组件,我希望我的组件能够从支持bean中触发方法,所以我创建了一个简单的例子,但是出了点问题.

这是我创建的组件:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
        <composite:attribute name="attribute1"/>
        <composite:attribute name="attribute2"/>
        <composite:attribute name="actionBtnText"/>
        <composite:attribute name="actionMethod" method-signature="java.lang.String action()"/>
</composite:interface>

<composite:implementation>
    <h:form>
            <h:inputText value="#{cc.attrs.attribute1}"/>
            <br/>
            <h:inputText value="#{cc.attrs.attribute2}"/>
            <br/>
            <h:commandButton action="#{cc.attrs.actionMethod}" value="#{cc.attrs.actionBtnText}"/>          
    </h:form>

</composite:implementation> 

</html>
Run Code Online (Sandbox Code Playgroud)

这是我在JSF页面中使用它的方式

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:custom="http://java.sun.com/jsf/composite/custom">

...

    <h:body>
    <custom:demoCustomComponent attribute1="#{demoBB.value1 }" attribute2="#{demoBB.value2 }" actionBtnText="Button text!" actionBtn="#{demoBB.act}"/>
    </h:body>
Run Code Online (Sandbox Code Playgroud)

这是支持组件所在页面的支持bean

@Named("demoBB")
@RequestScoped
public class DemoBB {

    private String value1;
    private String value2;
    public String getValue1() {
        return value1;
    }

    public String act() {
        System.out.println("Input 1: " + value1 …
Run Code Online (Sandbox Code Playgroud)

java jsf facelets composite-component jsf-2

6
推荐指数
1
解决办法
1万
查看次数

如何在Facelets和web.xml中引用JAR中的Facelets taglib?

我正在使用Apache MyFaces Commons Validator TagLib.

我该如何将其添加到我的web.xml中?公共JAR通过Maven下载并解决.

XHTML(我认为这是正确的):

<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:p="http://primefaces.prime.com.tr/ui"
      **xmlns:mcv="http://myfaces.apache.org/commons/validators"**>
Run Code Online (Sandbox Code Playgroud)

web.xml中:

<context-param>
  <!-- To add additional tab libs -->
  <param-name>facelets.LIBRARIES</param-name>
  <param-value>??.xml</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

编辑:我之所以这一步是因为我试图错误地引用Maven依赖,并且这样做,我试图从Apache下载jar并从我自己的存储库管理器托管它.我试图自己托管的jar不包含taglib jar.

在正确获得依赖关系后,一切都按照正常情况工作,没有必要明确定义taglib作为balusC所赞扬的内容.Thankx!

<dependency>
    <groupId>org.apache.myfaces.commons</groupId>
    <artifactId>myfaces-commons</artifactId>
    <version>1.1.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

jsf facelets myfaces taglib

6
推荐指数
1
解决办法
6837
查看次数

如何使用JSF和Facelets有条件地在我的模板中包含一个文件?

所以,我的模板包含一个footer.xhtml

<ui:include src="/WEB-INF/testtaker/Footer.xhtml"/>
Run Code Online (Sandbox Code Playgroud)

我想要做的是根据一些用户pref更改页脚到不同的Footer _ ???.xhtml文件.

所以,我想做这样的事情:

<ui:include src="/WEB-INF/testtaker/Footer_001.xhtml">
      Content from original Footer.xhtml
</ui:include>
Run Code Online (Sandbox Code Playgroud)

如果Footer_001.xhtml不存在,则让它使用标签之间的内容,否则使用文件中的内容.

我知道这似乎有点奇怪,但这将解决一个巨大的问题,即自定义我现有的网站,不必对所有地方进行更改.另外,我不确定该文件是否存在.

有什么想法吗?

jsf facelets include

6
推荐指数
1
解决办法
2971
查看次数

我可以确定是否在复合组件中定义了JSF2构面吗?

我正在创建一个JSF2 Facelets复合组件.如果定义了特定的facet,我希望HTML的呈现方式不同.有没有办法检查是否<f:facet name="..." />已为复合组件定义了?

java jsf facelets composite-component jsf-2

6
推荐指数
1
解决办法
2023
查看次数

在web.xml安全约束中排除css和图像资源

我正在使用JSF2.1和Glassfish 3.1.2.

我指定一个安全约束来阻止一切:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Secured Content</web-resource-name>
        <!-- Block all -->
        <url-pattern>/*</url-pattern>
    </web-resource-collection>

    <!-- only users with at least one of these roles are allowed to access the secured content -->
    <auth-constraint>
        <role-name>ADMINISTRATOR</role-name>
    </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

并有另一个允许访问页面和资源的子集:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Open Content</web-resource-name>
        <!-- Allow subscribe -->
        <url-pattern>/subscribe/*</url-pattern>
        <url-pattern>/javax.faces.resource/*</url-pattern>
    </web-resource-collection>
    <!-- No Auth Contraint! -->
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

这很好用.但是,如下

<url-pattern>/javax.faces.resource/*</url-pattern>
Run Code Online (Sandbox Code Playgroud)

允许所有资源的正确方法?

我只是通过查看Facelets注入xhtml的url来做到这一点.这种方法有安全漏洞吗?

谢谢.

security jsf web.xml facelets java-ee

6
推荐指数
1
解决办法
5592
查看次数

每个区域设置JSF 2中的不同facelets(用于模板)

我有一个模板,有<ui:insert name="help_contents" />一个页面定义<ui:define name="help_contents><!-- actual contents --></ui:define>,定义中的内容应该是基于JSF(不仅仅是简单的html/xhtml),由faces servlet处理,并根据locale不同.但是我不想用资源包做这个,因为每个属性需要大量的文本,并且必须为每个散布文本的组件分解它.换句话说,我想要每个语言环境的facelet,然后根据活动的语言环境包含正确的facelet.

这基本上就是问题所在.下面的上下文是为了寻找其他人,如果您已经明白我的意思,请跳过.

在大多数情况下,JSF 2的国际化非常容易.您创建一个或多个资源包,在faces-config.xml中声明这些资源包,并且您已准备好使用这些属性.但是这样的属性文件对我来说只对短标签文本,列标题,可能有几个参数的小消息有好处......当谈到大部分文本时,它们看起来很笨重.特别是如果文本应该穿插XHTML标签或JSF组件,在这种情况下你需要分解太多.

目前我正在开发一些使用JSF 2的Web应用程序,PrimeFaces作为组件包,它在常规意义上使用i18n的资源包.但各种观点需要一个帮助页面.我也想在这些帮助页面中使用JSF/PrimeFaces组件,因此填充表或对话框的示例与视图本身中的相同.

但是,包含基于区域设置的构图内容似乎不像我想象的那么简单.我想让XHTML页面(facelets)具有像_en或_fr这样的语言环境后缀,并根据活动的语言环境选择正确的页面.如果不存在此类页面,则应默认为_en页面(或者不包含仅包含英语内容的后缀的页面).从facescontext获取区域设置字符串不是问题,但检测页面是否存在似乎更难.有没有办法在JSF中或通过EL执行此操作,还是应该通过托管bean来完成?也许为此编写自定义标签可能很有用,但我不确定这需要做多少工作.

我确实找到了这个相关的问题,但是如果我不想注入纯HTML内容,这似乎才有用.我想要包含JSF内容的页面,以便它们实际上由JSF servlet处理和呈现.

java jsf facelets internationalization jsf-2

6
推荐指数
1
解决办法
2287
查看次数

Netbeans错误"属性目标未在组件outputStylesheet中定义"

我输入了以下代码:

<h:outputStylesheet library="css" name="style.css" target="body" />
Run Code Online (Sandbox Code Playgroud)

问题是它给我一个关于target ="body"的错误说:

The attribute target is not defined in the component outputStylesheet
Run Code Online (Sandbox Code Playgroud)

在html部分,如果html我有以下内容:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:pe="http://primefaces.org/ui/extensions">
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

谢谢

jsf netbeans facelets

6
推荐指数
1
解决办法
2504
查看次数

JSF中的RES_NOT_FOUND

我读了很多帖子但没有成功解决这个问题.请帮忙....

Eclipse Juno/JSF

项目结构: 在此输入图像描述

teste.xhtml:

<!DOCTYPE html[
    <!ENTITY nbsp "&#160;"> 
    <!ENTITY copy "&#169;">
] >
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
  <h:outputScript library="js" name="slides.min.jquery.js"/>
  <h:graphicImage value="images/blog.png" />
  <h:outputStylesheet name="css/estilo.css"/>
  </h:head>
  <h:body>
  #{javax.faces.resource}
  </h:body>
  </html>
Run Code Online (Sandbox Code Playgroud)

输出是:

<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND">
Run Code Online (Sandbox Code Playgroud)

与js和图像相同的res_not_found

pom.xml:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>4.0</version>
</dependency>

<dependency>
    <groupId>org.primefaces.extensions</groupId>
    <artifactId>all-themes</artifactId>
    <version>1.0.8</version>
</dependency>

<dependency>
    <groupId>com.sun.facelets</groupId>
    <artifactId>jsf-facelets</artifactId>
    <version>1.1.14</version>
</dependency>


<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.1.23</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1.23</version>
    <scope>provided</scope>
</dependency>       

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>javax.faces-api</artifactId>
    <version>2.2</version>
</dependency> …
Run Code Online (Sandbox Code Playgroud)

css eclipse jsf jboss facelets

6
推荐指数
1
解决办法
2万
查看次数