Method one: change the whole application’s skin
RichFaces comes with several skins:
To use a skin, all you need to do is set the name in web.xml file:
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>ruby</param-value>
</context-param>
Suppose you like the skin, but you want to make some small changes to it. Here is what to do.
Unzip richfaces-impl-3.x.x.GA.jar file. All the skin files are under META-INF/skin
Take the skin you want to modify and save it under a different name in the root of your Java source folder. For example yourskinname.skin.properties
Open the file and change the parameter you need. For example, changing the general font from 11px to 14px: generalSizeFont=14px,then just set the new skin in web.xml file:
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value> yourskinname </param-value>
</context-param>
Save and restart the server. Then you can see the change
Method two: change the component’s skin(Plug-n-skin)
Copy and paste these Maven instructions to command line and execute them.
mvn archetype:create
-DarchetypeGroupId=org.richfaces.cdk
-DarchetypeArtifactId=maven-archetype-plug-n-skin
-DarchetypeVersion= 3.2.2.GA
-DartifactId=skin
-DgroupId=GROUP-ID
-Dversion= 1.0.-SNAPSHOT
Then, in the root folder of Maven project (the one that contains "pom.xml" file) you should run the following command in the command line:
mvn cdk:add-skin -DbaseSkin=blueSky -DcreateExt=true -Dname=PlugnSkinDemo -Dpackage=SKINPACKAGE
Now you can start editing the XCSS files located in "\src\main\resources\SKIN-PACKAGE\SKIN-
NAME\css\". New style properties can be assigned to the selectors (the selectors listed in the
XCSS files) in two ways, which are both valid, and it’s up to the developer what way to choose.
The first way is to give css properties to the given selectors, such as:
<f:verbatim>
<![CDATA[
.rich-panel-header {
font-weight:bold;background:#999999;
border:3px solid #CD0000;
}
]]>
</f:verbatim>
The only thing, you have to keep in mind is that the selectors must be inside <f:verbatim> <![CDATA[ ...]]> </f:verbatim> tags
The second way is to give the selectors properties and values (skin).such as:
<u:selector name=".rich-panel">
<u:style name="background-color" skin="headerBackgroundColor"/>
<u:style name="border-width" skin="tableBorderWidth"/>
<u:style name="border-style" value="solid" />
<u:style name="border-color" value="#9A32CD" />
</u:selector>
Annotation: “skin” means use the base skin’s feature
But you have to bear in mind that the XCSS tags have to be placed outside <f: verbatim> <![CDATA[ ...]]> </f:verbatim>
Now we will see how font style of a standard HTML element can be changed. We will take submit button for example.Please,open "extended.xcss" file located in "skin\src\main\resources\skinpackage\plugnskindemo\css\" and put “ font-weight: bold; “ inside the curly braces of these coma separated selectors ,the CSS code should look like this.
button[type="button"], button[type="reset"],
button[type="submit"], input[type="re
input[type="submit"], input[type="button"] {
font-weight: bold;
}
As you read in the previous section, the skin should be built in the "skin" folder of the skin project by executing "mvn clean install "command. This procedure results in creating a "target" folder that contains a .jar file with a compiled new skin, it our case the file is named "skin-1.0.-SNAPSHOT.jar". The next step is to import the new PlugnSkinDemo skin into the project.
What you need to do in order to have the new skin imported to the project is to
• Copy the "skin-1.0.-SNAPSHOT.jar" file to the "\WebContent\WEB-INF\lib\" folder.
Annotation: If you don’t want to add the xxx.jar to your project, you can use myeclipse to configure the bulidpath and add your skin project to web project
• Add the new skin's name to the "web.xml" file. It is done like this
<context-param>
<param-name>org.ajax4jsf.SKIN</param-name>
<param-value>PlugnSkinDemo</param-value>
<context-param>
Please, do not forget that standard controls skinning has to be enabled in the "web.xml" file, which
can be done by adding the following code to the "web.xml" file:
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
OK, everything is done, restart your server and enjoy your new skin.
分享到:
相关推荐
- **皮肤配置:** 描述了如何使用RichFaces提供的皮肤功能自定义界面样式。 - **为什么使用皮肤:** 强调了皮肤化的重要性及其带来的好处。 - **使用皮肤:** 提供了具体的步骤来应用不同的皮肤。 - **例子:** ...
2. **组件库的灵活性**:RichFaces提供了两个核心组件库——Core Ajax和UI。其中,Core库负责将Ajax功能融入现有页面,无需额外的JavaScript编码或组件替换;UI库则提供了一系列丰富的组件,用于构建复杂的用户界面...
- **创建和使用自定义皮肤文件**:讲解如何根据需要创建新的皮肤文件。 - **内置的可定制化皮肤**:介绍框架自带的几种标准皮肤风格。 - **运行时更改皮肤**:探讨在应用运行过程中更改皮肤的方法。 - **标准...
4. **皮肤和主题:** RichFaces 允许自定义皮肤和主题,以满足不同应用的视觉需求。 5. **生命周期管理:** JSF 有自己的一套生命周期,包括初始化、应用请求值、处理验证、应用业务逻辑和渲染响应。RichFaces 集成...
RichFaces主要包含两个组件库:Core Ajax和UI库。Core库允许将Ajax功能添加到现有的JSF页面,无需编写JavaScript代码或替换现有组件。它提供页面级别的Ajax支持,允许定义页面事件,这些事件触发Ajax请求并在服务器...
RichFaces 4.5的Java API还支持事件处理,如`org.richfaces.event.AjaxBehaviorEvent`,它继承了JSF的`javax.faces.event.BehaviorEvent`,用于在AJAX请求生命周期中触发自定义行为。开发者可以使用这些事件来实现...
1. **AJAX支持**:RichFaces引入了一种称为XHTML的自定义标记,这些标记支持AJAX操作,使得部分页面更新成为可能,提高了应用的响应速度。例如,`<rich:component>`标签可以用于调用异步方法,更新页面特定区域。 2...
- **Skinning and Theming**:RichFaces允许自定义皮肤和主题,这在创建符合企业风格的UI时非常有用。 4. Demo源码分析 - **Examples**:此目录下的每个子目录都是一个单独的示例,展示了如何使用特定的RichFaces...
3. 皮肤和主题: RichFaces支持自定义皮肤和主题,允许开发者根据需求调整UI样式,以满足不同项目的需求。 三、核心组件 1. RichInput components:如AutoComplete、FileUpload等,提供了更丰富的输入方式,增强了...
- **预定义皮肤**:提供了大量的预定义皮肤供开发者使用,同时也支持自定义皮肤的创建。 6. **自动化测试工具**: - **自动化测试框架**:计划中的自动化测试工具将能够生成测试案例,帮助开发者更快地开发组件和...
3. **皮肤和主题**:RichFaces 3.0.0提供了多种预定义的皮肤和主题,可以根据项目需求快速定制UI样式,确保应用与企业品牌一致。 4. **事件处理**: RichFaces支持自定义服务器端和客户端事件,使得开发者可以灵活...
5. **皮肤和主题** - RichFaces 支持自定义皮肤和主题,允许开发者根据需求改变组件的外观和样式。 6. **事件处理** - RichFaces 提供了丰富的事件模型,允许开发者监听和响应用户操作或系统事件。 7. **集成与扩展*...
3. **事件处理**:提供了一种灵活的方式来处理客户端和服务器端的事件,可以自定义触发器和事件监听器,增强应用交互性。 4. **皮肤和主题**:支持CSS主题,允许开发者轻松更改组件样式,满足不同项目需求。 5. **...
3. **richfaces-core-impl-4.0.0.Final.jar**:这是RichFaces核心实现的库,包含了许多基础服务和功能,如事件处理、Ajax支持、皮肤化和渲染。这个库是RichFaces框架的核心部分,负责处理与JSF集成、请求处理和组件...
文档应该包含了组件的详细使用方法、示例代码、配置指导以及常见问题解答等内容。在使用过程中,开发者可以按照文档逐步了解和掌握各个组件的用法,快速上手并解决实际问题。 总之,RichFaces是JSF开发中的有力工具...
- **皮肤和样式**:支持自定义CSS皮肤,使得UI风格可以统一且易于更改。 **6. 性能优化与调试** - **Ajax优化**:通过设置Ajax响应缓存、延迟加载和事件合并来提升性能。 - **调试工具**:如RichFaces的Ajax Debug ...
**Richfaces ShowCase离线包** 是一个专为开发者设计的资源包,它包含了Richfaces框架的演示示例,能够帮助用户在没有网络连接的情况下也能深入理解和学习Richfaces的功能和用法。这个离线包特别适合那些需要在本地...
- **第六章至第八章:进阶技术** ——探讨了如何利用RichFaces进行表单验证、国际化处理以及实现自定义组件的方法。 - **第九章:最佳实践** ——分享了一些实际开发中的经验教训,帮助读者更好地运用RichFaces解决...