jsp - Dynamic Proxy in Java EL -


edit: narrowed down problem , posted related question here. please check out!

i trying use dynamic proxies make html form processing easier. using pretty plain mvc setup (no fancy frameworks) using jsps on google app engine. keep getting following exception:

javax.el.propertynotfoundexception: not find property testvalue in class com.sun.proxy.$proxy7     @ javax.el.beanelresolver.tobeanproperty(beanelresolver.java:430)     @ javax.el.beanelresolver.getvalue(beanelresolver.java:290)     @ javax.el.compositeelresolver.getvalue(compositeelresolver.java:231)     @ org.apache.el.parser.astvalue.getvalue(astvalue.java:123)     @ org.apache.el.valueexpressionimpl.getvalue(valueexpressionimpl.java:186)     ... 

okay, here code. first, interface proxying:

public interface myform {       public string gettestvalue(); } 

next, code creates proxy:

// imports omitted  public final class forms {      private forms() { }      public static <t> t fromrequest(             final class<t> klass,             final httpservletrequest request) {          object proxy = proxy.newproxyinstance(                 klass.getclassloader(),                 new class<?>[]{ klass },                 new invocationhandler() {                     @override public object invoke(                             object proxy,                             method method,                             object[] args) throws throwable {                          return "will returned?";                     }                 });         return (t)proxy;     } } 

next "action" class:

// imports omitted  public class myaction extends action {      // called controller, forwards returned jsp     public string perform(httpservletrequest request) throws exception {          final myform form = forms.fromrequest(myform.class, request);         request.setattribute("form", form);         return "view.jsp";     } } 

finally, jsp:

<html>     <body>         <div>${ form.testvalue }</div>     </body> </html> 

as can see, i'm not doing form processing yet. first, want implement proof of concept dynamic proxy. mentioned, code above not work. however, perplexingly, if make request attribute anonymous class forwards proxy, work! following change fixes it:

request.setattribute("form", new myform() {     @override gettestvalue() { return form.gettestvalue(); } }); 

however, having anonymously subclass interface kind of defeats purpose of proxy. please tell me what's going on?


Comments

Popular posts from this blog

asp.net mvc 3 - Using mvc3, I need to add a username/password to the sql connection string at runtime -

kineticjs - draw multiple lines and delete individual line -

thumbnails - jQuery image rotate on hover -