You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vaibhav Patil <V....@zensar.com> on 2001/07/12 10:23:17 UTC

Update Iterate tag

Hello Suhas,
I had a problem in updating the bean in iterate tag.
   I have done all the things that were suggested by you. I couldn't work on
it last two days, but 
still the problem persists. Today I am getting one more problem.
I am using following  piece of code in JSP and the corresponding Form bean.
   In one page it is displaying the proper record, but when I again display
same thing in next(confirmation) 
page, it says "exception thrown by getter property of productList"
What might be the problem??
       
          <logic:iterate id="product" name="productSearchForm"
property="productList">
                <bean:write name="product" property="productNumber"
filter="true"/>
                <bean:write name="product" property="productDescription"
filter="true"/>
               <bean:write name="product" property="orderQty"
filter="true"/>
                <html:text name="product" property="quantity" size="3"
maxlength="3" indexed="true"/>
          </logic:iterate>


    public Vector getProductList() {

		System.out.println("In get method fo productlist at start" +
productList.size());		
		if(productList.size() == 0){
        for (int i=0; i<5; i++)
		{
    		Product prod = new Product();
	    	prod.setProductNumber("9999");
	        prod.setOrderQty("50");  
    		prod.setQuantity("100");
	        prod.setProductDescription("This is test product");
	        productList.addElement((Product) prod);
			System.out.println("in for loop");
		}
		}

        System.out.println("returning get method fo productlist");
		return (productList);
		
     }

Thanks,
Vaibhav

Re: Update Iterate tag

Posted by Dmitri Colebatch <di...@nuix.com.au>.
Are you _absolutely sure_ that productList != null.  I've had many scenarios 
where I have two contructors for a form and struts is using the default 
constructor, which didn't create the list - hence a null pointer ex.

cheers
dim






On Thu, 12 Jul 2001 18:23, Vaibhav Patil wrote:
> Hello Suhas,
> I had a problem in updating the bean in iterate tag.
>    I have done all the things that were suggested by you. I couldn't work
> on it last two days, but
> still the problem persists. Today I am getting one more problem.
> I am using following  piece of code in JSP and the corresponding Form bean.
>    In one page it is displaying the proper record, but when I again display
> same thing in next(confirmation)
> page, it says "exception thrown by getter property of productList"
> What might be the problem??
>
>           <logic:iterate id="product" name="productSearchForm"
> property="productList">
>                 <bean:write name="product" property="productNumber"
> filter="true"/>
>                 <bean:write name="product" property="productDescription"
> filter="true"/>
>                <bean:write name="product" property="orderQty"
> filter="true"/>
>                 <html:text name="product" property="quantity" size="3"
> maxlength="3" indexed="true"/>
>           </logic:iterate>
>
>
>     public Vector getProductList() {
>
> 		System.out.println("In get method fo productlist at start" +
> productList.size());
> 		if(productList.size() == 0){
>         for (int i=0; i<5; i++)
> 		{
>     		Product prod = new Product();
> 	    	prod.setProductNumber("9999");
> 	        prod.setOrderQty("50");
>     		prod.setQuantity("100");
> 	        prod.setProductDescription("This is test product");
> 	        productList.addElement((Product) prod);
> 			System.out.println("in for loop");
> 		}
> 		}
>
>         System.out.println("returning get method fo productlist");
> 		return (productList);
>
>      }
>
> Thanks,
> Vaibhav