Hi,
I am observing really weird form behavior. See code below. For some reason
the quantity and the checkbox for each item in the view is only updated the
first time I submit the form. Second time onwards in the
SubmitLink.onSubmit() I dont get updated form field values. Have spent hours
moving things around without success.
// Cart Form
Form cartForm = new Form("cartForm");
add(cartForm);
// Shipping Options Panel
final Panel shippingOptionsPanel = new
ShippingOptionsPanel("shippingOptionsPanel");
cartForm.add(shippingOptionsPanel);
// Cart Header Toolbar
WebMarkupContainer headerToolbar = new
WebMarkupContainer("cartHeaderToolbar");
cartForm.add(headerToolbar);
headerToolbar.add(new BookmarkablePageLink("continueShopping",
HomePage.class));
SubmitLink updateCartLink = new SubmitLink("updateCartLink",
cartForm)
{
public static final long serialVersionUID = 1L;
@Override
public void onSubmit()
{
ShoppingCartWorkerEx.modifyCart(_cartItemValueObjList,
true, true);
_cartItemValueObjList =
ShoppingCartWorkerEx.getCartItemsValueObjsFromSession();
// Refresh the page only if there are no items in cart
if (ShoppingCartWorkerEx.getShoppingCart().size() == 0)
setResponsePage(new ViewCartPage());
else
{
shippingOptionsPanel.modelChanged();
LOG.info("====> Update cart link using the same
page");
}
}
};
headerToolbar.add(updateCartLink);
updateCartLink.add(new OfbizImage("updateCartImage"));
headerToolbar.add(new CheckoutButton("checkoutButton", new
ResourceModel("CartForm.checkoutButton")));
// Show Cart Items
final DataView cartItemView = new DataView("cartItemView", new
ListDataProvider(_cartItemValueObjList))
{
public static final long serialVersionUID = 1L;
@Override
protected void populateItem(Item item)
{
CartItemValueObj formCartItem =
(CartItemValueObj)item.getModelObject();
item.setModel(new CompoundPropertyModel(formCartItem));
item.add(new Label("index", new
Model(item.getIndex()+1)).setRenderBodyOnly(true));
PopupSettings popupSettings =
new PopupSettings(PageMap.forName("popupPageMap"),
PopupSettings.SCROLLBARS|PopupSettings.RESIZABLE).setHeight(400).setWidth(400);
Link productLink = new
BookmarkablePageLink("productLink",
NoNavProductDetailPage.class, new
PageParameters("productId=" + formCartItem.getProductId() +
",
popup=true")).setPopupSettings(popupSettings);
productLink.add(new Label("name"));
item.add(productLink);
item.add(new
FormComponentFeedbackBorder("quantityBorder").
add(new
TextField("quantity").setRequired(true).setLabel(new Model("Quantity"))
.add(NumberValidator.minimum(1))));
item.add(new CurrencyLabel("itemSubTotal"));
item.add(new CheckBox("markedForRemove"));
}
@Override
protected Item newItem(String id, int index, IModel model)
{
return new OddEvenItem(id, index, model);
}
};
cartForm.add(cartItemView);
--
View this message in context:
http://www.nabble.com/Weird-form-behavior-tp17158833p17158833.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]