PrimeFaces is using jQuery ThemeRoller CSS theme framework, and come with 30+ pre-designed themes that you can download and apply in seconds. In this tutorial, we will show you how to change a theme n PriceFaces.

 

There are two ways to change a theme :

  1. Using Maven to download and apply.
  2. Download manually and apply.

1. Maven Download

For Maven user, visit this PrimeFaces available theme, select a theme and remember the theme, defined in Maven and configure the web.xml.

In this case, we will show you how to change a default theme (aristo) to glass-x theme.

File : pom.xml

Markup
    //...
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories> <dependencies> <dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>glass-x</artifactId>
<version>1.0.6</version>
</dependency> <dependencies>
Theme version?
Visit this PrimeFaces repository directly, check the theme folder to know which one is the latest.

File : web.xml

Markup
    //...
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>glass-x</param-value>
</context-param>

Run it, the theme color will be changed, and looking inside the source code, it point to glass-x now.

Markup
<!-- html source code -->
<link type="text/css" rel="stylesheet" href="/project/faces/javax.faces.resource/theme.css?ln=primefaces-glass-x" />

2. Download Manually

For non-Maven user, just visit the PrimeFaces’s repository and download the theme jar manually, and put it in your project classpath, and configure the web.xml.

File : web.xml

Markup
    //...
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>glass-x</param-value>
</context-param>

Change Theme Dynamic

A nice trip to use EL expression to apply a theme dynamically. See following code snippet :

File : web.xml

Markup
  <context-param>
<param-name>primefaces.THEME</param-name>
<param-value>#{loggedInUser.preferences.theme}</param-value>
</context-param>

P.S Reference – PrimeFaces user guide

http://primefaces.org/themes

References

  1. PrimeFaces Available Themes
  2. jQuery Theme Roller
  3. PrimeFaces User Guide

更改primefaces theme的更多相关文章

  1. jekyll bootstrap更改主题theme

    使用主题 介绍: 由于JB版本号0.2.X的主题,如今全然是模块化的.他们跟踪和单独版本号的主题包. 这让每一个人都能够自由公布和共享主题. Jekyll-Bootstrap v 0.2.x仅仅附带t ...

  2. JSF primefaces session view expired 会话失效后页面跳转

    web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=" ...

  3. Primefaces的fileUpload组件使用

    最近在学习Primefaces(当然也是项目中需要用的).在使用其fileUpload遇到了不小的困难,现总结一下供大家及我自己今后参考使用. 1.首先是使用环境配置:正常的Primefaces开发环 ...

  4. ActionBar更改背景颜色(主题)

    1.默认是黑色的背景, 2.更改主题theme为Theme.AppCompat.Light即可,清单文件主题如下: <application android:name="com.ith ...

  5. 做了面向互联网部署的Dynamics 365 CE更改AD FS的登录页面

    摘要: 微软动态CRM专家罗勇 ,回复306或者20190307可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 默认情况下A ...

  6. 继承AppCompatActivity的Activity隐藏标题栏

    继承了AppCompatActivity的Activity无法通过调用requestWindowFeature(Window.FEATURE_NO_TITLE)来隐藏标题栏. public class ...

  7. Jboss7.1 加入realm auth认证 bootsfaces 美化的登录页面

    jboss-as-7.1.1.Final\standalone\configuration: 1, standalone.xml中 <security-domains>标签里面添加: &l ...

  8. 【Ext.Net学习笔记】03:Ext.Net DirectEvents用法详解、DirectMethods用法详解

    Ext.Net通过DirectEvents进行服务器端异步的事件处理.[Ext.Net学习笔记]02:Ext.Net用法概览.Ext.Net MessageBus用法.Ext.Net布局 中已经简单的 ...

  9. Ext.Net学习笔记07:Ext.Net DirectMethods用法详解

    使用DirectMethods在JS中调用C#方法 我承认,这个标题有点噱头,其实应该是通过DirectMethods,在JS中通过异步调用的方式执行服务器端的方法. 来看一个例子吧: [Direct ...

随机推荐

  1. web安全——数据库(mysql)

    简介 数据安全是现在互联网安全非常重要一个环节.而且一旦数据出现问题是不可逆的,甚至是灾难性的. 有一些防护措施应该在前面几个博文说过了,就不再赘述.比如通过防火墙控制,通过系统的用户控制,通过web ...

  2. FFmpeg 1.2 for Android 生成一个动态库

    上一篇<FFmpeg 1.2 for Android 编译动态库>里沃特跟大家介绍了如何编译动态库,但当时所生成的动态库总共包含10个so文件,这样要是加载起来会严重影响软件的启动速度,后 ...

  3. 千呼万唤岂出来,写款软件不容易——Visual Entity 2.0 发布

    在各位用户不继的催更中,终于完成了这次更新.Visual Entity这个软件发布于 2011年,这个软件完成后,便上班去了,也没有做什么推广工作.所以知道的用户并不多,尽管它是个非常好用.并且免费的 ...

  4. gulp插件gulp-usemin简单使用

    关于什么是gulp,它和grunt有什么区别等问题,这里不做任何介绍.本文主要介绍如何使用gulp-usemin这款插件,同时也会简单介绍本文中用到的一些插件. 什么是gulp-usemin 用来将H ...

  5. 维克里拍卖 Vickrey auction

    https://en.wikipedia.org/wiki/Vickrey_auction 维克里拍卖(Vickrey auction),即次价密封投标拍卖(Second-price sealed-b ...

  6. team foundation server——网络代码管理工具

    像我们平时有时会莫名的弹出一个如下图所示的提示框,这个是什么呢?这个就是有人用team foundation server进行过代码管理的项目 那么team foundation server到底是什 ...

  7. TCP/UDP,SOCKET网络通信,C++/Java实现

    趁这两天没事干,就把网络通信这一块搞一搞,C/S方面的了解一下,很重要! TCP Server/Client

  8. easyui-datagrid 报错:TypeError: col is null

    一般是由于设置的属性用到的列,如: idField:'aa', sortName:'bb' 等在 columns:[[{field:'cc',width:80,title:'列cc'}, {field ...

  9. 线性回归&&code

    # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from certifi import __mai ...

  10. Mysql-ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

    方法一:1.关闭mysql   # service mysqld stop2.屏蔽权限   # mysqld_safe --skip-grant-table   屏幕出现: Starting demo ...