You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Derick Fernando <de...@thelabllc.com> on 2005/11/22 02:07:46 UTC
Issue with beans of the same class
Hello,
I have two beans declared on a page:
Page:
<bean name="one" class="sandbox.test.Counter"/>
<bean name="two" class="sandbox.test.Counter"/>
Java:
package sandbox.test;
public class Counter
{
private static int count = 0;
public Counter(){ count = 0; }
public int getNext(){ return count++; }
}
Html:
<p jwcid="@For" source="ognl:list" element="literal:p">
Counter 1: <span jwcid="@Insert" value="ognl:beans.one.next"/>
Counter 2: <span jwcid="@Insert" value="ognl:beans.two.next"/>
</p>
Output:
Counter 1: 0 Counter 2: 0
Counter 1: 1 Counter 2: 2
Counter 1: 3 Counter 2: 4
Counter 1: 5 Counter 2: 6
The problem as you can see occurs after the first iteration. I think
this may be a bug, just wanted to make sure before I open an issue in JIRA.
Thanks
.........................................
Derick Fernando
Lead Architect
derickf@thelabllc.com
(323) 314-9593
http://www.thelabllc.com
Content is for intended recipient only.
Copyright 2001-2005, The Lab, LLC
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Issue with beans of the same class
Posted by Derick Fernando <de...@thelabllc.com>.
Missed that,
Thanks
Patrick Casey wrote:
> I don't think it's a bug; I think it's the fact that your "count"
> value is defined as static :). So both your beans are addressing the same
> integer when they count.
>
> --- Pat
>
>
>>-----Original Message-----
>>From: Derick Fernando [mailto:derickf@thelabllc.com]
>>Sent: Monday, November 21, 2005 5:08 PM
>>To: tapestry-user@jakarta.apache.org
>>Subject: Issue with beans of the same class
>>
>>Hello,
>>
>>I have two beans declared on a page:
>>
>>Page:
>>
>><bean name="one" class="sandbox.test.Counter"/>
>><bean name="two" class="sandbox.test.Counter"/>
>>
>>Java:
>>
>>package sandbox.test;
>>
>>public class Counter
>>{
>> private static int count = 0;
>> public Counter(){ count = 0; }
>> public int getNext(){ return count++; }
>>}
>>
>>Html:
>>
>><p jwcid="@For" source="ognl:list" element="literal:p">
>> Counter 1: <span jwcid="@Insert" value="ognl:beans.one.next"/>
>> Counter 2: <span jwcid="@Insert" value="ognl:beans.two.next"/>
>></p>
>>
>>Output:
>>
>>Counter 1: 0 Counter 2: 0
>>Counter 1: 1 Counter 2: 2
>>Counter 1: 3 Counter 2: 4
>>Counter 1: 5 Counter 2: 6
>>
>>The problem as you can see occurs after the first iteration. I think
>>this may be a bug, just wanted to make sure before I open an issue in
>>JIRA.
>>
>>Thanks
>>
>>.........................................
>>
>>Derick Fernando
>>Lead Architect
>>derickf@thelabllc.com
>>(323) 314-9593
>>http://www.thelabllc.com
>>
>>Content is for intended recipient only.
>>Copyright 2001-2005, The Lab, LLC
>>
>>---------------------------------------------------------------------
>>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
>
>
> __________ NOD32 1.1275 (20051103) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>
.........................................
Derick Fernando
Lead Architect
derickf@thelabllc.com
(323) 314-9593
http://www.thelabllc.com
Content is for intended recipient only.
Copyright 2001-2005, The Lab, LLC
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Issue with beans of the same class
Posted by Patrick Casey <pa...@adelphia.net>.
I don't think it's a bug; I think it's the fact that your "count"
value is defined as static :). So both your beans are addressing the same
integer when they count.
--- Pat
> -----Original Message-----
> From: Derick Fernando [mailto:derickf@thelabllc.com]
> Sent: Monday, November 21, 2005 5:08 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Issue with beans of the same class
>
> Hello,
>
> I have two beans declared on a page:
>
> Page:
>
> <bean name="one" class="sandbox.test.Counter"/>
> <bean name="two" class="sandbox.test.Counter"/>
>
> Java:
>
> package sandbox.test;
>
> public class Counter
> {
> private static int count = 0;
> public Counter(){ count = 0; }
> public int getNext(){ return count++; }
> }
>
> Html:
>
> <p jwcid="@For" source="ognl:list" element="literal:p">
> Counter 1: <span jwcid="@Insert" value="ognl:beans.one.next"/>
> Counter 2: <span jwcid="@Insert" value="ognl:beans.two.next"/>
> </p>
>
> Output:
>
> Counter 1: 0 Counter 2: 0
> Counter 1: 1 Counter 2: 2
> Counter 1: 3 Counter 2: 4
> Counter 1: 5 Counter 2: 6
>
> The problem as you can see occurs after the first iteration. I think
> this may be a bug, just wanted to make sure before I open an issue in
> JIRA.
>
> Thanks
>
> .........................................
>
> Derick Fernando
> Lead Architect
> derickf@thelabllc.com
> (323) 314-9593
> http://www.thelabllc.com
>
> Content is for intended recipient only.
> Copyright 2001-2005, The Lab, LLC
>
> ---------------------------------------------------------------------
> 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