Forums de discussion

Customize the style class for h:message(s)?

Jani Halinen, modifié il y a 11 années.

Customize the style class for h:message(s)?

New Member Publications: 2 Date d'inscription: 03/04/12 Publications récentes
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:

<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.
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Customize the style class for h:message(s)?

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
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, modifié il y a 11 années.

RE: Customize the style class for h:message(s)? (Réponse)

New Member Publications: 2 Date d'inscription: 03/04/12 Publications récentes
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>