Hi,

I met a problem similar to
WICKET-281<https://issues.apache.org/jira/browse/WICKET-281>.
It sill happens even after our project moves to wicket 1.2.6.

I can regenerate this error (JavaScript errors "Object expected"), when

1) submit a form which will  update ListView in the same page and clear
itself through ajax

This process is a bit similar to the Guest Book Example.

2) click BookMarkablePageLink, which points to a page (includes ajax
component)

3) error happens when you click ajax component

In the html source code, you can't find wicket-ajax.js


Part of my code:

Html

<div id="detail"><p>RMA Request Details:</p>
 <form wicket:id="itemForm">
 <table border="0">
 <tr align="left" valign="bottom">
   <td width="100">Category<select
wicket:id="category">Category</select></td>
   <td width="100">Product<select wicket:id="product">Product</select></td>
   <td width="60">Quantity <input wicket:id="quantity" type="text"
size="5"></td>
   <td></td>
 </tr>
 <tr>
   <td colspan="3" align="left" valign="bottom"><textarea
wicket:id="reason" cols="50" rows="3"></textarea></td>
   <td align="left" valign="bottom"><input wicket:id="addItem"
type="submit" value="Add"></td>
 </tr>
</table>
 </form>
 </div>

 <div wicket:id="showItems">
 <table border="0">
 <thead>
 <tr>
   <th>Category</th>     <th>Product</th>     <th>Amount</th>
<th>Reason</th>     <th></th>
 </tr>
 </thead>
 <tbody>
 <tr wicket:id="item">
   <td><span wicket:id="item_category">item_category</span></td>
   <td><span wicket:id="item_product">item_product</span></td>
   <td><span wicket:id="item_amount">item_amount</span></td>
   <td><span wicket:id="item_reason">item_reason</span></td>
   <td><a href="#" wicket:id="item_drop">Drop item</a></td>
 </tr>
 </tbody>
</table>
 </div>

Java code

public ItemForm(String id) {
           super(id);
       setOutputMarkupId(true);

           IModel cateChoices = new AbstractReadOnlyModel() {
               public Object getObject(Component component) {
                   List cates =  ((RMAApplication)
getApplication()).getRMAService()
                           .getCategories();
                   if(cates == null){
                       cates = Collections.EMPTY_LIST;
                   }
                   return cates;
               }
           };

           IModel prodChoices = new AbstractReadOnlyModel() {
               public Object getObject(Component component) {
                   List prods;
                   if(getSelectedCategory() != null){
                   Category cate = ((RMAApplication) getApplication())
                           .getRMAService().getCategoryByID(
                                   getSelectedCategory().getId());
                   prods = new ArrayList(cate.getProducts());
                   }else{
                       prods = Collections.EMPTY_LIST;
                   }

                   return prods;
               }

           };

           final DropDownChoice cates = new DropDownChoice("category",
                   new PropertyModel(this, "selectedCategory"),
cateChoices);
           cates.setRequired(true);

           final DropDownChoice prods = new DropDownChoice("product",
                   new PropertyModel(this, "selectedProduct"),
prodChoices);
           prods.setRequired(true);

           add(cates);
           add(prods);

           cates.add(new AjaxFormComponentUpdatingBehavior("onchange") {
               protected void onUpdate(AjaxRequestTarget target) {
                   target.addComponent(prods);
               }
           });
           FormComponent quantity = new RequiredTextField("quantity",
                   new PropertyModel(this, "quantity"));
           quantity.add(new QuantityValidator());
           add(quantity);

           FormComponent reason = new TextArea("reason", new PropertyModel(
                   this, "reason"));
           reason.setRequired(true);
           add(reason);

           add(new AjaxSubmitButton("addItem", this) {
               protected void onSubmit(AjaxRequestTarget target, Form form)
{
                   // repaint the feedback panel so that it is hidden
                   target.addComponent(feedback);
                   target.addComponent(form);
                   target.addComponent(itemsContainer);
               }

               protected void onError(AjaxRequestTarget target, Form form)
{
                   // repaint the feedback panel so errors are shown
                   target.addComponent(feedback);
               }
           });

       }

       public void onSubmit(){
           Item item = new Item(getSelectedProduct(), Integer
                   .parseInt(getQuantity()));
           item.setReturn_reason(getReason());
           Request r = ((RMASession) getSession()).getRequest();
           r.addItem(item);

           setSelectedCategory(null);
           setSelectedProduct(null);
           setQuantity(null);
           setReason(null);
       }


Conglun
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to