有没有办法在不构建整个项目的情况下运行 JSF 页面?

编程入门 行业动态 更新时间:2024-10-28 00:25:15
本文介绍了有没有办法在不构建整个项目的情况下运行 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="www.w3/1999/xhtml" xmlns:f="java.sun/jsf/core" xmlns:h="java.sun/jsf/html" xmlns:ui="java.sun/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 页面?

本文发布于:2023-11-23 09:17:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620912.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   情况下   页面   项目   JSF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!