0

After updating Wicket from version 6.12 to 6.13/6.14 onSubmit action doesn't work. For Example class:

public class LoginPage extends WebPage {

    private String username = "";
    private String password = "";

    public LoginPage() {
        super();
        Form<?> form = new Form<Void>("form");

        setDefaultModel(new CompoundPropertyModel<>(this));

        form.add(new Button("submit") {

            @Override
            public void onSubmit() {
                System.out.println("SUBMIT "+username+":"+password);
            }
        });
        form.add(new TextField<String>("username").setRequired(true));
        form.add(new PasswordTextField("password").setRequired(true));
        add(form);

    }
}

with HTML:

<!DOCTYPE html>
<html xmlns:wicket>
<body>
    <form wicket:id="form">
    <input id="name" type="text" placeholder="Username" wicket:id="username">
    <input id="password" type="password" placeholder="Password" wicket:id="password">
    <input type="submit" wicket:id="submit" value="Enter">
    </form>
</body>
</html>

doesn't works with wicket version 6.13+ and great work with wicket 6.12-. Changing Button on something like SubmitLink doesn't help.

Could you tell me what's wrong?

pushistic
  • 3,406
  • 3
  • 21
  • 35
  • 1
    At first sight, I see nothing wrong here. Did you know you can use the form's onSubmit method and not add a submit button to your Wicket component hierarchy? Maybe you simplified your code for the question so this might not apply. It could still be worth a try to find if there's something special with your button. – bernie Apr 01 '14 at 02:50
  • 2
    add `onError` and see if it stops there – Robert Niestroj Apr 01 '14 at 07:59
  • onError doesn't work and move onSubmit method to form doesn't work too. This code I tested before posting there. DEVELOPMENT mode doesn't help. onSubmit don't work for new Wicket or I am loser :( – pushistic Apr 01 '14 at 19:35

2 Answers2

1

Well... hacky but it seems to work with 6.15. Replace encodePageComponentInfo with the following one.

@Override
protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
      Args.notNull(url, "url");

      if (info != null) {
          String s = info.toString();
          if (!Strings.isEmpty(s)) {
              try {
                  Integer.parseInt(s);
              } catch (Exception e) {
                  QueryParameter parameter = new QueryParameter(s, "");
                  url.getQueryParameters().add(parameter);
              }
          }
     }
}
Apostolos
  • 10,033
  • 5
  • 24
  • 39
0

I found problem in my test project. I use changed MountedMapper for hiding version number in the URL:

/**
* Wrapper for hiding the version number in the URL
*/
public class SimpleMountedMapper extends MountedMapper {
    public SimpleMountedMapper(String mountPath, Class<? extends IRequestablePage> pageClass) {
        super(mountPath, pageClass, new PageParametersEncoder());
    }

    @Override
    protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
    }

    public Url mapHandler(IRequestHandler requestHandler) {
        if (requestHandler instanceof ListenerInterfaceRequestHandler) {
            return null;
        } else {
            return super.mapHandler(requestHandler);
        }
    }
}

In new version of wicket something wrong with this implementation (got it from this question).

Community
  • 1
  • 1
pushistic
  • 3,406
  • 3
  • 21
  • 35
  • check my answer. i deleted it earlier because i thought that it broke other functionality but it was another problem that prevented it from running successfully, so i undeleted my answer. it seems to be working. but please check it yourself when you have time. – Apostolos Apr 28 '14 at 12:23