JSF/Facelets:为什么将 JSF/Facelets 与 HTML 标签混合使用不是一个好主意? [英] JSF/Facelets: why is it not a good idea to mix JSF/Facelets with HTML tags?

查看:24
本文介绍了JSF/Facelets:为什么将 JSF/Facelets 与 HTML 标签混合使用不是一个好主意?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读了好几遍了:一些开发人员不提倡在他们的 XHTML 文件中将 JSF/Facelets 标签与 HTML 标签交错.显然 HTML 标签不会成为 UI 组件树的一部分,但这样做的缺点是什么?

I've read this several times now: some developers aren't advocates of interleaving JSF/Facelets tags with HTML tags in their XHTML files. Obviously the HTML tags won't be part of the UI component tree, but what's the disadvantage of that?

我经常找到作者进行这种混合的代码示例:

I often find code examples where the authors do that kind of mixing:

http://www.ibm.com/developerworks/java/library/j-facelets/

http://www.packtpub.com/article/facelets-components-in-jsf-1.2

http://oreilly.com/catalog/9780596529246

Seam in Action"还交织着 JSF/Facelets 和 HTML 标签.

"Seam in Action" also interleaves JSF/Facelets and HTML tags.

我对实际使用的内容感到困惑.我开始混合标签,但我开始相信这可能不是正确的选择.但是,我不明白为什么更喜欢纯粹的方法.

I'm confused about what to actually use. I started out mixing tags, but I'm beginning to believe it was probably not the right choice. However, I fail to see why the puristic approach is preferrable.

我确信我有一个表,其中 JSF 数据表没有给我足够的灵活性来显示我需要的内容,所以纯粹地这样做是不可能的.

I know for certain that I have a table where the JSF datatable doesn't give me enough flexibility to display what I need to, so doing it puristically isn't possible.

此外,我想知道为什么上面的示例都没有使用 f:view 等代替硬编码的 html、head、body 等标签.

Furthermore I'm wondering why none of the examples above use f:view etc. instead of the hardcoded html, head, body etc. tags.

谁能帮我解决这个问题?

Can anyone please clear this up for me?

推荐答案

在 JSF 1.0/1.1 时代,这确实不是一个好主意",因为使用JSP 作为视图技术.所有纯 HTML 都由 JSP 在之前渲染 JSF 组件树.例如

During the JSF 1.0/1.1 ages this was indeed "not a good idea", because all the HTML was not automatically taken in the JSF component tree when using JSP as view technology. All plain HTML was eagerly by JSP rendered before the JSF component tree. E.g.

<p>Lorem ipsum <h:outputText value="#{bean.value1}"> dolor sit amet<p>
<p>Consectetur adipiscing <h:inputText value="#{bean.value2}" /> elit</p>

被渲染为

<p>Lorem ipsum dolor sit amet<p>
<p>Consectetur adipiscing elit</p>

value1
<input type="text" value="value2" />

要解决此问题,您需要引入 .

To fix this you would need to bring <f:verbatim> in.

<f:verbatim><p>Lorem ipsum </f:verbatim><h:outputText value="#{bean.value1}"><f:verbatim> dolor sit amet<p></f:verbatim>
<f:verbatim><p>Consectetur adipiscing </f:verbatim><h:inputText value="#{bean.value2}" /><f:verbatim> elit</p></f:verbatim>

这是一个真正的维护痛苦.这是 JSF 1.0/1.1 如此受人讨厌的主要原因之一.

This was a real maintenance pain. This was one of the major reasons why JSF 1.0/1.1 was so hated.

自 JSF 1.2 起,有了新的视图处理程序,就不再需要 .开发人员现在可以松一口气了.此外,新的视图处理程序允许 JSF 使用与 JSP 不同的视图技术,Facelets 就这样诞生了.

Since JSF 1.2, with the new view handler, the <f:verbatim> was not necessary anymore. Developers can now breathe relieved. Moreover, the new view handler allowed JSF to use a different view technology than JSP and this way Facelets was born.

这篇关于JSF/Facelets:为什么将 JSF/Facelets 与 HTML 标签混合使用不是一个好主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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