ADF: Styling components by its id
If we want to change the style of a component we usually use skinning and its selectors or we use the styleClass property of the components and creating a class in the css file.
Although it is not a usual way to apply styles to a component I am going to show you how to style any component using its id.
If we have a button for example in a page and it is not surrounded by any naming container, for example a panelCollection or a region we can use its id to style the component
As soon as that component in surrounded by any naming container the id generated in html will change, and for example it will be “pc1:b2” if we have it in a panelCollection, or “r1:0:b1” if we have it in a region.
You can check the code generated by inspecting the page once you run it.
If we try to use the new id “pc1:b2” you will see that button’s style has not changed.
In CSS we have some special characters like these ones.
$, %, &, !, “, #, ‘, (, ), *, :, ;,<, =, >, +, ,, -, ., /, ?, @, [, , ], ^, `, {, |, }, ~
The way to fix it is to scape the special characters. To do this we have to look at the unicode table and look for the character
In this example the unicode value for ‘:’ is ‘3a’.
Once we have the unicode value for our character we have to replace ‘:’ by ‘3a ‘.
Don’t forget to add a space after the unicode value.
Now if we run the application we can see that the button’s style has changed.