[Wicket-user] Forms/Models
I wrote the following code with Forms and Models... is there a more compact way of doing this? Would it be a bad idea to combine the form class and the model class into one and have it reference itself as a Model object? Also, since I am not so concerned about holding on to the model's state (logins are usually just one-time requests and the form is always reset on failure), what's a simple way of doing this without storing the LoginModel in the session? Thanks in advance! public class Login extends BasePage { // TODO Add any page properties or variables here public Login () { super (Login); add (new LoginForm (loginForm)) ; } } class LoginForm { LoginModel loginModel = null ; public LoginForm (final String componentName) { super (componentName) ; loginModel = new LoginModel () ; this.setModel (new CompoundPropertyModel (loginModel)) ; add (new RequiredTextField (loginName)); add (new PasswordTextField (password)); } public void onSubmit () { String loginName = loginModel.getLoginName () ; if (asdfasdf.equals (loginModel.getPassword ())) { MySession session = session.setLoginName (loginName) ; this.setResponsePage (Home.class) ; } else { log.warn (Login failure for + loginName) ; this.setResponsePage (getPage ()) ; } } } class LoginModel implements Serializable { private String loginName ; private String password ; public String getLoginName () { return loginName; } public void setLoginName (String loginName) { this.loginName = loginName; } public String getPassword () { return password; } public void setPassword (String password) { this.password = password; } } -- View this message in context: http://www.nabble.com/Forms-Models-tf2341262.html#a6516020 Sent from the Wicket - User mailing list archive at Nabble.com. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Forms/Models
it really depends on the reusability you want.do you want loginform to be reusable?do you want loginmodel to be reusable?if the answer to both is no then you can just doclass Login extends WebPage { private String login; private String password; public Login() { Form form=new Form(form, new CompoundPropertyModel(this)) {public void onSubmit (){ if (asdfasdf.equals (password)) { MySession session = session.setLoginName (loginName) ;this.setResponsePage (Home.class) ;}else {log.error(Login failure for + login) ; }} }; form.add (new RequiredTextField (loginName)); form.add (new PasswordTextField (password));}and call it a day :)-Igor On 9/26/06, Patrick Angeles [EMAIL PROTECTED] wrote: I wrote the following code with Forms and Models... is there a more compactway of doing this? Would it be a bad idea to combine the form class and themodel class into one and have it reference itself as a Model object? Also, since I am not so concerned about holding on to the model's state(logins are usually just one-time requests and the form is always reset onfailure), what's a simple way of doing this without storing the LoginModel in the session?Thanks in advance!public class LoginextendsBasePage{// TODO Add any page properties or variables herepublic Login (){super (Login); add (new LoginForm (loginForm)) ;}}class LoginForm{LoginModel loginModel = null ;public LoginForm (final String componentName){super (componentName) ; loginModel = new LoginModel () ;this.setModel (new CompoundPropertyModel (loginModel)) ;add (new RequiredTextField (loginName));add (new PasswordTextField (password)); }public void onSubmit (){String loginName = loginModel.getLoginName () ;if (asdfasdf.equals (loginModel.getPassword ())) {MySession session = session.setLoginName (loginName) ;this.setResponsePage (Home.class) ;}else {log.warn (Login failure for + loginName) ;this.setResponsePage (getPage ()) ;}}} class LoginModelimplements Serializable{private String loginName ;private String password ;public String getLoginName (){return loginName;}public void setLoginName (String loginName) {this.loginName = loginName;}public String getPassword (){return password;}public void setPassword (String password){this.password = password;} }--View this message in context: http://www.nabble.com/Forms-Models-tf2341262.html#a6516020Sent from the Wicket - User mailing list archive at Nabble.com.-Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cashhttp://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___Wicket-user mailing listWicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Forms/Models
Thanks... that's exactly what I was looking for ;)So I take it, CompoundPropertyModel does not require get/set methods to access/mutate properties? (I think I have to make login public, in this case?) On 9/26/06, Igor Vaynberg [EMAIL PROTECTED] wrote: it really depends on the reusability you want.do you want loginform to be reusable?do you want loginmodel to be reusable?if the answer to both is no then you can just doclass Login extends WebPage { private String login; private String password; public Login() { Form form=new Form(form, new CompoundPropertyModel(this)) {public void onSubmit (){ if (asdfasdf.equals (password)) { MySession session = session.setLoginName (loginName) ;this.setResponsePage (Home.class) ;}else {log.error(Login failure for + login) ; }} }; form.add (new RequiredTextField (loginName)); form.add (new PasswordTextField (password));}and call it a day :)-Igor On 9/26/06, Patrick Angeles [EMAIL PROTECTED] wrote: I wrote the following code with Forms and Models... is there a more compactway of doing this? Would it be a bad idea to combine the form class and themodel class into one and have it reference itself as a Model object? Also, since I am not so concerned about holding on to the model's state(logins are usually just one-time requests and the form is always reset onfailure), what's a simple way of doing this without storing the LoginModel in the session?Thanks in advance!public class LoginextendsBasePage{// TODO Add any page properties or variables herepublic Login (){super (Login); add (new LoginForm (loginForm)) ;}}class LoginForm{LoginModel loginModel = null ;public LoginForm (final String componentName){super (componentName) ; loginModel = new LoginModel () ;this.setModel (new CompoundPropertyModel (loginModel)) ;add (new RequiredTextField (loginName));add (new PasswordTextField (password)); }public void onSubmit (){String loginName = loginModel.getLoginName () ;if (asdfasdf.equals (loginModel.getPassword ())) {MySession session = session.setLoginName (loginName) ;this.setResponsePage (Home.class) ;}else {log.warn (Login failure for + loginName) ;this.setResponsePage (getPage ()) ;}}} class LoginModelimplements Serializable{private String loginName ;private String password ;public String getLoginName (){return loginName;}public void setLoginName (String loginName) {this.loginName = loginName;}public String getPassword (){return password;}public void setPassword (String password){this.password = password; } }--View this message in context: http://www.nabble.com/Forms-Models-tf2341262.html#a6516020 Sent from the Wicket - User mailing list archive at Nabble.com.-Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___Wicket-user mailing listWicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user -Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___Wicket-user mailing list Wicket-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/wicket-user -- Patrick Angeles | VP of Technology | Direct:646.643.2607 | Fax:800.366.2303 | Support:800.819.0325 | Inertia - Powering the Wine REvolution | www.inertiabev.com - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Forms/Models
I thought this is in his private 1.3 branch On 9/26/06, Igor Vaynberg [EMAIL PROTECTED] wrote: we have been talking about letting it access private fields directly so you dont have to implement the pesky getters/setters. not sure if that has been committed yet. johan? -Igor On 9/26/06, Patrick Angeles [EMAIL PROTECTED] wrote: Thanks... that's exactly what I was looking for ;) So I take it, CompoundPropertyModel does not require get/set methods to access/mutate properties? (I think I have to make login public, in this case?) On 9/26/06, Igor Vaynberg [EMAIL PROTECTED] wrote: it really depends on the reusability you want. do you want loginform to be reusable? do you want loginmodel to be reusable? if the answer to both is no then you can just do class Login extends WebPage { private String login; private String password; public Login() { Form form=new Form(form, new CompoundPropertyModel(this)) { public void onSubmit () { if (asdfasdf.equals (password)) { MySession session = session.setLoginName (loginName) ; this.setResponsePage (Home.class) ; } else { log.error(Login failure for + login) ; } } }; form.add (new RequiredTextField (loginName)); form.add (new PasswordTextField (password)); } and call it a day :) -Igor On 9/26/06, Patrick Angeles [EMAIL PROTECTED] wrote: I wrote the following code with Forms and Models... is there a more compact way of doing this? Would it be a bad idea to combine the form class and the model class into one and have it reference itself as a Model object? Also, since I am not so concerned about holding on to the model's state (logins are usually just one-time requests and the form is always reset on failure), what's a simple way of doing this without storing the LoginModel in the session? Thanks in advance! public class Login extends BasePage { // TODO Add any page properties or variables here public Login () { super (Login); add (new LoginForm (loginForm)) ; } } class LoginForm { LoginModel loginModel = null ; public LoginForm (final String componentName) { super (componentName) ; loginModel = new LoginModel () ; this.setModel (new CompoundPropertyModel (loginModel)) ; add (new RequiredTextField (loginName)); add (new PasswordTextField (password)); } public void onSubmit () { String loginName = loginModel.getLoginName () ; if (asdfasdf.equals (loginModel.getPassword ())) { MySession session = session.setLoginName (loginName) ; this.setResponsePage (Home.class) ; } else { log.warn (Login failure for + loginName) ; this.setResponsePage (getPage ()) ; } } } class LoginModel implements Serializable { private String loginName ; private String password ; public String getLoginName () { return loginName; } public void setLoginName (String loginName) { this.loginName = loginName; } public String getPassword () { return password; } public void setPassword (String password) { this.password = password; } } -- View this message in context: http://www.nabble.com/Forms-Models-tf2341262.html#a6516020 Sent from the Wicket - User mailing list archive at Nabble.com. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user -- Patrick Angeles | VP of Technology | Direct:646.643.2607 | Fax:800.366.2303 |