tags:

views:

45

answers:

1

Hi all,

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

+3  A: 

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.

stevemac
It's working when I've put:createSaveButton.setOutputMarkupPlacholderTag(true); instead of:createUploadButton.setOutputMarkupPlacholderTag(true);Thank you, very much!
sonjafon
your right, fixed the answer..
stevemac
And, if you call .setOutputMarkupPlacholderTag(true); it's not necessary to call .setOutputMarkupId(true);, as the the first implies the second.
tpdi
sonjafon, please accept the answer by clicking the check icon when it solved your problem.
Thomas Kappler