Research Log of Web Science Students

Computer Science is not simply programming

Spring sessionForm problem in Google AppEngine

with 2 comments

I finally made a dynamically generating form in Spring MVC for our making a course feature. I thought it had all worked out except that
the sessionForms in Google Appengine works in the development environment but not when I deploy it.

I have sessions-enabled set to true in my appengine-web.xml.

Am I missing something here? I had to override the initBinder in my Controller for it to work in appengine because Spring tries to “access the system class loader”

Maybe I should also do something for my problem but I don’t know what it is.

package com.springtutorial.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.springtutorial.model.Course;

public class GetCourseController extends SimpleFormController {
	private static final String ADD_VIDEO_TO_CURRENT_LEARNING_ACTIVITY = "video";
	private static final String NEW_REQUEST = "";
	private static final String ADD_LEARNING_ACTIVITY = "add learning activity";
	private String currentRequest;
	private int activityNumber;
	protected ModelAndView showForm(HttpServletRequest request,
			HttpServletResponse response, BindException errors)
			throws Exception {
		if (ADD_LEARNING_ACTIVITY.equals(currentRequest)){
			request.setAttribute("request","add learning activity");
		} else if (ADD_VIDEO_TO_CURRENT_LEARNING_ACTIVITY.equals(currentRequest)){
		else {
		return super.showForm(request, response, errors);
	protected boolean isFormChangeRequest(HttpServletRequest request) {
		String action = request.getParameter("submit");
		if (ADD_LEARNING_ACTIVITY.equals(action)){
			currentRequest = ADD_LEARNING_ACTIVITY;
			return true;
		return false;
	protected ModelAndView onSubmit(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		return super.onSubmit(request, response, command, errors);
	protected void initBinder(HttpServletRequest request,
			ServletRequestDataBinder binder) throws Exception {
		binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); 

Written by Jose Asuncion

September 20, 2009 at 2:29 pm

Posted in Hardwire

2 Responses

Subscribe to comments with RSS.

  1. […] me include here what I’ve found about my previous post’s problem. I discovered in the logs that the form state was not being saved to session because I was getting […]

  2. […] roughed through a feature in the past that required a lot of learning of the Spring framework (see here, here, here . And today I found myself going through the same […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: