Your CartActionToolbar#markupProvider is infact your form, so you can do
((Form)markupProvider).setDefaultButton(checkoutButton), or you could
make the cartForm a private field in ViewCartPage and just access it
with cartForm.setDefaultButton(checkoutButton).
For the first approach you'll need to assign the markupProvider to a
private field in CartActionToolbar, or make markupProvider final in the
constructor.
Does that help?
-- Edvin
Ritesh Trivedi skrev:
public class ViewCartPage
{
....
// Add feedback panel
add(new FeedbackPanel("feedbackPanel", new
ComponentFeedbackMessageFilter(ViewCartPage.this)));
ShoppingCart cart = ShoppingCartWorkerEx.getShoppingCart();
int cartSize = cart.size();
if (cartSize == 0)
add(new Label("viewCartContainer", new
ResourceModel("Cart.empty.label", "Your Shopping Cart is empty")));
else
add(new CartDetailsFragment("viewCartContainer",
"cartDetailsFragment", this));
}
public class CartDetailsFragment
extends Fragment
{
public static final long serialVersionUID = 1L;
private List<CartItemVo> _cartItemVoList = FastList.<CartItemVo>
newInstance();
public CartDetailsFragment(String id, String fragmentId,
MarkupContainer markupProvider)
{
super(id, fragmentId, markupProvider);
populate();
}
private void populate()
{
_cartItemVoList =
ShoppingCartWorkerEx.getCartItemVoListFromSession();
Form cartForm = new Form("cartForm", new Model(new
ViewCartWrapperModelObject(new ShippingOptionByCriteria(
null, null), _cartItemVoList)));
add(cartForm);
// Cart Header Toolbar
cartForm.add(new CartActionToolbar("cartHeaderToolbar",
"cartActionToolbar", ViewCartPage.this, cartForm));
......
} // end cart detail fragment
private class CartActionToolbar
extends Fragment
{
public CartActionToolbar(String id, String markupId, MarkupContainer
markupProvider)
{
super(id, markupId, markupProvider);
populate();
}
public void populate()
{
// Checkout button
Button checkoutButton = new Button("checkoutButton", new
ResourceModel("CartForm.checkoutButton"))
{
public static final long serialVersionUID = 1L;
@Override
public void onSubmit()
{
...
setResponsePage(CheckoutPage.class);
}
};
add(checkoutButton);
LOG.info("!!!!!!!!!!!!!!!! Checkout button parent " +
checkoutButton.getParent() + " grand parent " +
checkoutButton.getParent().getParent() + " getForm() " +
checkoutButton.getForm() +
" path " + checkoutButton.getPath());
checkoutButton.getForm().setDefaultButton(checkoutButton);
Edvin Syse wrote:
Please post the Java-code.
-- Edvin
Ritesh Trivedi skrev:
Hi,
I have a Page which contains Fragment (A) and which in turn contains
Fragment (B). Fragment B has a button. In Fragment B class if I do
button.getForm() I get null. I also tried button.getParent().getParent()
which should be a form - but it returns null as well.
Here is the markup
<body>
<wicket:extend>
<div class="subColumnHolder">
<div wicket:id="feedbackPanel"></div>
<div wicket:id="viewCartContainer">[Cart Contents
here]</div>
</div>
<wicket:fragment wicket:id="cartContentsFragment">
<h2>Your Shopping Cart</h2>
<p>Please review your shopping cart and press checkout to
proceed with your order</p>
<form wicket:id="cartForm">
<div class="actionButtons"
wicket:id="cartHeaderToolbar"></div> <-----Fragment cartActionToolbar
....
</form>
</wicket:fragment>
<wicket:fragment wicket:id="cartActionToolbar">
<input wicket:id="checkoutButton" type="submit"
value="Checkout <<" class="button floatRight"/>
....
</wicket:fragment>
I have corresponding java code to add components properly - can post if
needed.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]