Hi,

wicket=1.4.17. The following component structure is only executing forms submit method but
not the submit method of the button. Can i achieve this?

i have table markup on my page

<code>
<div class="content>
<form wicket:id="form">
<table>
<thead>
<tr>
<th><wicket:message key="amount">[Amount]</wicket:message></th>
<th><wicket:message key="itemId">[Item id]</wicket:message></th>
<th><wicket:message key="name">[Name]</wicket:message></th>
</tr>
</thead>
<tbody>
<tr wicket:id="entries">
<td><input wicket:id="amount"/><input wicket:id="doChangeAmount" type="submit" /></td>
<td><span wicket:id="itemId">[Item id]</span></td>
<td><span wicket:id="name">[Name]</span></td>
</tr>
</tbody>
</table>
</form>
</div>
</code>

i add a form and a ListView for the entries

<code>
    private Component basketEntries() {
return new StatelessForm<Void>("form").add(new BasketEntries("entries", new LoadableDetachableBasketItemModel(basketId)));
    }
</code>

BasketEntries is a ListView

<code>
public class BasketEntries extends ListView<BasketItemModel> {

public BasketEntries(String id, IModel<List<? extends BasketItemModel>> model) {
        super(id, model);
    }

    @Override
    protected boolean getStatelessHint() {
        return true;
    }

    @Override
    protected void populateItem(ListItem<BasketItemModel> item) {
item.add(new TextField<Integer>("amount", new PropertyModel<Integer>(item.getModel(), BasketItemModel.FIELD_AMOUNT), Integer.class)); item.add(new ChangeBasketItemAmountLink("doChangeAmount", new PropertyModel<BasketItemBO>(item.getModel(), BasketItemModel.FIELD_BASKET_ITEM))); item.add(new Label("itemId", new PropertyModel<String>(item.getModel(), BasketItemModel.FIELD_ITEM_ID))); item.add(new Label("name", new PropertyModel<String>(item.getModel(), BasketItemModel.FIELD_NAME)));
    }
}
</code>

And my ChangeAmountLink is a button

<code>
public class ChangeBasketItemAmountLink extends Button {

    @SpringBean(name=BasketRecorder.NAME)
    private BasketRecorder _basket;

    private final IModel<BasketItemBO> _basketItem;

public ChangeBasketItemAmountLink(String id, IModel<BasketItemBO> model) {
        super(id);
        _basketItem = model;
        setDefaultFormProcessing(false);
    }

    @Override
    public void onSubmit() {
        _basket.changeAmount(getBasketItem());
        setRedirect(true);
        super.onSubmit();
    }

    private BasketItemBO getBasketItem() {
        return _basketItem.getObject();
    }
}
</code>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to