Html 什么 jsf 组件可以渲染 div 标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/951593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:50:49  来源:igfitidea点击:

What jsf component can render a div tag?

jsfhtml

提问by user101442

Eg: h:inputTextwill render a "input type='text'". What jsf tag can render a "div"tag?

例如:h:inputText将呈现一个"input type='text'". 什么 jsf 标签可以渲染"div"标签?

回答by Romain Linsolas

You can create a DIVcomponent using the <h:panelGroup/>. By default, the <h:panelGroup/>will generate a SPAN in the HTML code.

您可以DIV使用<h:panelGroup/>. 默认情况下,<h:panelGroup/>将在 HTML 代码中生成 SPAN。

However, if you specify layout="block", then the component will be a DIVin the generated HTML code.

但是,如果您指定layout="block",则组件将是DIV生成的 HTML 代码中的 。

<h:panelGroup layout="block"/>

回答by mp31415

In JSF 2.2 it's possible to use passthroughelements:

在 JSF 2.2 中,可以使用passthrough元素:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:jsf="http://xmlns.jcp.org/jsf">
    ...
    <div jsf:id="id1" />
    ...
</html>

The requirement is to have at least one attribute in the element using jsf namespace.

要求是使用 jsf 命名空间的元素中至少有一个属性。

回答by Nick Grubb

Apart from the <h:panelGroup>component (which comes as a bit of a surprise to me), you could use a <f:verbatim>tag with the escape parameter set to falseto generate any mark-up you want. For example:

除了<h:panelGroup>组件(这让我有点惊讶),您可以使用<f:verbatim>带有转义参数设置为的标签false来生成您想要的任何标记。例如:

<f:verbatim escape="true">
    <div id="blah"></div>
</f:verbatim>

Bear in mind it's a little less elegant than the panelGroupsolution, as you have to generate this for both the start and end tags if you want to wrap any of your JSF code with the divtag.

请记住,它不如panelGroup解决方案优雅,因为如果您想用div标记包装任何 JSF 代码,您必须为开始和结束标记生成它。

Alternatively, all the major UI Frameworks have a divcomponent tag, or you could write your own.

或者,所有主要的 UI 框架都有一个div组件标签,或者您可以编写自己的标签。

回答by Hyman jin

回答by Sanket

I think we can you use verbatim tag, as in this tag we use any of the HTML tags

我想我们可以使用逐字标记,因为在这个标记中我们使用任何 HTML 标记