Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wicket提交操作不';行不通_Wicket - Fatal编程技术网

Wicket提交操作不';行不通

Wicket提交操作不';行不通,wicket,Wicket,将Wicket从版本6.12更新到6.13/6.14后,提交操作不起作用。例如,课程: public class LoginPage extends WebPage { private String username = ""; private String password = ""; public LoginPage() { super(); Form<?> form = new Form<Void>("fo

将Wicket从版本6.12更新到6.13/6.14后,提交操作不起作用。例如,课程:

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);

    }
}
公共类登录页面扩展网页{
私有字符串用户名=”;
私有字符串密码=”;
公共登录页(){
超级();
表格=新表格(“表格”);
setDefaultModel(新的CompoundPropertyModel(this));
表格.添加(新按钮(“提交”){
@凌驾
提交时公共无效(){
System.out.println(“提交”+用户名+:“+密码);
}
});
添加(新文本字段(“用户名”).setRequired(true));
添加(新密码文本字段(“密码”).setRequired(true));
添加(表格);
}
}
使用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>

不适用于wicket 6.13+版本,适用于wicket 6.12-。更改SubmitLink之类的按钮没有帮助


你能告诉我出了什么问题吗?

我在测试项目中发现了问题。我使用已更改的MountedMapper在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);
        }
    }
}
/**
*用于在URL中隐藏版本号的包装器
*/
公共类SimpleMontedMapper扩展了MountedMapper{

公共SimpleMountedMapper(String mountPath,Class很好…有点粗糙,但它似乎适用于6.15。 将encodePageComponentInfo替换为以下内容

@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);
              }
          }
     }
}

乍一看,我看这里没有什么问题。你知道你可以使用表单的onSubmit方法,而不向Wicket组件层次结构中添加submit按钮吗?也许你简化了问题的代码,因此这可能不适用。也许仍然值得一试,看看你的按钮是否有什么特别之处。添加
onError
,然后看我如果停止,则OneRor不工作,将Submit方法移动到form也不工作。我在发布之前测试了此代码。开发模式没有帮助。onSubmit不适用于new Wicket,否则我将失败:(检查我的答案。我之前删除了它,因为我认为它破坏了其他功能,但这是另一个阻止它成功运行的问题,因此我取消了删除我的答案。它似乎正在工作。但请您自己在有时间时检查它。)。