You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Travis Romney <tr...@inpowered.com> on 2004/08/07 20:38:07 UTC

Re: Help!!! Problem with ListEdit component when adding additional rows

You need to make sure that when that page first
starts rendering that your list edit component is not null.
You could try something like this:

public void pageBeginRender(PageEvent pe) {
    if (pe.getRequestCycle().isRewinding()) {
     return;
    }
    if(getListEditMap() == null) {
	setListEditMap(new ListEditMap());
    }
    readPoItem();
   }


Mark.Lomongo@rcgit.com wrote:
> 
> 
> 
> 
> 
> I have a purchase order page and users can add items into it.  I used the
> ListEdit to implement this, if I start with a list of items it works well
> but when I start adding items it displays the following error.  Thanks
> 
> org.apache.tapestry.BindingException
> Unable to update expression 'listEditMap.key' for
> inpowered.stock.warehousing.pages.PurchaseOrderPage$Enhance_20@1896a4c[purchaseorder
>  ] to 133.
> binding:  ExpressionBinding[purchaseorder listEditMap.key]
> location:
> context:/WEB-INF/tapestry/inpowered/stock/warehousing/purchaseorder.page,
> line 39, column 58
> 
> ognl.OgnlException
> target is null for setProperty(null, "key", 133)
> 
> here's the code snippet...
> <property-specification name = "listEditMap" type =
> "org.apache.tapestry.form.ListEditMap" />
> <property-specification name = "poItem" type =
> "inpowered.stock.warehousing.model.PurchaseOrderItemModel" persistent =
> "yes" />
> <component id = "listEdit" type = "ListEdit" >
>     <binding name = "source" expression = "listEditMap.keys" />
>     <binding name = "value" expression = "listEditMap.key" />
>     <static-binding name = "element" value = "tr" />
> <binding name = "listener" expression = "listeners.synchronizePoItem" />
> </component>
> 
>  public abstract ListEditMap getListEditMap();
>  public abstract void setListEditMap(ListEditMap listEditMap);
>  public abstract PurchaseOrderItemModel getPoItem();
>  public abstract void setPoItem(PurchaseOrderItemModel poItem);
>  private ArrayList poItemList = new ArrayList();
> 
>  public void pageBeginRender(PageEvent pe) {
>   if (pe.getRequestCycle().isRewinding()) {
>    return;
>   }
>   readPoItem();
>  }
> 
>  public void addItem(IRequestCycle cycle) {
>      Product product = getProduct();
>      PurchaseOrderItemModel poItem = new PurchaseOrderItemModel();
>      ...
>      poItemList.add(poItem);
>      return;
>     }
> 
>   public void synchronizePoItem(IRequestCycle cycle) {
>     ListEditMap map = getListEditMap();
>     PurchaseOrderItemModel poItem = (PurchaseOrderItemModel)
>     map.getValue();
>     if (poItem == null) {
>       throw new PageRedirectException(this);
>     }
>     setPoItem(poItem);
>   }
> 
>  private void readPoItem() {
>   ListEditMap map = new ListEditMap();
>   int count = Tapestry.size(poItemList);
>   for (int i = 0; i < count; i++) {
>    PurchaseOrderItemModel poim = (PurchaseOrderItemModel) poItemList
>      .get(i);
>    map.add(poim.getProductID(), poim);
>   }
>    setListEditMap(map);
> }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org