Moved Spring Web Flow to a top level project

This commit is contained in:
Ben Hale
2006-12-21 16:02:27 +00:00
commit e7ecbbc7e5
1083 changed files with 80775 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
# $Header$
# Contains filterable project settings. Setting placeholders in filterable project text
# files will be replaced with these values when the 'statics' build target is run.
#
# You may add static settings directly to this source file in the format:
# setting=value e.g MY_SETTING=myvalue
# This is appropriate usage if you know the setting value will never change.
#
# At build time this source file is copied to the ${target.dir} where additional
# dynamic settings may be appended using the <propertyfile> task. Use this approach
# when a setting value depends on the build or the local user's environment.
#
# An example of this approach is shown below:
#
# build.xml
# <target name="build.prepare" depends="common-targets.build.prepare">
# <!-- Append additional local settings that are applicable to this project -->
# <propertyfile file="${target.filter.file}">
# <!-- key=the name of the setting
# value=the property in your build.properties file that has the local setting value -->
# <entry key="MY_LOCAL_SETTING" value="${my.local.setting}" />
# </propertyfile>
# </target>
#
# This allows for dynamic replacement values that are sourced from local properties files to facilitate
# local user settings.
#
# To refer to filterable settings within project source files like config files, JSPs, or
# other text files use the standard ant placeholder format:
# @SETTING_NAME@ e.g, @MY_SETTING@ and @MY_LOCAL_SETTING@
#
# Your settings:

View File

