有没有办法在不构建整个项目的情况下运行 JSF 页面? [英] Is there a way to run a JSF page without building the whole project?

查看:28
本文介绍了有没有办法在不构建整个项目的情况下运行 JSF 页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法只运行一个页面,这样我就可以看到生成的 html(和 css),即使它本质上是非功能性的?独立的 JSF 页面.我想回顾一下我是如何设置表单的,以便在实际为表单的字段编码之前从用户的角度来看它们是否有意义.我正在使用 maven 和 netbeans,但不确定后者是否相关.

Is there a way to just run the one page so that I can see the generated html (and css) as it would look to the user even if it is essentially non-functional? Standalone JSF page as it were. I want to review how I am setting up forms to see if they make sense form a user standpoint before actually coding for the form's fields. I'm using maven and netbeans but not sure if the latter is relevant.

推荐答案

如果您使用的是 JSF2 Facelets,那么您只需使用纯 HTML 设计表单并使用 jsfc 属性来指定应在 JSF 运行时使用的相应 JSF 组件.例如

If you're using JSF2 Facelets, then you can just design your forms with plain HTML and use the jsfc attribute to specify the respective JSF component which should be used during JSF runtime. E.g.

<form jsfc="h:form">
    <label jsfc="h:outputLabel" for="input1" />
    <input type="text" jsfc="h:inputText" id="input1" value="#{bean.input1}" required="true" />
    <span jsfc="h:message" for="input1" />
    <input type="submit" jsfc="h:commandButton" value="Submit" action="#{bean.submit}" />
</form>

阅读 Facelets <ui:xxx> taglib 文档 也应该提供一些见解.例如

Reading the Facelets <ui:xxx> taglib documentation should also give some insights. E.g.

<span jsfc="ui:remove">
    This is present during design time, but is removed during JSF runtime.
</span>

<div jsfc="ui:repeat" value="#{bean.items}" var="item">#{item}</div>

<table>
    <tr jsfc="ui:repeat" value="#{bean.items}" var="item">
        <td>#{item.id}</td>
        <td>#{item.name}</td>
    </tr>
</table>

事实上,您可以使用 来指定 Facelet 组合的开始和结束(例如,包含文件或标记文件).外部的任何内容在运行时都将被忽略,但您仍然可以在设计时放置一些 HTML,以便您可以轻松预览包含文件或标记文件应该是其中一部分的完整设计.

And the fact that you can use <ui:composition> to specify the start and end of a Facelet composition (e.g. an include file or a tag file). Any content outside will be disregarded during runtime, but you can still put some HTML around during designtime so that you can easily preview complete designs in which the include file or tag file is supposed to be part of.

<!DOCTYPE html>
<html lang="en"
    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"
>
    <head>
        ...
    </head>
    <body>
        ...
        <ui:composition>
            Here you can design content of include file or
            tag file as if it's part of the whole design.
        </ui:composition>
        ...
    </body>
</html>

这一切都允许您在不需要 JSF 运行时预览 HTML/CSS 设计.

This all allows you to preview HTML/CSS designs without needing a JSF runtime.

这篇关于有没有办法在不构建整个项目的情况下运行 JSF 页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