使用类属性,而不是一个JSF组件的styleClass的实际工作,为什么? [英] Using class attribute instead of styleClass of a JSF component actually works, why?
问题描述
据我的理解,我们需要使用的styleClass =
作为JSF组件不支持只使用类=
。
As far as I understood, we needed to use styleClass=
as the JSF components don't support using just class=
.
我最近注意到,用某些组件类=
仍然呈现正常。作为一个小例子,
I've noticed recently that some components that were using class=
were still rendering correctly. As a minimal example,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Simple JSF Facelets page</title>
</h:head>
<h:body>
<h:inputText class="wut" anothertag="hi" value="me"/>
</h:body>
</html>
这产生
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/individuallifefaz/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo"/>
<title>Simple JSF Facelets page</title></head>
<body>
<input type="text" name="j_idt5" value="me" class="wut"/>
</body>
</html>
这是为什么工作?这显然不只是通过任何未知的标签传球,为 anothertag
被剥离出去。
推荐答案
这实际上是由视图技术的Facelets进行,而不是由JSF组件本身。 Facelets有一个<一个href=\"http://grep$c$c.com/file/repo1.maven.org/maven2/org.glassfish/javax.faces/2.2.0/com/sun/faces/facelets/tag/jsf/html/HtmlComponentHandler.java#79\">alias为类
属性,它会自动映射到的styleClass
。这被实现为支持一部分 JSFC
属性为设计师友好的Facelets,这应该让这样的事情可能使用的:
This is actually done by the view technology Facelets, not by the JSF component itself. Facelets has an alias for class
attribute which automatically maps to styleClass
. This was implemented as part of support for jsfc
attribute as used in "designer friendly Facelets" which should make things like this possible:
<input type="text" jsfc="h:inputText" class="foo" />
如果您使用JSF使用不同的视图技术(虽然到目前为止有没有这对Facelets的一个严肃的替代选择,而JSP是德precated),那么就无法保证&LT; H :inputText的类&GT;
将工作
If you use JSF with a different view technology (although so far there's none which is a serious alternative to Facelets, and JSP is deprecated), then there's no guarantee that <h:inputText class>
would work.
- Is there a way to run a JSF page without building the whole project?
这篇关于使用类属性,而不是一个JSF组件的styleClass的实际工作,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!