You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "very.sad.developer" <ve...@gmail.com> on 2012/07/02 23:19:02 UTC
Why my model doesn't refresh
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"));
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Why my model doesn't refresh
Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Jul 2, 2012 at 11:19 PM, very.sad.developer
<ve...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Why my model doesn't refresh
Posted by "very.sad.developer" <ve...@gmail.com>.
Thank you for fast answer,
Yes, there should be used PasswordTextField, but for showing problem I
simplify the boring part :).After done this quickstart (this is part of
bigger application) my models suddently start to refresh. I check my
configuration and now I suspect JRebel for my last problems.
Are you using JRebel with wicket? Do you faced any problems when you use
this tool with wicket?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Why-my-model-doesn-t-refresh-tp4650321p4650325.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org