Wicket:在 Ajax 响应期间显示按钮
我遇到与在页面上显示按钮相关的问题。有两个按钮,分别是“上传”和“保存”。一开始“上传”按钮是可见的,而保存按钮有.setVisible(false)。
…
<tr>
<td width="35%" align="right">
<input type="submit" wicket:id="createUploadButton" value="Upload" class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"/>
</td>
<td width="30%" align="right">
</td>
<td width="35%" align="left">
<input type="submit" wicket:id="createCancelButton" value="Cancel" class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"/>
</td>
</tr>
在上传按钮的Ajax请求期间,需要显示“保存”按钮并隐藏上传按钮,但出现错误。代码片段如下所示:
AjaxButton createSaveButton=new IndicatingAjaxButton("createSaveButton"){
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
// TODO Auto-generated method stub
}
};
createSaveButton.setVisible(uploaded);
createSaveButton.setOutputMarkupId(true);
form.add(createSaveButton);
AjaxButton createUploadButton=new IndicatingAjaxButton("createUploadButton"){
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
…
createUploadButton.setVisible(false);
createSaveButton.setVisible(true);
target.addComponent(createUploadButton);
target.addComponent(createSaveButton);
}
createUploadButton.setOutputMarkupId(true);
form.add(createUploadButton);
有人知道问题出在哪里吗?
谢谢! 索尼娅
I have the problem related to showing the button on the page. There are two buttons called “Upload” and “Save”. On the beginning “Upload” button is visible, while Save button has .setVisible(false).
…
<tr>
<td width="35%" align="right">
<input type="submit" wicket:id="createUploadButton" value="Upload" class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"/>
</td>
<td width="30%" align="right">
</td>
<td width="35%" align="left">
<input type="submit" wicket:id="createCancelButton" value="Cancel" class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"/>
</td>
</tr>
During the AjaxRequest of Upload button it is necessary to show “Save” button and to hide Upload button, but there is the error. Code snippet is shown below:
AjaxButton createSaveButton=new IndicatingAjaxButton("createSaveButton"){
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
// TODO Auto-generated method stub
}
};
createSaveButton.setVisible(uploaded);
createSaveButton.setOutputMarkupId(true);
form.add(createSaveButton);
AjaxButton createUploadButton=new IndicatingAjaxButton("createUploadButton"){
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
…
createUploadButton.setVisible(false);
createSaveButton.setVisible(true);
target.addComponent(createUploadButton);
target.addComponent(createSaveButton);
}
createUploadButton.setOutputMarkupId(true);
form.add(createUploadButton);
Does somebody know where the problem is?
Thanks!
Sonja
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
setOutputMarkupPlacholderTagsetOutputMarkupPlaceholderTag。请参阅:在 HTML 中放置一个可以用 true 按钮替换的隐藏元素。
You need to use
setOutputMarkupPlacholderTagsetOutputMarkupPlaceholderTag. See:To put a hidden element in the HTML that can be replaced with the true button.