掲示板

Primefaces theme override custom Liferay theme

10年前 に Philip Jastrzębowski によって更新されました。

Primefaces theme override custom Liferay theme

New Member 投稿: 12 参加年月日: 13/10/06 最新の投稿
Hi all,
On the portal we're developing we faced issue with CSS imports. We created a custom theme in which we define all our css classes. We're also using Primefaces library for some portlets. After defining class for particular PF component we stylize it in the theme. And now here come the problem. If this component we stylize has also his own primefaces classes that set different values for any property, it overrides CSS value in our theme. I give example, becouse it might seem vague:

We define button:
<p:commandbutton styleClass="buttonClass" (...) />


And stylize it in our theme:
.buttonClass {
 backgroud: color: green;
}


But the result is not as expected (green), becouse primefaces has also got his own libraries (such as aristo) for classes e.g. .ui-widget-content .ui-state-default and so on that overrides our theme. I noticed that also defining that property in portlet CSS is overwritten.

Now we are looking for solution that avoids using !important clause in each our CSS property or defining our primefaces theme. Is there any simple soultion for that problem?
thumbnail
10年前 に Juan Gonzalez によって更新されました。

RE: Primefaces theme override custom Liferay theme

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Did you try setting the theme to NONE in web.xml?

<context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>none</param-value>
</context-param>
10年前 に Philip Jastrzębowski によって更新されました。

RE: Primefaces theme override custom Liferay theme

New Member 投稿: 12 参加年月日: 13/10/06 最新の投稿
I guess then it would not use any Primefaces theme at all. I mean we are using some properties from PF theme, but want just to overwrite a few that are defined in our theme.
thumbnail
10年前 に Juan Gonzalez によって更新されました。

RE: Primefaces theme override custom Liferay theme

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Ok I see,

did you try adding the css in <h:head> section?

 <h:head>

<link href="#{request.contextPath}/css/liferay-theme-override.css" rel="stylesheet" type="text/css">

</h:head>
thumbnail
10年前 に Neil Griffin によって更新されました。

RE: Primefaces theme override custom Liferay theme

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
With CSS, the last <link href="..."></link> "wins" so you would need to make sure that the PrimeFaces Theme <link href="..."></link> in the head appears before your own customizations.
10年前 に Philip Jastrzębowski によって更新されました。

RE: Primefaces theme override custom Liferay theme

New Member 投稿: 12 参加年月日: 13/10/06 最新の投稿
Neil Griffin:
With CSS, the last <link href="..."></link> "wins" so you would need to make sure that the PrimeFaces Theme <link href="..."></link> in the head appears before your own customizations.


I know the theory, but don't know how to make my css to be included first. I have no <link href (...) /> for PF css neither in my portlet nor in the theme.
10年前 に Philip Jastrzębowski によって更新されました。

RE: Primefaces theme override custom Liferay theme

New Member 投稿: 12 参加年月日: 13/10/06 最新の投稿
@Juan Gonzalez
Yea, I tried. But even then this css is included befor primefaces' CSSes emoticon
thumbnail
10年前 に Juan Gonzalez によって更新されました。

RE: Primefaces theme override custom Liferay theme

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi Philip,

please try putting

<h:outputstylesheet.. target="head" />


just after <h:body>
10年前 に Philip Jastrzębowski によって更新されました。

RE: Primefaces theme override custom Liferay theme

New Member 投稿: 12 参加年月日: 13/10/06 最新の投稿
Unfortunately still no expected result. Ouput looks the same like in your previous idea.

This CSS sheet overwrite theme css, but is overwritten by PF CSSes.
thumbnail
10年前 に Juan Gonzalez によって更新されました。

RE: Primefaces theme override custom Liferay theme

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi Philip,

can you post here how does your xhtml looks like, and the <head> part in the HTML?

It worked fine for me...
thumbnail
10年前 に Neil Griffin によって更新されました。

RE: Primefaces theme override custom Liferay theme

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Liferay Faces Bridge supports the same type of resource ordering as PrimeFaces found in this blog.

So you can try using <f:facet name="last"> in order to cause your stylesheet to appear last (or at least, after the PrimeFaces theme CSS).