
The rcfaces-1.2.0.RELEASE archive file contains the following directories:
For integration build:
The rcfaces-imageIO-*.jar is used by RCFaces to generate on the fly multiple versions of an image (hover, disabled, scaled, ...).
<servlet>
<servlet-name>Rcfaces resources Servlet</servlet-name>
<servlet-class>org.rcfaces.renderkit.html.internal.resource.ResourcesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Rcfaces resources Servlet</servlet-name>
<url-pattern>/rc-fwk/*</url-pattern>
</servlet-mapping>
<?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>RCFacesFormSample</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Rcfaces resources Servlet</servlet-name>
<servlet-class>org.rcfaces.renderkit.html.internal.resource.ResourcesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Rcfaces resources Servlet</servlet-name>
<url-pattern>/rc-fwk/*</url-pattern>
</servlet-mapping>
</web-app>
We want to add data from a form into a data grid, so we need to build a JSF managed bean to get fields value and put them in the table's model. The best solution would be to do two managed beans; however for this simple demo only one is necessary.
Create a java object named GridBean in the org.rcfaces.rcfacesformsample.managed package :
package org.rcfaces.rcfacesformsample.managed;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.rcfaces.core.event.SelectionEvent;
public class GridBean {
private static final DateFormat dateFormat = new SimpleDateFormat(
"dd/MM/yyyy");
private List<Row> rows; // Data model of dataGrid
private Row newRow; // Use by the form field
public GridBean() {
rows = new ArrayList<Row>();
rows.add(new Row("Didier", "La Rochelle", "1/1/1882"));
rows.add(new Row("Fred", "La Rochelle", "02/02/1901"));
rows.add(new Row("Olivier", "La Rochelle", "11/4/1975"));
rows.add(new Row("Christine", "La Rochelle", "4/12/1980"));
rows.add(new Row("Jean-Marc", "La Rochelle", "4/12/1980"));
rows.add(new Row("JB", "La Rochelle", "1/8/2000"));
}
// called by the actionListner of submit button
public void addRow(SelectionEvent event) {
rows.add(new Row(newRow.getName(), newRow.getCity(), newRow
.getBirthDate()));
newRow = null;
}
public List<Row> getRows() {
return rows;
}
public void setRows(List<Row> rows) {
this.rows = rows;
}
public Row getNewRow() {
if (newRow == null) {
newRow = new Row();
}
return newRow;
}
public void setNewRow(Row newRow) {
this.newRow = newRow;
}
public class Row {
private String name;
private String city;
private Date birthDate;
public Row() {
}
public Row(String name, String city, String birthDate) {
this.name = name;
this.city = city;
try {
this.birthDate = dateFormat.parse(birthDate);
} catch (ParseException ex) {
throw new IllegalArgumentException(ex);
}
}
public Row(String name, String city, Date birthDate) {
this.name = name;
this.city = city;
this.birthDate = birthDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
}
}
<managed-bean>
<managed-bean-name>gridBean</managed-bean-name>
<managed-bean-class>org.rcfaces.rcfacesformsample.managed.GridBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:forward page="form.jsf"/>
</jsp:root>
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:v="http://rcfaces.org/core" xmlns:vh="http://rcfaces.org/html">
<jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
<jsp:output omit-xml-declaration="true" doctype-root-element="html"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd" />
<f:view>
<html>
<head>
<vh:init /> <!-- !important tag -->
</head>
<vh:javaScriptCollector>
<body>
<h:form>
<v:fieldSet text="Form">
<!-- container -->
<div style="margin-top: 10px;">
What is your name :
<v:message for="field1" showDetail="false" showSummary="true"
showIfMessage="true" />
<v:textEntry id="field1" columnNumber="30"
value="#{gridBean.newRow.name}" required="true" />
</div>
<div style="margin-top: 10px;">
Where do you come from :
<v:message for="field2" showDetail="false" showSummary="true"
showIfMessage="true" />
<v:textEntry id="field2" columnNumber="30"
value="#{gridBean.newRow.city}" required="true"
emptyMessage="your city" />
</div>
<div style="margin: 10px 0;">
When were you born :
<v:message for="fieldDate" showDetail="false" showSummary="true"
showIfMessage="true" />
<v:dateEntry id="fieldDate" value="#{gridBean.newRow.birthDate}"
required="true" />
<v:dateChooser id="date" for="fieldDate" />
</div>
<v:submitButton text="submit" actionListener="#{gridBean.addRow}" />
</v:fieldSet>
<div style="margin-top: 10px;">
<v:dataGrid id="tableId"
width="450" value="#{gridBean.rows}" var="row" rows="3">
<v:dataColumn text="Name" sortListener="alpha" value="#{row.name}" />
<v:dataColumn text="city" sortListener="alpha" value="#{row.city}" />
<v:dataColumn text="BirthDate" value="#{row.birthDate}"
alignment="center" />
</v:dataGrid>
<v:pager for="tableId"></v:pager>
</div>
</h:form>
</body>
</vh:javaScriptCollector>
</html>
</f:view>
</jsp:root>
You should see :
