检票口 ModalWindow 错误

发布于 2024-10-07 18:27:08 字数 1844 浏览 1 评论 0原文

我是 wicket 新手,当我尝试运行我的应用程序时,我收到以下错误:

WicketMessage:模态窗口内容 id 错误。组件ID:myPanel;内容 ID:内容:

在我的 AddStudent html 中:

<span wicket:id="InformationDialog"/>
<span wicket:id="myPanel"/>

这些是在 AddStudent.java 中的开始标记之后的第一件事

(在构造函数中):

panel=new InformationPanel("myPanel");
message=new ModalWindow("InformationDialog");
message.setContent(panel);
message.setCssClassName(ModalWindow.CSS_CLASS_BLUE);
message.setTitle("Important Information");

其中 InformationPanel 扩展了 Panel:

<html>
<wicket:panel>
<table>
<tr>
<td><span wicket:id="message"/></td>
</tr>
<tr>
<td><input type ="button" value ="OK" wicket:id="ok"/></td>
</tr>
</table>
</wicket:panel>
<html>

显然,我有一个相应的 java 类 - 它可能不相关,但在这里它是:

package myapp.project;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.panel.Panel;

public class InformationPanel extends Panel {
    private Button ok;
    private Label messageLabel;
    public InformationPanel(String id){
        super(id);
        messageLabel=new Label("message","");
        ok=new Button("ok"){
            public void onSubmit(){
                AddStudent student = new AddStudent();
                setResponsePage(student);
            }
        };
        add(ok);
        add(messageLabel);

    }
    public void setSuccessful(){
        messageLabel.setDefaultModelObject("You have successfully added the student");
    }
    public void setUnSuccessful(){
        messageLabel.setDefaultModelObject("A student with that username already exists!");
    }

}

不知道问题所在。提前致谢

I'm new to wicket, and I get he following error when I try to run my application:

WicketMessage: Modal window content id is wrong. Component ID:myPanel; content ID: content:

in my AddStudent html:

<span wicket:id="InformationDialog"/>
<span wicket:id="myPanel"/>

These are the first things after my opening tag

in AddStudent.java(in the constructor):

panel=new InformationPanel("myPanel");
message=new ModalWindow("InformationDialog");
message.setContent(panel);
message.setCssClassName(ModalWindow.CSS_CLASS_BLUE);
message.setTitle("Important Information");

where InformationPanel extends Panel:

<html>
<wicket:panel>
<table>
<tr>
<td><span wicket:id="message"/></td>
</tr>
<tr>
<td><input type ="button" value ="OK" wicket:id="ok"/></td>
</tr>
</table>
</wicket:panel>
<html>

Obviously, I have a corresponding java class-it might not be relevant but here it is:

package myapp.project;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.panel.Panel;

public class InformationPanel extends Panel {
    private Button ok;
    private Label messageLabel;
    public InformationPanel(String id){
        super(id);
        messageLabel=new Label("message","");
        ok=new Button("ok"){
            public void onSubmit(){
                AddStudent student = new AddStudent();
                setResponsePage(student);
            }
        };
        add(ok);
        add(messageLabel);

    }
    public void setSuccessful(){
        messageLabel.setDefaultModelObject("You have successfully added the student");
    }
    public void setUnSuccessful(){
        messageLabel.setDefaultModelObject("A student with that username already exists!");
    }

}

No idea of the problem. Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亽野灬性zι浪 2024-10-14 18:27:08

在您的 AddStudent.java 构造函数中,您的

panel=new InformationPanel("myPanel");
message=new ModalWindow("InformationDialog");
message.setContent(panel);

Wicket ModalWindow 需要其内容具有特定的 id,但您不匹配该 id。

尝试将其更改为

message=new ModalWindow("InformationDialog");
panel=new InformationPanel(message.getContentId());
message.setContent(panel);

message.getContentId() 应该使 id 对齐。

In your AddStudent.java constructor , you have

panel=new InformationPanel("myPanel");
message=new ModalWindow("InformationDialog");
message.setContent(panel);

Wicket ModalWindow needs its content to have a specific id, which you're not matching.

Try changing this to

message=new ModalWindow("InformationDialog");
panel=new InformationPanel(message.getContentId());
message.setContent(panel);

The message.getContentId() should make the ids align.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文