Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 377
east825 Avatar asked Jan 02 '14 14:01

east825


People also ask

What is StyleClass in Primefaces?

StyleClass manages css classes declaratively to during enter/leave animations or just to toggle classes on an element.

What is the difference between class and style in HTML?

So the difference between both is you can re-use classes whereas you can't re-use inline styles. Save this answer.

How to use 2 classes in one div?

To define multiple classes, separate the class names with a space, e.g. <div class="city main">. The element will be styled according to all the classes specified.

What is a div class in HTML?

The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!


2 Answers

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
like image 98
Alexandre Lavoie Avatar answered Oct 23 '22 18:10

Alexandre Lavoie


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

like image 24
esmoreno Avatar answered Oct 23 '22 18:10

esmoreno