@@ -0,0 +1,20 @@
log4j.rootCategory=WARN, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${@PROJECT_WEBAPP_NAME@.root}/@PROJECT_WEBAPP_NAME@.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files
log4j.appender.logfile.MaxBackupIndex=3
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#Pattern to output : date priority [category] - <message>line_separator
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n
#Enable webflow debug logging
log4j.category.org.springframework.webflow=DEBUG
log4j.category.org.springframework.binding=DEBUG

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2002-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.shippingrate.domain;
import java.io.Serializable;
import java.math.BigDecimal;
public class Rate implements Serializable {
private BigDecimal value;
public Rate(BigDecimal value) {
this.value = value;
}
public double getDoubleValue() {
return value.doubleValue();
}
public boolean equals(Object o) {
if (!(o instanceof Rate)) {
return false;
}
return value.equals(((Rate)o).value);
}
public int hashCode() {
return value.hashCode();
}
public String toString() {
return value.toString();
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2002-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.shippingrate.domain;
import java.io.Serializable;
public class RateCriteria implements Serializable {
private boolean residential = true;
private String senderZipCode;
private String receiverZipCode;
private String senderCountryCode;
private String receiverCountryCode;
private int packageType = -1;
private double packageWeight;
public int getPackageType() {
return packageType;
}
public void setPackageType(int packageType) {
this.packageType = packageType;
}
public double getPackageWeight() {
return packageWeight;
}
public void setPackageWeight(double packageWeight) {
this.packageWeight = packageWeight;
}
public String getReceiverCountryCode() {
return receiverCountryCode;
}
public void setReceiverCountryCode(String receiverCountryCode) {
this.receiverCountryCode = receiverCountryCode;
}
public String getReceiverZipCode() {
return receiverZipCode;
}
public void setReceiverZipCode(String receiverZipCode) {
this.receiverZipCode = receiverZipCode;
}
public boolean isResidential() {
return residential;
}
public void setResidential(boolean residential) {
this.residential = residential;
}
public String getSenderCountryCode() {
return senderCountryCode;
}
public void setSenderCountryCode(String senderCountryCode) {
this.senderCountryCode = senderCountryCode;
}
public String getSenderZipCode() {
return senderZipCode;
}
public void setSenderZipCode(String senderZipCode) {
this.senderZipCode = senderZipCode;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2002-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.shippingrate.domain;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
public class RateCriteriaValidator implements Validator {
public boolean supports(Class clazz) {
return RateCriteria.class.isAssignableFrom(clazz);
}
public void validate(Object obj, Errors errors) {
RateCriteria criteria = (RateCriteria)obj;
validateSender(criteria, errors);
validateReceiver(criteria, errors);
validatePackageDetails(criteria, errors);
}
public void validateSender(RateCriteria query, Errors errors) {
if (!StringUtils.hasText(query.getSenderCountryCode()) || query.getSenderCountryCode().equals("null")) {
errors.rejectValue("senderCountryCode", "senderCountryCodeRequired", "Sender country code is required");
}
if (!StringUtils.hasText(query.getSenderZipCode())) {
errors.rejectValue("senderZipCode", "senderZipCodeRequired", "Sender zip code is required");
}
}
public void validateReceiver(RateCriteria query, Errors errors) {
if (!StringUtils.hasText(query.getReceiverCountryCode()) || query.getReceiverCountryCode().equals("null")) {
errors.rejectValue("receiverCountryCode", "receiverCountryCodeRequired",
"Receiver country code is required");
}
if (!StringUtils.hasText(query.getReceiverZipCode())) {
errors.rejectValue("receiverZipCode", "receiverZipCodeRequired", "Receiver zip code is required");
}
}
public void validatePackageDetails(RateCriteria query, Errors errors) {
if (query.getPackageType() < 0) {
errors.rejectValue("packageType", "packageTypeRequired", "Package type is required");
}
if (query.getPackageWeight() <= 0) {
errors.rejectValue("packageWeight", "packageWeightRequired", "Package weight is required");
}
}
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright 2002-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.shippingrate.domain;
import java.util.Map;
public interface RateService {
public Map getCountries();
public Map getPackageTypes();
public Rate getRate(RateCriteria criteria);
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2002-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.samples.shippingrate.domain;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
public class StubRateService implements RateService {
public Map getCountries() {
Map countries = new HashMap();
countries.put("US", "United States");
countries.put("CA", "Canada");
return countries;
}
public Map getPackageTypes() {
Map packageTypes = new HashMap();
packageTypes.put("1", "Letter Envelope");
packageTypes.put("2", "Express Box");
packageTypes.put("3", "Tube");
return packageTypes;
}
public Rate getRate(RateCriteria criteria) {
return new Rate(new BigDecimal("1.39"));
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="rateService" class="org.springframework.webflow.samples.shippingrate.domain.StubRateService"/>
</beans>

View File

@@ -0,0 +1 @@
typeMismatch.rateCriteria.packageWeight=Package weight must be a number

View File

@@ -0,0 +1,9 @@
log4j.rootCategory=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
# Enable web flow logging
log4j.category.org.springframework.webflow=DEBUG
log4j.category.org.springframework.binding=DEBUG

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
<start-actions>
<action bean="formAction" method="setupForm" />
</start-actions>
<start-state idref="selectCustomerType" />
<view-state id="selectCustomerType" view="selectCustomer">
<transition on="submit" to="selectSender">
<action bean="formAction" method="bind" />
</transition>
</view-state>
<view-state id="selectSender" view="selectSender">
<render-actions>
<bean-action bean="rateService" method="getCountries">
<method-result name="countries" />
</bean-action>
</render-actions>
<transition on="submit" to="selectReceiver">
<action bean="formAction" method="bindAndValidate">
<attribute name="validatorMethod" value="validateSender" />
</action>
</transition>
</view-state>
<view-state id="selectReceiver" view="selectReceiver">
<render-actions>
<bean-action bean="rateService" method="getCountries">
<method-result name="countries" />
</bean-action>
</render-actions>
<transition on="submit" to="selectPackageDetails">
<action bean="formAction" method="bindAndValidate">
<attribute name="validatorMethod" value="validateReceiver" />
</action>
</transition>
</view-state>
<view-state id="selectPackageDetails" view="selectPackageDetails">
<render-actions>
<bean-action bean="rateService" method="getPackageTypes">
<method-result name="packageTypes" />
</bean-action>
</render-actions>
<transition on="submit" to="findRate">
<action bean="formAction" method="bindAndValidate">
<attribute name="validatorMethod" value="validatePackageDetails" />
</action>
</transition>
</view-state>
<action-state id="findRate">
<bean-action bean="rateService" method="getRate">
<method-arguments>
<argument expression="flowScope.rateCriteria" />
</method-arguments>
<method-result name="rate" />
</bean-action>
<transition on="success" to="showRate" />
</action-state>
<end-state id="showRate" view="showRate" />
</flow>

View File

@@ -0,0 +1,41 @@
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<form action="rates.htm" method="post" id="selectCustomerTypeForm">
<spring:nestedPath path="rateCriteria">
<spring:bind path="residential">
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
</spring:bind>
<fieldset>
<legend>Select your customer profile</legend>
<label>What's most appropriate for you?</label><br>
<spring:bind path="residential">
<label>I'm a private person</label>
<input type="radio" name="${status.expression}" value="true" <c:if test="${status.value == true}">checked</c:if>><br>
</spring:bind>
<spring:bind path="residential">
<label>We're a business, institution or government agency</label>
<input type="radio" name="${status.expression}" value="false" <c:if test="${status.value == false}">checked</c:if>><br>
</spring:bind>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<input type="submit" value="Next" name="_eventId_submit">
</fieldset>
</spring:nestedPath>
<script type="text/javascript">
formRequest('selectCustomerTypeForm');
</script>
</form>

View File

@@ -0,0 +1,46 @@
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<form action="rates.htm" method="post" id="selectPackageDetailsForm">
<spring:nestedPath path="rateCriteria">
<fieldset>
<legend>Select package details</legend>
<spring:bind path="packageType">
<label>Package type</label>
<select name="${status.expression}">
<option value="-1">-- Select package type</option>
<c:forEach items="${packageTypes}" var="packageType">
<option value="${packageType.key}" <c:if test="${status.value == packageType.key}">selected</c:if>>${packageType.value}</option>
</c:forEach>
</select>
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
<br>
</spring:bind>
<spring:bind path="packageWeight">
<label>Package weight</label>
<input type="text" name="${status.expression}" value="${status.value}">
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
<br>
</spring:bind>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<input type="submit" value="Next" name="_eventId_submit">
</fieldset>
</spring:nestedPath>
<script type="text/javascript">
formRequest('selectPackageDetailsForm');
</script>
</form>

View File

@@ -0,0 +1,43 @@
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<form action="rates.htm" method="post" id="selectReceiverForm">
<spring:nestedPath path="rateCriteria">
<fieldset>
<legend>Select receiver location</legend>
<spring:bind path="receiverCountryCode">
<label>Country</label>
<select name="${status.expression}">
<option value="null">-- Select country</option>
<c:forEach items="${countries}" var="country">
<option value="${country.key}" <c:if test="${status.value == country.key}">selected</c:if>>${country.value}</option>
</c:forEach>
</select>
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
<br>
</spring:bind>
<spring:bind path="receiverZipCode">
<label>Zip code</label>
<input type="text" name="${status.expression}" value="${status.value}">
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
<br>
</spring:bind>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<input type="submit" value="Next" name="_eventId_submit">
</fieldset>
<script type="text/javascript">
formRequest('selectReceiverForm');
</script>
</spring:nestedPath>
</form>

View File

@@ -0,0 +1,43 @@
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<form action="rates.htm" method="post" id="selectSenderForm">
<spring:nestedPath path="rateCriteria">
<fieldset>
<legend>Select sender location</legend>
<spring:bind path="senderCountryCode">
<label>Country</label>
<select name="${status.expression}">
<option value="null">-- Select country</option>
<c:forEach items="${countries}" var="country">
<option value="${country.key}" <c:if test="${status.value == country.key}">selected</c:if>>${country.value}</option>
</c:forEach>
</select>
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
<br>
</spring:bind>
<spring:bind path="senderZipCode">
<label>Zip code</label>
<input type="text" name="${status.expression}" value="${status.value}">
<c:if test="${status.error}">
<span class="error">${status.errorMessage}</span>
</c:if>
<br>
</spring:bind>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<input type="submit" value="Next" name="_eventId_submit">
</fieldset>
</spring:nestedPath>
<script type="text/javascript">
formRequest('selectSenderForm');
</script>
</form>

View File

@@ -0,0 +1,13 @@
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<form action="rates.htm" method="post">
<fieldset>
<legend>Rate details</legend>
<label>Your shipping rate is: <span>${rate}</span>
</fieldset>
</form>

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd">
<!--
A general purpose controller for the entire "Point of Sale (POS)" application,
exposed at the /rates.htm URL. The id of a flow to launch should be passed
in using the "_flowId" request parameter: e.g. /rates.htm?_flowId=getRate-flow
-->
<bean name="/rates.htm" class="org.springframework.webflow.executor.mvc.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<!-- Launches new flow executions and resumes existing executions -->
<flow:executor id="flowExecutor" registry-ref="flowRegistry" repository-type="simple"/>
<!-- Creates the registry of flow definitions for this application -->
<flow:registry id="flowRegistry">
<flow:location path="/WEB-INF/flows/**/*-flow.xml" />
</flow:registry>
<!-- Performs "form backing object" data binding and validation on input submit -->
<bean id="formAction" class="org.springframework.webflow.action.FormAction">
<property name="formObjectName" value="rateCriteria" />
<property name="formObjectClass" value="org.springframework.webflow.samples.shippingrate.domain.RateCriteria" />
<property name="formObjectScope" value="FLOW" />
<property name="validator">
<bean class="org.springframework.webflow.samples.shippingrate.domain.RateCriteriaValidator" />
</property>
</bean>
<!-- Maps flow view-state view names to JSP templates -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- Resolves message codes to internationalized messages -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>MessageResources</value>
</property>
</bean>
</beans>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:org/springframework/webflow/samples/shippingrate/domain/services.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>shippingrate</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>shippingrate</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,51 @@
<HTML>
<head>
<title>Shipping Rate - An Ajax-enabled Spring Web Flow Sample</title>
<script src="prototype.js" type="text/javascript"></script>
<script src="swf_ajax.js" type="text/javascript"></script>
</head>
<BODY>
<DIV align="left">Shipping Rate - An Ajax-enabled Spring Web Flow Sample</DIV>
<HR>
<DIV align="left">
<P>
This sample application demonstrates use of Spring Web Flow
in combination with Ajaxian techniques. Specfically, it illustrates a
wizard embedded in a zone of this page that makes Ajax calls to the server to
participate in a executing flow. To complete processing, this wizard takes
the details about a shipment and calls a service to get the shipping rate.
<p>
The techniques demonstrated are:
<UL>
<li>
Using a JavaScript component to submit regular forms through an AJAX request, and inserting the HTML
received from the server into a DIV tag.
</li>
<LI>
Using the "_flowId" request parameter to let the view tell the web
flow controller which flow needs to be started.
</LI>
<LI>
Implementing a wizard using Spring Web Flow.
</LI>
</UL>
</P>
<p>
Note: this sample has been tested successfully on Internet Explorer 6 and Safari 2.0.3. There are currently known Javascript issues with use on Firefox 1.5.
</p>
</DIV>
<HR>
<div id="getRateWizard">
<script type="text/javascript">
window.onload = function() {
new SimpleRequest('getRateWizard', 'rates.htm', 'get', '_flowId=getRate-flow');
};
</script>
</div>
</BODY>
</HTML>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
body {
width: 720px;
margin: 0px;
padding: 0px;
font-size: 10px;
}
div#logo {
width: 720px;
height: 65px;
background: #86AEA5;
}
div#navigation {
width: 720px;
height: 20px;
background: #E2F3B8;
text-align: right;
}
div#content {
width: 720px;
padding: 5px;
}
div#insert {
width: 120;
float: right;
text-align: right;
}
.buttonBar {
height: 1.5em;
text-align: right;
}
div#copyright {
width: 720px;
}
div#copyright p {
text-align: center;
font-family: Tahoma, sans-serif;
font-size: 90%;
color: div#336633;
margin-left: 5px;
font-weight: bold;
clear: both;
}
.readOnly {
color: rgb(192, 192, 192);
}
.error {
color: red;
font-weight: bold;
font-family: Arial, sans-serif;
font-size: 90%;
}

View File

@@ -0,0 +1,64 @@
var SimpleRequest = function(targetElementId, url, method, parameters) {
var targetElement = $(targetElementId);
if (targetElement == null) {
throw 'Target element is null!';
}
if (url == null) {
throw 'URL has to be provided';
}
if (method == null) {
method = 'get';
} else if (method != 'get' && method != 'post') {
throw 'Method should be get or post';
}
var myAjax = new Ajax.Updater(
{ success: targetElement },
url,
{
method: method,
parameters: parameters,
onFailure: errFunc,
evalScripts: true
});
};
function formRequest(formElementId) {
Event.observe(formElementId, 'submit', handleSubmitEvent, true);
}
function handleSubmitEvent(event) {
var formElement = Event.element(event);
if (formElement.tagName.toLowerCase() != 'form') {
throw 'Element ' + formElement + ' is not a FORM element!';
}
var method = formElement.method;
if (method == null) {
method = 'get';
}
var url = formElement.action;
if (url == null) {
throw 'No action defined on ' + formElement;
}
try {
Event.stop(event);
var myRequest = new Ajax.Updater(
{ success: formElement.parentNode },
url,
{
method: method,
parameters: Form.serialize(formElement),
evalScripts: true,
onFailure: errFunc
});
} finally {
return false;
}
}
var handlerFunc = function(t) {
alert(t.responseText);
}
var errFunc = function(t) {
alert('Error ' + t.status + ' -- ' + t.statusText);
}