[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    RE: ForEach question
From:       Larry Sherrill <larrypsherrill () yahoo ! com>
Date:       2005-04-29 22:37:23
Message-ID: 20050429223723.85274.qmail () web14026 ! mail ! yahoo ! com
[Download RAW message or body]

That clarifies a lot. Thanks!

--- "Hensley, Richard" <Richard.Hensley@McKesson.com>
wrote:

> You might also want to consider reviewing the lists
> for making properties
> abstract and letting Tapestry handle the resetting.
> I notices that you have
> members here, I would use properties instead and
> code the method something
> like:
> 
>    public void setOnlinePayment(OnlinePayment p) {
>       if (p == null) {
>          return;
>       }
> 	setPayment(p);
> 	setTotal(getTotal() + p.getAmount);
> 	setCount(getCount() + 1);
>    }
> 
>    public abstract double getTotal();
> 
>    public abstract void setTotal(double value);
> 
>    public abstract int getCount();
> 
>    public abstract void setCount(int value);
> 
>    public abstract void setPayment(OnlinePayment p);
> 
> In you .page you do:
> 
> <property-specification name="total" type="double"
> />
> <property-specification name="count" type="int"/>
> <property-specification name="payment"
> type="package.OnlinePayment" />
> 
> As you suspect, what you are seeing is left over
> values when the page is put
> back into the pool. If you did not see this during
> development, but are
> seeing it in production, it is because you turned
> off page pooling during
> development.
> 
> Richard
> 
> -----Original Message-----
> From: Larry Sherrill
> [mailto:larrypsherrill@yahoo.com] 
> Sent: Friday, April 29, 2005 3:18 PM
> To: Tapestry users
> Subject: Re: ForEach question
> 
> The problem arose as I was trying to use the setter
> to
> accumulate a total, which I later call with getTotal
> after the ForEach:
>    public void setOnlinePayment(OnlinePayment p) {
>       if (p == null) {
>          return;
>       }
>       total = total.add(p.getAmount());
>       this.payment = p;
>       count++;
>    }
> 
> The problem is that each invocation of the report is
> doubling the total. I think I just saw a potential
> answer on page 306 regarding the
> PageDetachListener--reseting the ivars to pristine
> values before returning the page to the pool.
> 
> Not sure if this is the recommended approach to 
> totalling during a ForEach.
> 
> Thanks for your help, Larry
> 
> 
> --- Danny Mandel <dmandel@tolweb.org> wrote:
> > Pages are pooled as necessary, so if there were
> two
> > simultaneous 
> > requests that could not share the same page
> object,
> > there would be 
> > another page grabbed from the pool to handle the
> > concurrency issue.
> > 
> > So, it will indeed work and not have any conflicts
> > with mixing data 
> > between different requests.
> > 
> > Hope that helps,
> > Danny
> > 
> > Larry Sherrill wrote:
> > 
> > >Greetings,
> > >
> > >I have a question about ForEach threadsafeness.
> > >
> > >If two browsers clients hit the same Tapestry
> page
> > at
> > >the same time, calling setCustomer/getCustomer at
> > the
> > >same time during the execution of a ForEach loop,
> > how
> > >do the two threads avoid stepping on the customer
> > >instance variable. I've confirmed that the setter
> > is
> > >being called each time, unless I am
> hallucinating.
> > >
> > ><tr jwcid="@Foreach" source="ognl:customerList"
> > >value="ognl:customer" element="tr">
> > >
> > >Am I missing something? I didn't think that a new
> > >instance of the java page was being instantiated
> > each
> > >time, so how does the customer ivar avoid thread
> > safe
> > >issues?
> > >
> > >Thanks, Larry
> > >
> > >
> >
> >__________________________________________________
> > >Do You Yahoo!?
> > >Tired of spam?  Yahoo! Mail has the best spam
> > protection around 
> > >http://mail.yahoo.com 
> > >
> >
>
>---------------------------------------------------------------------
> > >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
> > 
> > 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> 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
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic