how do you submit the form? it seems like you do not add a submit button or submit link into the form..

Ajayi Yinka wrote:
Hi,
This problem still persist till now. I can really figure out the cause of
the problem. Could anyone help me out? This is one of the pages in my
application. I have searched all the texts I have on wicket to get the cause
of the problem but I coudn't find one.

I appreciate any asisstance anyone can render on this.

Thanks in advance.
package web.page;

import web.UserSession;
import web.component.MainNavigationComponent;
import pojo.User;
import services.TouchPayService;
import java.util.List;
import org.apache.wicket.Session;
import org.apache.wicket.injection.web.InjectorHolder;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;

/**
 *
 * @author AJAYI YINKA
 */
public final class Login extends AbstractConsoleWebPage  {

    Form form;
    private TextField userId;
    private PasswordTextField userPassword;
    List<User> users;
    @SpringBean
    TouchPayService touchpay;
    private static final long serialVersionUID = 1L;
    public Login() {

        InjectorHolder.getInjector().inject(this);

        org.apache.wicket.Component mainNavigation;

        mainNavigation = new MainNavigationComponent("mainNavigation",
null);

        userId = new TextField("userId", new Model(" "));
        userId.setRequired(true);


        userPassword = new PasswordTextField("userPassword", new Model("
"));
        userPassword.setRequired(true);

        form = new LoginFormComponent("f");

        add(new FeedbackPanel("errorMsg"));
        form.add(userId);
        form.add(userPassword);
        add(form);
        add(mainNavigation);


    }

    public void setUser(User user) {
        ((UserSession) getSession()).setCurrentUser(user);
    }


    @Override
    public String getTitle() {
        return "Login Page";
    }

    class LoginFormComponent extends Form {

        public LoginFormComponent(String id) {
            super(id);
        }

        @Override
        public void onError(){

        setResponsePage(Login.class);
         }

        @Override
        public void onSubmit() {


            String userId = (String) Login.this.getUserId();
            String userPassword = (String) Login.this.getPassword();

            User user = null;
            users = touchpay.findAllUsers();

            for (User userInDB : users) {
                if ((userInDB.getUsername().equals(userId)) &&
(userInDB.getPassword().equals(userPassword))) {
                    user = userInDB;
                }
            }
            if (user == null) {
                // not yet implemented
                } else {
                setUser(user);
                Session.get().info("You have logged in successfully");

                if (!continueToOriginalDestination()) {
                    setResponsePage(HomePage.class);
                }
            }

        }
    }

    /** Helper methods to retrieve the userId and the password **/
    protected String getUserId() {
        return userId.getModelObjectAsString();
    }

    protected String getPassword() {
        return userPassword.getModelObjectAsString();
    }
}




On Wed, Sep 10, 2008 at 6:18 AM, Ajayi Yinka <[EMAIL PROTECTED]>wrote:

hi guys,
I have try to get over the problem by calling Login.class in onError
method. this seems to cover this bugs, but I am not satistify as the error
message is still redisplaying in the next page.
I think what i really need is the problems that are associated with
validation.

On Wed, Sep 10, 2008 at 4:58 AM, Ajayi Yinka <[EMAIL PROTECTED]>wrote:

I thought as much, it seems I am missing something out in validation
process. Please help me check out from this snippet of my codes

userId = new TextField("userId", new Model(""));
        userId.setRequired(true);


        userPassword = new PasswordTextField("userPassword", new
Model(""));
        userPassword.setRequired(true);

        form.add(userId);
        form.add(userPassword);
      add(form);

add(new FeedbackPanel("errorMsg"));

thanks.



On Wed, Sep 10, 2008 at 4:06 AM, Serkan Camurcuoglu <[EMAIL PROTECTED]
wrote:
if onSubmit is not called and the form is redisplayed with the values
that you've last entered, it seems like the form is not validated
successfully..



Ajayi Yinka wrote:

Hi guys,
I am a newbie in wicket. I am presently developpng an application using
wicket framework. I am having problem in submitting my forms.
The form submissionis actually working whenever I enter a value but if
no
value is put in the textbox, feedback panel will  display  the error
message
(I think this is good).

The problem is that if I now enter values in the textboxes, the onsubmit
method is not executed. I dont know what is causing this.
I need a prompt response as this is delaying the progress of my job.
Thanks.
Yinka.



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





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

Reply via email to