Re: Problem with paramsPrepareParamsStack
Its working now, User class must be Serializable. But Why it matters for Validation?? Since we want to persist User class it must be serializable But why Validation was not working??? Why Validation requires a Serializable class??? Just for curiosity... spsarolkar wrote: > > Hi, thanks I missed that.. > But now validation is no working/partially working i.e. when i submit > invalid values i am redirected to input result but messages are not > printed. Also values are not inserted to database. Here are modified files > > > UpdateUserAction.java wrote: >> >> @ParentPackage("base-package") >> @Results({ >> @Result(name="success",value="index",type= >> ServletActionRedirectResult.class), >> >> @Result(name="dupPK",value="/WEB-INF/jsp/user/findUser-success.jsp"), >> >> @Result(name="error",value="/WEB-INF/jsp/user/findUser-success.jsp"), >> >> @Result(name="input",value="findUser",type=ServletActionRedirectResult.class) >> }) >> @Validation >> public class UpdateUserAction extends BaseUserAction { >> @Validations(visitorfield...@visitorfieldvalidator( >> message="Default message", >> fieldName="model", >> appendPrefix=false >> )} >> ) >> public String execute(){ >> userService.persist(user,emailId); >> return SUCCESS; >> } >> } >> > > User.java wrote: >> >> @Entity >> @Table(name="APP_USER",schema="s2app") >> public class User { >> private String email; >> private String firstname; >> private String lastname; >> private String password; >> @Id >> @Column(name="EMAIL") >> public String getEmail() { >> return email; >> } >> @EmailValidator(message="Validation Error", key="validate.email") >> public void setEmail(String email) { >> this.email = email; >> } >> @Column(name="FIRST_NAME") >> public String getFirstname() { >> return firstname; >> } >> @RequiredStringValidator(message="Firstname must be >> present",key="validate.firstname",trim=true) >> public void setFirstname(String firstname) { >> this.firstname = firstname; >> } >> @Column(name="LAST_NAME") >> public String getLastname() { >> return lastname; >> } >> @RequiredStringValidator(message="Lastname must be >> present",key="validate.lastname",trim=true) >> public void setLastname(String lastname) { >> this.lastname = lastname; >> } >> @Column(name="USER_PASSWORD") >> public String getPassword() { >> return password; >> } >> @RequiredStringValidator(message="Password must be >> present",key="validate.password",trim=true) >> public void setPassword(String password) { >> this.password = password; >> } >> } >> >> >> findUser-success.jsp wrote: >>> >>> <%...@page contentType="text/html;charset=UTF-8" %> >>> <%...@taglib prefix="s" uri="/struts-tags" %> >>> >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> >>> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >> > -- View this message in context: http://www.nabble.com/Problem-with-paramsPrepareParamsStack-tp24895177p24912439.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with paramsPrepareParamsStack
Hi, thanks I missed that.. But now validation is no working/partially working i.e. when i submit invalid values i am redirected to input result but messages are not printed. Also values are not inserted to database. Here are modified files UpdateUserAction.java wrote: > > @ParentPackage("base-package") > @Results({ > @Result(name="success",value="index",type= > ServletActionRedirectResult.class), > > @Result(name="dupPK",value="/WEB-INF/jsp/user/findUser-success.jsp"), > > @Result(name="error",value="/WEB-INF/jsp/user/findUser-success.jsp"), > > @Result(name="input",value="findUser",type=ServletActionRedirectResult.class) > }) > @Validation > public class UpdateUserAction extends BaseUserAction { > @Validations(visitorfield...@visitorfieldvalidator( > message="Default message", > fieldName="model", > appendPrefix=false > )} > ) > public String execute(){ > userService.persist(user,emailId); > return SUCCESS; > } > } > User.java wrote: > > @Entity > @Table(name="APP_USER",schema="s2app") > public class User { > private String email; > private String firstname; > private String lastname; > private String password; > @Id > @Column(name="EMAIL") > public String getEmail() { > return email; > } > @EmailValidator(message="Validation Error", key="validate.email") > public void setEmail(String email) { > this.email = email; > } > @Column(name="FIRST_NAME") > public String getFirstname() { > return firstname; > } > @RequiredStringValidator(message="Firstname must be > present",key="validate.firstname",trim=true) > public void setFirstname(String firstname) { > this.firstname = firstname; > } > @Column(name="LAST_NAME") > public String getLastname() { > return lastname; > } > @RequiredStringValidator(message="Lastname must be > present",key="validate.lastname",trim=true) > public void setLastname(String lastname) { > this.lastname = lastname; > } > @Column(name="USER_PASSWORD") > public String getPassword() { > return password; > } > @RequiredStringValidator(message="Password must be > present",key="validate.password",trim=true) > public void setPassword(String password) { > this.password = password; > } > } > > > findUser-success.jsp wrote: >> >> <%...@page contentType="text/html;charset=UTF-8" %> >> <%...@taglib prefix="s" uri="/struts-tags" %> >> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> >> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > -- View this message in context: http://www.nabble.com/Problem-with-paramsPrepareParamsStack-tp24895177p24911963.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with paramsPrepareParamsStack
spsarolkar wrote: public void prepare(){ if(emailId==null){ this.user=new User(); } else{ this.user=userService.findByEmail(emailId); } } So if emailId is null you construct a new one, but if it is not null and findByEmail() fails, it is still null. java.lang.IllegalArgumentException: attempt to create create event with null entity When i tried to debug it I am getting user object in prepare() function i.e. user is not null but when i check the same value in update method it comes out to be null This generates , right? So it'll submit a parameter &emailId=, which will result in emailId not being null, but rather being the empty string. The prepare lookup fails, so user is still null. Try these two fixes: > > > > > > > > public void prepare() { > if (emailId != null) { > this.user=userService.findByEmail(emailId); > } > if (this.user == null) { > this.user = new User(); > } > } -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Problem with paramsPrepareParamsStack
phony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:313) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442) When i tried to debug it I am getting user object in prepare() function i.e. user is not null but when i check the same value in update method it comes out to be null My jsp form is as follows <%@ taglib uri="/struts-tags" prefix="s" %> … When I remove default params stack it is working properly. I want to use ParamsPrepareParams stack. I am following apress struts2 practical guid book Somebody please help me out... -- View this message in context: http://www.nabble.com/Problem-with-paramsPrepareParamsStack-tp24895177p24895177.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org