Edvin,
Before posting, I already made Form a private member of the toolbar and
passed it from the parent fragment as a workaround.
My main question was - why didnt getForm() on the button work? and second -
not sure how you are saying markupProvider is the form? markup provider is
the page. My page markup file has the fragments. What am I missing?
<wicket:extend>
Cart...
<wicket:fragment wicket:id="fragment1">
<form>
<div id="include_fragment2"></div>
</wicket:fragment>
<wicket:fragment wicket:id="fragment2">
<button wicket:id="checkoutButton"/>
</wicket:fragment>
...
</wicket:extend>
Edvin Syse wrote:
>
> 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]
>
>
>
--
View this message in context:
http://www.nabble.com/getForm%28%29-on-a-component-inside-2nd-level-Fragment-returns-null--tp19166943p19170881.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]