What is the difference between class and styleClass attributes in JSF?

久未见 提交于 2019-12-22 01:33:55

问题


I see, that in JSF most of the standard components that mapped to HTML tags, e.g. <h:commandButton/>, have attributes class and styleClass. But no matter, which one I use, both is rendered as class attributes in markup.

So why there are two attributes with the same purpose?


回答1:


There is simply no class attribute in JSF components.

From the doc, attribute styleClass :

Space-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup.

The styleClass is simply converted as class in the rendered HTML.

More info :

  • h:commandButton



回答2:


See this references:

http://www.roseindia.net/jsf/commandButton.shtml

http://www.developersbook.com/jsf/jsf-tags-reference/html/commandButton.php

style: If you want ot add any CSS with the component then you can put the style as the value of the attribute. Added CSS will be applied on for the component.

styleClass: This attribute holds the CSS class name which is defined in the external style sheet.

The attribute style in JSF is equivalent to attribute style in HTML.

The attribute styleClass in JSF is equivalent to attribute class in HTML.

Regards



来源:https://stackoverflow.com/questions/20884950/what-is-the-difference-between-class-and-styleclass-attributes-in-jsf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!