我已将项目更新为richfaces 4.1.0和JSF 2.0。我已经明显改变了maven依赖关系,更新了web.xml,faces-config.xml,从* .jsp文件转换为* .xhtml文件,将所有head,body,form更新为h:head,h:body,h:form 。但是,我的页面布局和a4j:ajax行为存在严重问题。我认为最好只列出问题:
我的丰富:数据表皮肤停止工作。我甚至尝试从标签中删除columnClass等属性,使其保留默认的bluesky皮肤,但结果看起来就像一个简单的html表(没有行,没有背景,没有颜色)。
a4j:axjax标签工作得更糟糕a4j:支持确实如此。对于我的selectOneMenus,我尝试了event =“change”但它不起作用。只有在将valueChangedListener添加到标记并尝试了event =“valueChange”之后才能使用它。
rich:日历元素不是“可点击的” - 当我将光标移到按钮上以弹出日历时它不会改变,当我点击按钮时没有任何反应。我还需要a4j:ajax,但我无法测试它。
虽然event =“valueChange”适用于selectOneMenu,但我的a4j:mediaOutput图像不会重新渲染。图表是我切换到JSF 2.0的原因,因为我需要使用session-data-helper机制来加载图像。当使用session-data-helper加载数据时,是否有一种特殊的机制来重新渲染(或现在用'aj:ajax'渲染')这个元素?
以下是web.xml和index.xhtml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="2.5">
<display-name>presentation graph</display-name>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/data-helper.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>javac.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
的index.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:sdh="http://richfaces.org/session-data-helper">
<h:head>
<title>Graph presentation</title>
<h:outputStylesheet name="style.css" library="css" />
</h:head>
<h:body>
<h:form id="form">
<div class="grid_2">
<rich:calendar value="#{formBean.date}"
id="date" popup="true" datePattern="yyyy/MM/dd"
showApplyButton="false" cellWidth="24px" cellHeight="22px" style="width:200px">
<a4j:ajax event="change" render="resultTable chart" execute="@this" listener="#{formBean.dateSelected}"/>
</rich:calendar>
</div>
<div class="grid_2">
<h:selectOneMenu id="selectMenu" value="#{formBean.model.selected_id}" valueChangeListener="#{formBean.selected}" styleClass="comboBoxes">
<f:selectItems value="#{formBean.myModelValues}" />
<a4j:ajax execute="@this" event="valueChange" render="resultTable chart" ajaxSingle="true"/>
</h:selectOneMenu>
</div>
<div id="list" class="container2">
<rich:dataTable id="resultTable" value="#{formBean.results}" var="query" rows="10" headerClass="columnclass" rowClasses="rowclass" styleClass="datatable" cellpadding="1" cellspacing="1" rules="rows" >
<rich:column headerClass="columnclass" width="100" >
<f:facet name="header">
<h:outputText value="Values" style="align:center; text-align:center; " />
</f:facet>
<h:outputText value="#{query.val}" />
</rich:column>
<rich:column headerClass="columnclass" width="100" >
<f:facet name="header">
<h:outputText value="Models" style="align:center; text-align:center; " />
</f:facet>
<h:outputText value="#{query.model}" />
</rich:column>
<f:facet name="footer">
<rich:dataScroller page="#{formBean.page}" style="margin-left: 15%; margin-right: 15%; width: 70%;">
<f:facet name="first">
<h:outputText value="First" />
</f:facet>
<f:facet name="last">
<h:outputText value="Last" />
</f:facet>
</rich:dataScroller>
</f:facet>
</rich:dataTable>
</div>
<div id="graph" class="container2">
<a4j:mediaOutput
id="chart"
element="img"
cacheable="false"
session="true"
createContent="#{mediaPainter.drawChartImage}"
value = "#{sdh:storeData(formBean.chartData)}"
mimeType="image/jpeg"
/>
</div>
</h:form>
</h:body>
</html>
这是使用webapp部署的.jar文件列表:
cssparser-0.9.5.jar
MySQL的连接器的Java-5.1.18.jar
的Ehcache-1.6.0.jar
RichFaces的组件-API 4.1.0.Final.jar
番石榴r08.jar
RichFaces的组件-UI-4.1.0.Final.jar
javax.faces-2.1.3.jar
RichFaces的核心-API 4.1.0.Final.jar
jcommon-1.0.16.jar
RichFaces的核心 - IMPL-4.1.0.Final.jar
jfreechart的-1.0.13.jar
SAC-1.3.jar
JSTL-API-1.2.jar
这是pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.models.presentation.</groupId>
<artifactId>graph_presentation</artifactId>
<name>graph_presentation</name>
<version>Final</version>
<packaging>war</packaging>
<url>http://jboss.org/richfaces</url>
<repositories>
<!-- You should seriously consider using a repository manager or declare repositories in your settings.xml.
See http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/ -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<!-- Setting this property using archetype-metadata.xml requiredPorperty
so that generated project uses correct version of richfaces.
-->
<org.richfaces.bom.version>4.1.0.Final</org.richfaces.bom.version>
</properties>
<build>
<finalName>individuel_broadcast3</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>${org.richfaces.bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jee6</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory>
<classifier>jee6</classifier>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>jee6</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory>
<classifier>jee6</classifier>
<packagingExcludes>WEB-INF/lib/javax.faces*</packagingExcludes>
<warSourceExcludes>WEB-INF/lib/javax.faces*</warSourceExcludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>