tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Steen" <ted.st...@gmail.com>
Subject Re: T5:
Date Mon, 29 Jan 2007 00:25:54 GMT
I read up on form validation and saw that onSuccess should be used for
this. So now it works fine, but there is still problems with the
@ApplicationState in the super class.

2007/1/29, Ted Steen <ted.steen@gmail.com>:
> @ComponentClass
> public abstract class CommonPengBasePage {
>
>     @Inject("context:resources/images/bakis.gif")
>     private Asset _background;
>
>         @ApplicationState
>         private PengUserDTO _identity;
>
>         public Asset getBackgroundImage() {
>                 return _background;
>         }
>
>         public PengUserDTO getIdentity() {
>                 return _identity;
>         }
>
>         public void setIdentity(PengUserDTO identity) {
>                 _identity = identity;
>         }
> }
>
> public abstract class PengBasePage extends CommonPengBasePage {
>
>         @SetupRender
>         public boolean checkForValidIdentity() {
>
>                 //todo check state flag instead when that is implemented
>                 if(getIdentity() != null) {
>                         return true;
>                 } else {
>                         return false; //todo something clever
>                 }
>
>         }
> }
>
> //a page that needs an identity
> public class ShowCollective extends PengBasePage {
>
>
>
> }
>
> //the login page
> public class Start extends CommonPengBasePage {
>
>         @Inject
>         private UserService pengUserService;
>
>         @Inject
>         private Log log;
>
>     @Inject
>     private Messages messages;
>
>     @Component
>     private Form loginForm;
>
>         private String email;
>         private String password;
>
>         public String getEmail() {
>                 return email;
>         }
>         public void setEmail(String email) {
>                 this.email = email;
>         }
>         public String getPassword() {
>                 return password;
>         }
>         public void setPassword(String password) {
>                 this.password = password;
>         }
>
>         @OnEvent(component="doLogin")
>         public String handleLogin() {
>
>                 if(loginForm.isValid()) {
>
>                         PengUserDTO pengUser = pengUserService.login(email, password);
>
>                         if (pengUser == null)
>                         {
>                                 loginForm.recordError(messages.get("login-error"));
>                         } else {
>                                 setIdentity(pengUser);
>                                 return "ShowCollective";
>                         }
>                 } else {
>                         log.info("Form is not valid...");
>                 }
>                 return null;
>         }
>
> }
>
>
> This is a subset of my proof-of-concept-project, showing the "bug".
> Actually I have a question regarding the handleLogin() method in page Start.
> I have a Submit component with id doLogin (maybe not a very clever
> name...) and i use that component id in @OnEvent for the method
> handleLogin.
> When the login succeeds and I return "ShowCollective" tapestry says throws this;
>
> java.lang.IllegalArgumentException
> Event 'selected' from net.keso.ted.peng5.pages.Start:doLogin received
> an event handler method return value of ShowCollective from
> net.keso.ted.peng5.pages.Start.handleLogin(). This type of event does
> not support return values from event handler methods.
>
> So my question is, how am I supposed to redirect/reroute to a
> different page after an event coming from a submit button?
>
> thanks
> /ted
> 2007/1/28, Howard Lewis Ship <hlship@gmail.com>:
> > Sounds like a bug to me.  I have seen some oddities involving the user
> > of inner classes and fields that are removed (I believe it's actually
> > a Javassist bug) but this doesn't seem to fall into that. Any chance
> > of showing us the code?
> >
> > On 1/27/07, Ted Steen <ted.steen@gmail.com> wrote:
> > > All the involved classes are in the same package.
> > >
> > > 2007/1/27, Howard Lewis Ship <hlship@gmail.com>:
> > > > Very odd.
> > > >
> > > > The transformation does remove the _identity field, but since the
> > > > field is private, that should not matter.  There are other
> > > > transformations that also remove fields.
> > > >
> > > > I don't  have a test for this specific case, I'll have to add one.
> > > >
> > > > What package is the base class in? That affects what classes are
> > > > transformed, though it looks like the transformation is happening.
> > > >
> > > > @ComponentClass on a base class is sufficient.
> > > >
> > > > On 1/27/07, Ted Steen <ted.steen@gmail.com> wrote:
> > > > > Abstract class CommonBasePage is annotated with @ComponentClass and
> > > > > defines a field "_identity" which is annotated with @ApplicationState.
> > > > > get and set for the field is implemented in CommonBasePage.
> > > > > the abstract class BasePage extends CommonBasePage
> > > > >
> > > > > now, when I create a new page Main I let it extend from BasePage.
> > > > > but then I get
> > > > > java.lang.NoSuchFieldError: _identity at
> > > > > net.keso.ted.peng5.pages.CommonPengBasePage.containingPageDidLoad(CommonPengBasePage.java)
> > > > > .
> > > > > .
> > > > > .
> > > > >
> > > > > Am I doing something wrong?
> > > > > Also, should I annotate the Main page with @ComponentClass or can
I
> > > > > assume that it is inherited from CommonBasePage?
> > > > >
> > > > > --
> > > > > /ted
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: dev-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Howard M. Lewis Ship
> > > > TWD Consulting, Inc.
> > > > Independent J2EE / Open-Source Java Consultant
> > > > Creator and PMC Chair, Apache Tapestry
> > > > Creator, Apache HiveMind
> > > >
> > > > Professional Tapestry training, mentoring, support
> > > > and project work.  http://howardlewisship.com
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: dev-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > /ted
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: dev-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant
> > Creator and PMC Chair, Apache Tapestry
> > Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support
> > and project work.  http://howardlewisship.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: dev-help@tapestry.apache.org
> >
> >
>
>
> --
> /ted
>


-- 
/ted

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Mime
View raw message