我是 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!");
}
}
不知道这个问题。提前致谢
最佳答案
在您的 AddStudent.java 构造函数中,您有
panel=new InformationPanel("myPanel");
message=new ModalWindow("InformationDialog");
message.setContent(panel);
Wicket ModalWindow
需要它的内容有一个特定的 id,你没有匹配。
尝试将其更改为
message=new ModalWindow("InformationDialog");
panel=new InformationPanel(message.getContentId());
message.setContent(panel);
message.getContentId()
应该使 ID 对齐。
关于java - Wicket 口 ModalWindow 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4453056/