我是wicket的新手,当我尝试运行我的应用程序时,他遇到错误:
WicketMessage:模态窗口内容ID错误。组件ID:myPanel;内容ID:内容:
在我的AddStudent html中:
<span wicket:id="InformationDialog"/>
<span wicket:id="myPanel"/>
这是我打开标签后的第一件事
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!");
}
}
不知道这个问题。提前致谢
答案 0 :(得分:7)
在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对齐。