On Mon, Jul 2, 2012 at 11:19 PM, very.sad.developer
<[email protected]> wrote:
> Hello everyone,
>
> I don't know why my model doesn't refresh in this example:
> (maven project created from wicket
> quickstart:http://dl.dropbox.com/u/1280777/myproject.zip)
>
> wicket version: *6.0.0-beta2*
>
>
> *LoginPage.java*
>
> import org.apache.wicket.Component;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.markup.html.form.Button;
> import org.apache.wicket.markup.html.form.StatelessForm;
> import org.apache.wicket.markup.html.form.TextField;
> import org.apache.wicket.markup.html.panel.FeedbackPanel;
> import org.apache.wicket.model.PropertyModel;
>
> public class LoginPage extends WebPage{
>
>
> private UserLoginRequest userLoginRequest = new UserLoginRequest();
>
> public LoginPage() {
> add(createLoginForm());
> add(createFeebackPanel());
>
> }
>
> private Component createFeebackPanel() {
> return new FeedbackPanel("feedbackPanel");
> }
>
> private Component createLoginForm() {
>
>
> final TextField<String> login = new TextField<String>("login",
> PropertyModel.<String>of(this, "userLoginRequest.username"));
> login.setRequired(true);
>
>
> final TextField<String> password = new
> TextField<String>("password",
> PropertyModel.<String>of(this, "userLoginRequest.username"));
I guess you need the password field, not the username ^^^
> password.setRequired(true);
>
> StatelessForm<Void> statelessForm = new
> StatelessForm<Void>("loginForm"){
> @Override
> protected void onSubmit() {
>
> String user = userLoginRequest.getUsername();
> String password =
> userLoginRequest.getPassword();
>
> if ((null == user) || (password == null)) {
> throw new RuntimeException("Why
> models didn't refresh when put correct
> values into inputs");
> }
> }
> };
>
> statelessForm.add(login);
> statelessForm.add(password);
>
> statelessForm.add(new Button("submitForm"));
> return statelessForm;
> }
> }
> class UserLoginRequest implements java.io.Serializable{
>
> private String username;
> private String password;
>
> public String getUsername() {
> return username;
> }
> public void setUsername(String username) {
> this.username = username;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
>
> public void cleanPassword(){
> password = null;
> }
> }
>
> *html:*
> <!DOCTYPE html>
> <html xmlns:wicket="http://wicket.apache.org">
> <head>
> <meta charset="utf-8" />
> <title>Apache Wicket Quickstart</title>
> <link
>
> href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold'
> rel='stylesheet' type='text/css' />
> <link rel="stylesheet" href="style.css" type="text/css" media="screen"
> title="Stylesheet" />
> </head>
> <body>
>
>
> <form wicket:id="loginForm">
> Login<input type="text" value="" wicket:id="login" /> <br />
> Password<input type="text" value="" wicket:id="password" />
> <br />
> <br /> <input type="submit" value="Log in"
> wicket:id="submitForm" />
> </form>
> <br />
> </body>
> </html>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Why-my-model-doesn-t-refresh-tp4650321.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]