Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Jani Halinen
Customize the style class for h:message(s)?
January 11, 2013 5:07 AM
Answer

Jani Halinen

Rank: New Member

Posts: 2

Join Date: April 3, 2012

Recent Posts

Is it possible to change/override the style class for validation messages?

I can add my own style class using the error/fatal/info/warn/Class attribute of the message tag but it will only append the parameter before the portlet-msq-error class and the result will be something like:

1<span class="[color=#ff0000][b]myerrorclass[/b] portlet-msg-error[/color]">Mandatory field</span>


This is implemented in MessageAttributes.java. I've been googling around but don't seem to find a way to override/customize this functionality.

I'm asking this because I can't change the portal's theme and the portlet-msg-error -style messes the layout. The JSR 286 standard CSS class names would be just fine if I was able to modify the portal's theme.
David H Nebinger
RE: Customize the style class for h:message(s)?
January 11, 2013 5:15 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7252

Join Date: September 1, 2006

Recent Posts

Dude, any style that you do to "span.myerrorclass.portlet-msg-error" will override whatever the portal tries to apply. All you need to do is 'undo' the styling that the portal theme applies until you get it to where you want to be.

Using two classes like above, the rule has a higher specificity so the portal's styling does not get applied.
Jani Halinen
RE: Customize the style class for h:message(s)?
January 17, 2013 4:35 AM
Answer

Jani Halinen

Rank: New Member

Posts: 2

Join Date: April 3, 2012

Recent Posts

Thank you for your reply.

Overriding the css is certainly a good approach. I didn't want to touch any css, so I reconfigured the component-class for HtmlMessage:

@faces-config.xml:

<component>
<component-type>javax.faces.HtmlMessage</component-type>
<component-class>com.liferay.faces.bridge.component.html.HtmlMessageBridgeImpl</component-class>
<component-class>javax.faces.component.html.HtmlMessage</component-class>
<component-extension>
<base-component-type>javax.faces.Message</base-component-type>
<renderer-type>javax.faces.Message</renderer-type>
</component-extension>
</component>