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. dnsunlocker解决

    环境:windows 10 中文企业版,firefox47, chrome51 安装了某个国外程序后,浏览器各种不正常,打开网页慢,或是无法打开,更严重的是会弹广告,各种广告. 然后在控制面板中卸载了 ...

  2. Win2008上.NET4.0部署出错HTTP 错误 500.21 - Internal Server Error的解决方法

    原因:在安装Framework v4.0之后,再启用IIS,导致Framework没有完全安装 解决:开始->所有程序->附件->鼠标右键点击“命令提示符”->以管理员身份运行 ...

  3. javascript位置相关知识点整理

    1.css指定元素的位置采用的是文档坐标: 2.js查询元素位置的方法返回的是元素在视口中的位置,即视口坐标: 如何获得元素的位置和尺寸 获得元素的位置和尺寸可以通过getBoundingClient ...

  4. jquery+bootstrap使用数字增减按钮

    <div class="container"> <div class="page-header"><h1>Bootstrap ...

  5. hwclock 显示或设置CMOS时间

    显示或设置CMOS时间 hwclock [options] 选项 -r               默认选项,读取并打印CMOS时间 -s               将CMOS时间设置为系统时间 - ...

  6. PagerAdapter 用法

    PagerAdapter简介 PagerAdapter是android.support.v4包中的类,它的子类有FragmentPagerAdapter, FragmentStatePagerAdap ...

  7. eclipse下package的命名规范

    Java的包名都有小写单词组成,类名首字母大写:包的路径符合所开发的 系统模块的 定义,比如生产对生产,物资对物资,基础类对基础类.以便看了包名就明白是哪个模块,从而直接到对应包里找相应的实现. 由于 ...

  8. PHP与MySQL

    这周学习了PHP与MySQL的搭接下面来给大家分享一下: 1.账号注册,论坛发帖... 思路:通过form表单提交到PHP页面,PHP页面往MySQL中插入数据: 2.账号登陆 思路:form提交数据 ...

  9. linux基础学习2

    http://www.chengzhier.com <a href="http://www.chengzhier.com">橙汁儿网</a> 1. date ...

  10. jQuery自定义插件

    jQuery自定义插件 jQuery自定义插件按照功能分类,可以分为三类, 1>封装对象方法的插件,(也就是基于某个DOM元素的jQuery对象,局部的) 2>封装全局函数的插件,   ( ...