Wicket:在 Ajax 响应期间显示按钮

发布于 2024-09-12 18:23:38 字数 1682 浏览 2 评论 0原文

我遇到与在页面上显示按钮相关的问题。有两个按钮,分别是“上传”和“保存”。一开始“上传”按钮是可见的,而保存按钮有.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 技术交流群。

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

发布评论

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

评论(1

热风软妹 2024-09-19 18:23:38

您需要使用setOutputMarkupPlacholderTag setOutputMarkupPlaceholderTag。请参阅:

createSaveButton.setVisible(uploaded);
createSaveButton.setOutputMarkupId(true);

// Add This line
createSaveButton.setOutputMarkupPlaceholderTag(true);
form.add(createSaveButton);

在 HTML 中放置一个可以用 true 按钮替换的隐藏元素。

You need to use setOutputMarkupPlacholderTag setOutputMarkupPlaceholderTag. See:

createSaveButton.setVisible(uploaded);
createSaveButton.setOutputMarkupId(true);

// Add This line
createSaveButton.setOutputMarkupPlaceholderTag(true);
form.add(createSaveButton);

To put a hidden element in the HTML that can be replaced with the true button.

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