Again a post about ADF Basics for beginners, about contentStyle and inlineStyle property of components.
I have seen lots of thread on OTN about changing basic styles of the component . for example,
How to change font size of inputText ?
How to change color of inputText/outputText ?
How to change color of link or button ?
and everyone starts creating a css/skin for these minor changes but there is no need of that
Skin should be used for complex styles or you have apply same style to all components of your application
If you will read API docs then you will know this, See what docs says about inlineStyle property-
The CSS styles to use for this component. This is intended for basic style changes; you should use the skinning mechanism if you require any complex style changes. The inlineStyle is a set of CSS styles that are applied to the root DOM element of the component. Be aware that because of browser CSS precedence rules, CSS rendered on a DOM element takes precedence over external stylesheets like the skin file. Therefore skins will not be able to override what you set on this attribute.
Difference between contentStyle and inlineStyle –
contentStyle property used to style content part of component like if you want to change color of inputText or any other input component then you have to specify this in contentStyle property of that component
inlineStyle is about whole component and also available in output (outputText) or collection (table, tree etc) component’s property where contentStyle is not there. This can be use to set width, height ,border or color of output components etc.
So this is enough about theory , no one likes theory 😉 , Everyone is looking for some code that is ready to use
Let’s see some practical usage of both properties –
Change font, color, size(width), padding of input components (af:inputText, af:inputDate, af:selectOneChoice etc)-
Used this in contentStyle property of components
and check the output
you can also change input text to uppercase , lowercase, Initcap using contentStyle property, just use any of this –
text-transform:uppercase; // To change in uppercase
text-transform:lowercase; //To change in lowercase
text-transform:capitalize; //To change in initcap
Change properties of output components , color of link/button –
Output components doesn’t have contentStyle property as there is not content part in component , here we make use of inlineStyle property
See what happens on applying same style in outputText and link using inlineStyle
It looks good 🙂 , but same style doesn’t work for button because button has multiple root element (we can only change width, color of text and font of button but background color and other styling can not be changed using inlineStyle property)
For more detail about button skinning check – Customize af:button (font, shape, size, color etc) using skinning -Oracle ADF (12.1.3)
Change data collection components (af:table, af:treeTable,etc) height, width –
just write in inlineStyle property like this
background color will be applied on empty area of table and color will be applicable on column header and EmptyText
Remember to set table’s height using inlineStyle ensure that autoHeightRows should be set to -1
In same way we can change color of columns too, see i have used different background colors (set background-color:colorName; in inlineStyle of af:column) for columns and it looks like this
Now it’s your turn , try more combination on different components. you can do a lot using contentStyle and inlineStyle property. Remember all these changes can be done using skin also but if have some minor changes then why use skin , when framework provides these wonderful properties
Cheers 🙂 Happy Learning
I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF