Re: Submit Form Automatically during Load

2007-11-02 Thread Hubert Kauker


Nino.Martinez wrote:
> 
> have you mounted the page?
> 

> I want to support a URL like this: 
>
> http://host/webapp/home/?userid=foo&password=bar&submit=true

Well, no. I haven't.

Even without mounting, in the absence of *submit* the *userid* and
*password* parameters show up nicely in the page after loading. 
The only thing is, when one of them is missing, the usual validation does
not seem to run.

Do you suppose, mounting the page name would make any difference?


-- 
View this message in context: 
http://www.nabble.com/Submit-Form-Automatically-during-Load-tf4736602.html#a13547958
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Submit Form Automatically during Load

2007-11-02 Thread Hubert Kauker

Hello...

I want to support a URL like this: 

http://host/webapp/home/?userid=foo&password=bar&submit=true



The page is meant to perform login.

When both userid and password are correct, I want to pass to the following
page directly.
This works well.



When the password is wrong, I want an error message in the feedback panel
and stay on the page.
This works, too.



When either of the (required) parameters userid/password is missing, I want
the usual validation error message.

This does NOT work, for some reason I do not understand.



I suspect, the constructor is probably the wrong place where to place the
if(...){...}.

But where should it go?

Many thanks in advance.

Hubert



[Code]
public class Home extends WebPage { 
private static final long serialVersionUID = 1L;
private String userid;
private String password;

// Getters and Setters
public String getUserid() {
return userid;
}
public void setUserid( String userid ){
this.userid = userid;
}
public String getPassword() {
return password;
}
public void setPassword( String password ){
this.password = password;
}

// Constructor
public Home(PageParameters parameters) {
this();
userid = parameters.getString("userid");
password = parameters.getString("password");
if( parameters.getBoolean("submit") ) {
if( ((LoginForm)get("loginForm")).process() ) {
((LoginForm)get("loginForm")).onSubmit();
}
}
}

// Constructor
public Home() {
super();
add( new LoginForm( "loginForm", this ) );
add( new FeedbackPanel( "feedback" ));
}

// Form
public class LoginForm extends Form {
private static final long serialVersionUID = 1L;

public LoginForm(String id, Object modelObject ) {
super(id, new CompoundPropertyModel( modelObject ));
add(new RequiredTextField("userid"));
add(new 
PasswordTextField("password").setResetPassword(false));
}

public void onSubmit() {
if( userid == null ) return;
if (userid.equals(password)) {
setResponsePage(new Welcome(userid));
} else
error("Wrong Password");
}
}
}

-- 
View this message in context: 
http://www.nabble.com/Submit-Form-Automatically-during-Load-tf4736602.html#a13545251
Sent from the Wicket - User mailing list archive at Nabble.com.