I am trying to create a form using the Spring Framework, but according to this (http://groups.google.com/group/google-appengine-java/ browse_thread/thread/d93fd7385bf85bf7), I need to override initBinder. Well, I think I did that and it still doesn't work.
My jsp (priceincreasejsp):
<%@ page contentType="text/html;charset=UTF-8" language="java"
isELIgnored="false" session="false" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/
form" %>
<form:form method="post" commandName="priceIncrease">
Increase (%): <form:input path="percentage"/>
<input type="submit" value="Execute">
</form:form>
myapp-servlet.xml has the following:
<bean name="/priceincrease.htm"
class="myapp.web.PriceIncreaseFormController">
<property name="sessionForm" value="true"/>
<property name="commandName" value="priceIncrease"/>
<property name="commandClass" value="myapp.service.PriceIncrease"/
>
<property name="validator">
<bean class="myapp.service.PriceIncreaseValidator"/>
</property>
<property name="formView" value="priceincrease"/>
<property name="successView" value="success.htm"/>
<property name="productManager" ref="productManager" />
</bean>
PriceIncrease.java:
public class PriceIncrease implements Serializable {
private Integer percentage;
public void setPercentage(Integer i) {
percentage = i;
}
public Integer getPercentage() {
return percentage;
}
}
PriceIncreaseFormController.java:
public class PriceIncreaseFormController extends SimpleFormController
{
private ProductManager productManager;
public ModelAndView onSubmit(Object command) throws
ServletException {
PriceIncrease priceIncrease = (PriceIncrease) command;
Integer increase = priceIncrease.getPercentage();
productManager.increasePrice(increase);
return new ModelAndView(new RedirectView(getSuccessView()));
}
public void initBinder(WebDataBinder binder, WebRequest request)
{
binder.registerCustomEditor(PriceIncrease.class, new
PriceIncreaseEditor());
binder.registerCustomEditor(Integer.class,
new CustomNumberEditor(Integer.class, true)); // use this instead?
}
public void setProductManager() {...}
public ProductManager getProductManager {...}
}
Finally, PriceIncreaseEditor.java: (this is probably wrong..)
public class PriceIncreaseEditor extends PropertyEditorSupport{
@Override
public void setAsText(String text) throws IllegalArgumentException
{
Integer increase = new Integer(text);
super.setValue(increase);
}
}
Stack trace:
org.springframework.web.servlet.tags.RequestContextAwareTag
doStartTag: access denied (java.lang.RuntimePermission getClassLoader)
java.security.AccessControlException: access denied
(java.lang.RuntimePermission getClassLoader)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:
355)
at
java.security.AccessController.checkPermission(AccessController.java:
567)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:
549)
at
com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:
45)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1311)
at
org.springframework.beans.BeanUtils.findEditorByConvention(BeanUtils.java:
368)
at
org.springframework.validation.AbstractPropertyBindingResult.getCustomEditor(AbstractPropertyBindingResult.java:
110)
at
org.springframework.validation.AbstractPropertyBindingResult.formatFieldValue(AbstractPropertyBindingResult.java:
87)
at
org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:
230)
at
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:
120)
at
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:
172)
at
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:
192)
at
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:
158)
at
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:
145)
at
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:
136)
at
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:
120)
at
org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:
379)
at
org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:
139)
at
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:
90)
at
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:
77)
at
org.apache.jsp.WEB_002dINF.jsp.priceincrease_jsp._jspx_meth_form_005finput_005f0(priceincrease_jsp.java:
149)
at
org.apache.jsp.WEB_002dINF.jsp.priceincrease_jsp._jspService(priceincrease_jsp.java:
82)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
511)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
390)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
418)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
at
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:
240)
at
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:
258)
at
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:
1174)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:
901)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:
809)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:
571)
at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:
501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
511)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:
97)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:
35)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
43)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
418)
at
com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:
238)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
542)
at org.mortbay.jetty.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:923)
at
com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:
76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:
135)
at
com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:
261)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime
$6.handleBlockingRequest(RuntimePb.java:8495)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime
$6.handleBlockingRequest(RuntimePb.java:8493)
at
com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:
24)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:
435)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:
572)
at com.google.tracing.TraceContext$TraceContextRunnable
$1.run(TraceContext.java:448)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:
688)
at com.google.tracing.TraceContext
$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:
326)
at com.google.tracing.TraceContext
$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:
318)
at com.google.tracing.TraceContext
$TraceContextRunnable.run(TraceContext.java:446)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:
1110)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
I've been pretty stuck for a while now... Any ideas?