You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Daniel Jue <te...@gmail.com> on 2007/05/17 17:40:58 UTC

[Tap 4.1.2] Problem with repeated calls to an If component

Hi,

I experienced this problem after upgrading from Tap 4.1 to Tap 4.1.2 Snapshot.
The problem is that I have an IF component that is being called 3
times, when it should only be called once.

I have extracted the problem into a simpler page for examination:

plain.page:


<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification class="com.phy6.app.plain">
</page-specification>



plain.java:


package com.phy6.app;

import javax.servlet.ServletContext;

import org.apache.tapestry.IComponent;
import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.InitialValue;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.annotations.InjectStateFlag;
import org.apache.tapestry.html.BasePage;

public abstract class plain extends BasePage {

	/**
	 * @return a boolean indicating if the the user is logged in
	 */
	@InjectStateFlag("user")
	public abstract boolean getUserExists();

	@InitialValue("0")
	public abstract int getNumber();

	public abstract void setNumber(int n);

	/**
	 * @return the servlet context
	 */
	@InjectObject("service:tapestry.globals.ServletContext")
	public abstract ServletContext getServletContext();

	@Component(type = "If", id = "ifUserIsLoggedIn", bindings = {
		"condition=getUserIsLoggedIn()" })
	public abstract IComponent getIfUserIsLoggedIn();

	/**
	 * @return a boolean indicating whether or not a user is logged in.
	 */
	public boolean getUserIsLoggedIn() {
		setNumber(getNumber() + 1);
		System.out.println("plain: getUserIsLoggedIn() " + getNumber());
		return getUserExists();
	}
	@Component(type="Insert",id="wtfisgoingon",bindings={"value=getNumber()"})
	public abstract IComponent getWTFisgoingon();
}



plain.html:


<html>
<body jwcid="$content$">
<span jwcid="ifUserIsLoggedIn">Hi</span>
<span jwcid="wtfisgoingon" />
</body>
</html>


Output to console:

INFO: Server startup in 3966 ms
plain: getUserIsLoggedIn() 1
plain: getUserIsLoggedIn() 2
plain: getUserIsLoggedIn() 3


Output to browser:

<html>
<body>

3
</body>
</html>



Note that I've stripped the code down.  There is no way for the user
to exist in this example, I'm simply reloading the page when the
server starts.  (Tomcat 5.5.23)  This code was part of my Home.page,
which decides whether or not to display a login component or greet the
user.

How can I get it to only check the IF component once? (or better yet,
why is it called three times?)

Daniel

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


[Tap 4.1.3] multiple ognl evaluation problem (was Re: [Tap 4.1.2] Problem with repeated calls to an If component)

Posted by Aaron Kaminsky <aa...@adaptiveplanning.com>.
Hi all,

I am on Tap 4.1.3 (using the released binary) and I am also experiencing 
this behavior.  I cannot find any documentation on this situation or a 
workaround other than Jesse's comments in this thread.  Can someone 
point me to more information on how to work around this multiple ognl 
evaluation?  I am migrating a big application from Tap3 and I have lots 
of legacy code that is currently broken because of this behavior.

Thank you,
Aaron

Jesse Kuhnert wrote:
> It's something that will happen to all ognl expressions for the next 
> week or
> two.  After that they will be resolved as per normal in development 
> mode and
> jit'ed in production.
>
> On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
>>
>> Jesse, I stepped away from the computer for a bit, and I had just now
>> submitted the JIRA before updating this conversation.
>>
>> https://issues.apache.org/jira/browse/TAPESTRY-1477
>>
>> I am happy to know it is something that happens on purpose, and for
>> developmental issues.  I would hate to have my DAO's get called 3
>> times in production though, so if similar ensurances are left in, I
>> hope there would be a way to turn it off via a flag, etc.
>>
>> Does this "ensuring" feature only apply to IF components, or to others
>> as well?  (i.e. are expressions for other components being evaluated
>> multiple times?)  I have one dynamic form component that can make use
>> of up to 40 other core components based on multiple if/else
>> components.
>>
>> I also feel assured now that this isn't some ill procedure that would
>> potentially break something down the line.
>>
>> Daniel
>>
>> On 5/17/07, Jesse Kuhnert <jk...@gmail.com> wrote:
>> > No need for JIRA issues - I know exactly why it's doing it and
>> intentionally
>> > have it running this way.
>> >
>> > Unfortunately it's the only sane way I know to make sure 4.1.2 is
>> > releasable.  There's no actual need for OGNL expressions to be 
>> compiled
>> in
>> > dev mode but otherwise I'd have no way of ensuring that your happily
>> > developed app didn't work quite the same way in production. 
>> ...Would you
>> > rather be annoyed for another week or two until the release or get a
>> phone
>> > call at 2am that the app is blowing up and wtf have you done we're
>> totally
>> > screwed? =p
>> >
>> > On 5/17/07, Andreas Andreou <an...@di.uoa.gr> wrote:
>> > >
>> > > Add a JIRA please.
>> > > At least since 4.1.2-20070501.233137-64, i can see the first If
>> getting
>> > > called 3 times!
>> > > And it's probably the first @If after an app reset that gets 
>> evaluated
>> 3
>> > > times and not
>> > > the first @If of a page.
>> > >
>> > > An old 4.1.2-20070215.051249-15 worked correctly, i cant test other
>> (in
>> > > between)
>> > > versions right now due to dependencies incompatibilities.
>> > >
>> > >
>> > >
>> > > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
>> > > >
>> > > > Ugh.  This is a big pain now.  I have a huge dynamic form that has
>> > > > lots of IFs, and I can see the same queries being called 3 
>> times or
>> > > > more.  =(
>> > > > Everything still works, it's just about 3 times slower.
>> > > >
>> > > > If anyone has solved this problem please let me know!
>> > > >
>> > > > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
>> > > > > Here is another example when more than one IF component is used.
>> > > > >
>> > > > > It seems the conditional for the first IF gets called 3 times,
>> then
>> > > > > the others just get called once.
>> > > > >
>> > > > > plain.java:
>> > > > >
>> > > > > package com.phy6.app;
>> > > > >
>> > > > > import org.apache.tapestry.IComponent;
>> > > > > import org.apache.tapestry.annotations.Component;
>> > > > > import org.apache.tapestry.annotations.InitialValue;
>> > > > > import org.apache.tapestry.html.BasePage;
>> > > > >
>> > > > > public abstract class plain extends BasePage {
>> > > > >
>> > > > >         public boolean getDoStuff() {
>> > > > >                 this.setNumber(this.getNumber() + 1);
>> > > > >                 System.out.println("plain: getDoStuff() " +
>> > > > this.getNumber());
>> > > > >                 return false;
>> > > > >         }
>> > > > >
>> > > > >         @Component(type = "If", id = "ifXYZ", bindings = {
>> > > > "condition=getDoStuff()" })
>> > > > >         public abstract IComponent getIfXYZ();
>> > > > >
>> > > > >         @Component(type = "If", id = "ifABC", bindings = {
>> > > > "condition=getDoStuff()" })
>> > > > >         public abstract IComponent getIfABC();
>> > > > >
>> > > > >         @Component(type = "If", id = "ifDEF", bindings = {
>> > > > "condition=getDoStuff()" })
>> > > > >         public abstract IComponent getIfDEF();
>> > > > >
>> > > > >         @Component(type = "If", id = "ifGHI", bindings = {
>> > > > "condition=getDoStuff()" })
>> > > > >         public abstract IComponent getIfGHI();
>> > > > >
>> > > > >         @InitialValue("0")
>> > > > >         public abstract int getNumber();
>> > > > >
>> > > > >         @Component(type = "Insert", id = "wtfisgoingon", 
>> bindings
>> = {
>> > > > > "value=getNumber()" })
>> > > > >         public abstract IComponent getWTFisgoingon();
>> > > > >
>> > > > >         public abstract void setNumber(int n);
>> > > > > }
>> > > > >
>> > > > >
>> > > > >
>> > > > > plain.html
>> > > > >
>> > > > > <html>
>> > > > > <body>
>> > > > > <span jwcid="ifXYZ">Hi XYZ</span>
>> > > > > <span jwcid="ifABC">Hi ABC</span>
>> > > > > <span jwcid="ifDEF">Hi DEF</span>
>> > > > > <span jwcid="ifGHI">Hi GHI</span>
>> > > > > <span jwcid="wtfisgoingon" />
>> > > > > </body>
>> > > > > </html>
>> > > > >
>> > > > >
>> > > > > plain.page is an empty page spec.
>> > > > >
>> > > > > Output:
>> > > > > INFO: Server startup in 3645 ms
>> > > > > plain: getDoStuff() 1
>> > > > > plain: getDoStuff() 2
>> > > > > plain: getDoStuff() 3
>> > > > > plain: getDoStuff() 4
>> > > > > plain: getDoStuff() 5
>> > > > > plain: getDoStuff() 6
>> > > > >
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > > > For additional commands, e-mail: users-help@tapestry.apache.org
>> > > >
>> > > >
>> > >
>> > >
>> > > --
>> > > Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
>> > > Tapestry / Tacos developer
>> > > Open Source / JEE Consulting
>> > >
>> >
>> >
>> >
>> > --
>> > Jesse Kuhnert
>> > Tapestry/Dojo team member/developer
>> >
>> > Open source based consulting work centered around
>> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>


-- 
See how easy it can be to move beyond spreadsheets for budgeting, 
forecasting and reporting! Try Adaptive Planning now: Trial Enterprise 
Edition | Use Free Express Edition

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


Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's something that will happen to all ognl expressions for the next week or
two.  After that they will be resolved as per normal in development mode and
jit'ed in production.

On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
>
> Jesse, I stepped away from the computer for a bit, and I had just now
> submitted the JIRA before updating this conversation.
>
> https://issues.apache.org/jira/browse/TAPESTRY-1477
>
> I am happy to know it is something that happens on purpose, and for
> developmental issues.  I would hate to have my DAO's get called 3
> times in production though, so if similar ensurances are left in, I
> hope there would be a way to turn it off via a flag, etc.
>
> Does this "ensuring" feature only apply to IF components, or to others
> as well?  (i.e. are expressions for other components being evaluated
> multiple times?)  I have one dynamic form component that can make use
> of up to 40 other core components based on multiple if/else
> components.
>
> I also feel assured now that this isn't some ill procedure that would
> potentially break something down the line.
>
> Daniel
>
> On 5/17/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> > No need for JIRA issues - I know exactly why it's doing it and
> intentionally
> > have it running this way.
> >
> > Unfortunately it's the only sane way I know to make sure 4.1.2 is
> > releasable.  There's no actual need for OGNL expressions to be compiled
> in
> > dev mode but otherwise I'd have no way of ensuring that your happily
> > developed app didn't work quite the same way in production. ...Would you
> > rather be annoyed for another week or two until the release or get a
> phone
> > call at 2am that the app is blowing up and wtf have you done we're
> totally
> > screwed? =p
> >
> > On 5/17/07, Andreas Andreou <an...@di.uoa.gr> wrote:
> > >
> > > Add a JIRA please.
> > > At least since 4.1.2-20070501.233137-64, i can see the first If
> getting
> > > called 3 times!
> > > And it's probably the first @If after an app reset that gets evaluated
> 3
> > > times and not
> > > the first @If of a page.
> > >
> > > An old 4.1.2-20070215.051249-15 worked correctly, i cant test other
> (in
> > > between)
> > > versions right now due to dependencies incompatibilities.
> > >
> > >
> > >
> > > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> > > >
> > > > Ugh.  This is a big pain now.  I have a huge dynamic form that has
> > > > lots of IFs, and I can see the same queries being called 3 times or
> > > > more.  =(
> > > > Everything still works, it's just about 3 times slower.
> > > >
> > > > If anyone has solved this problem please let me know!
> > > >
> > > > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> > > > > Here is another example when more than one IF component is used.
> > > > >
> > > > > It seems the conditional for the first IF gets called 3 times,
> then
> > > > > the others just get called once.
> > > > >
> > > > > plain.java:
> > > > >
> > > > > package com.phy6.app;
> > > > >
> > > > > import org.apache.tapestry.IComponent;
> > > > > import org.apache.tapestry.annotations.Component;
> > > > > import org.apache.tapestry.annotations.InitialValue;
> > > > > import org.apache.tapestry.html.BasePage;
> > > > >
> > > > > public abstract class plain extends BasePage {
> > > > >
> > > > >         public boolean getDoStuff() {
> > > > >                 this.setNumber(this.getNumber() + 1);
> > > > >                 System.out.println("plain: getDoStuff() " +
> > > > this.getNumber());
> > > > >                 return false;
> > > > >         }
> > > > >
> > > > >         @Component(type = "If", id = "ifXYZ", bindings = {
> > > > "condition=getDoStuff()" })
> > > > >         public abstract IComponent getIfXYZ();
> > > > >
> > > > >         @Component(type = "If", id = "ifABC", bindings = {
> > > > "condition=getDoStuff()" })
> > > > >         public abstract IComponent getIfABC();
> > > > >
> > > > >         @Component(type = "If", id = "ifDEF", bindings = {
> > > > "condition=getDoStuff()" })
> > > > >         public abstract IComponent getIfDEF();
> > > > >
> > > > >         @Component(type = "If", id = "ifGHI", bindings = {
> > > > "condition=getDoStuff()" })
> > > > >         public abstract IComponent getIfGHI();
> > > > >
> > > > >         @InitialValue("0")
> > > > >         public abstract int getNumber();
> > > > >
> > > > >         @Component(type = "Insert", id = "wtfisgoingon", bindings
> = {
> > > > > "value=getNumber()" })
> > > > >         public abstract IComponent getWTFisgoingon();
> > > > >
> > > > >         public abstract void setNumber(int n);
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > plain.html
> > > > >
> > > > > <html>
> > > > > <body>
> > > > > <span jwcid="ifXYZ">Hi XYZ</span>
> > > > > <span jwcid="ifABC">Hi ABC</span>
> > > > > <span jwcid="ifDEF">Hi DEF</span>
> > > > > <span jwcid="ifGHI">Hi GHI</span>
> > > > > <span jwcid="wtfisgoingon" />
> > > > > </body>
> > > > > </html>
> > > > >
> > > > >
> > > > > plain.page is an empty page spec.
> > > > >
> > > > > Output:
> > > > > INFO: Server startup in 3645 ms
> > > > > plain: getDoStuff() 1
> > > > > plain: getDoStuff() 2
> > > > > plain: getDoStuff() 3
> > > > > plain: getDoStuff() 4
> > > > > plain: getDoStuff() 5
> > > > > plain: getDoStuff() 6
> > > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> > > Tapestry / Tacos developer
> > > Open Source / JEE Consulting
> > >
> >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Daniel Jue <te...@gmail.com>.
Jesse, I stepped away from the computer for a bit, and I had just now
submitted the JIRA before updating this conversation.

https://issues.apache.org/jira/browse/TAPESTRY-1477

I am happy to know it is something that happens on purpose, and for
developmental issues.  I would hate to have my DAO's get called 3
times in production though, so if similar ensurances are left in, I
hope there would be a way to turn it off via a flag, etc.

Does this "ensuring" feature only apply to IF components, or to others
as well?  (i.e. are expressions for other components being evaluated
multiple times?)  I have one dynamic form component that can make use
of up to 40 other core components based on multiple if/else
components.

I also feel assured now that this isn't some ill procedure that would
potentially break something down the line.

Daniel

On 5/17/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> No need for JIRA issues - I know exactly why it's doing it and intentionally
> have it running this way.
>
> Unfortunately it's the only sane way I know to make sure 4.1.2 is
> releasable.  There's no actual need for OGNL expressions to be compiled in
> dev mode but otherwise I'd have no way of ensuring that your happily
> developed app didn't work quite the same way in production. ...Would you
> rather be annoyed for another week or two until the release or get a phone
> call at 2am that the app is blowing up and wtf have you done we're totally
> screwed? =p
>
> On 5/17/07, Andreas Andreou <an...@di.uoa.gr> wrote:
> >
> > Add a JIRA please.
> > At least since 4.1.2-20070501.233137-64, i can see the first If getting
> > called 3 times!
> > And it's probably the first @If after an app reset that gets evaluated 3
> > times and not
> > the first @If of a page.
> >
> > An old 4.1.2-20070215.051249-15 worked correctly, i cant test other (in
> > between)
> > versions right now due to dependencies incompatibilities.
> >
> >
> >
> > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> > >
> > > Ugh.  This is a big pain now.  I have a huge dynamic form that has
> > > lots of IFs, and I can see the same queries being called 3 times or
> > > more.  =(
> > > Everything still works, it's just about 3 times slower.
> > >
> > > If anyone has solved this problem please let me know!
> > >
> > > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> > > > Here is another example when more than one IF component is used.
> > > >
> > > > It seems the conditional for the first IF gets called 3 times, then
> > > > the others just get called once.
> > > >
> > > > plain.java:
> > > >
> > > > package com.phy6.app;
> > > >
> > > > import org.apache.tapestry.IComponent;
> > > > import org.apache.tapestry.annotations.Component;
> > > > import org.apache.tapestry.annotations.InitialValue;
> > > > import org.apache.tapestry.html.BasePage;
> > > >
> > > > public abstract class plain extends BasePage {
> > > >
> > > >         public boolean getDoStuff() {
> > > >                 this.setNumber(this.getNumber() + 1);
> > > >                 System.out.println("plain: getDoStuff() " +
> > > this.getNumber());
> > > >                 return false;
> > > >         }
> > > >
> > > >         @Component(type = "If", id = "ifXYZ", bindings = {
> > > "condition=getDoStuff()" })
> > > >         public abstract IComponent getIfXYZ();
> > > >
> > > >         @Component(type = "If", id = "ifABC", bindings = {
> > > "condition=getDoStuff()" })
> > > >         public abstract IComponent getIfABC();
> > > >
> > > >         @Component(type = "If", id = "ifDEF", bindings = {
> > > "condition=getDoStuff()" })
> > > >         public abstract IComponent getIfDEF();
> > > >
> > > >         @Component(type = "If", id = "ifGHI", bindings = {
> > > "condition=getDoStuff()" })
> > > >         public abstract IComponent getIfGHI();
> > > >
> > > >         @InitialValue("0")
> > > >         public abstract int getNumber();
> > > >
> > > >         @Component(type = "Insert", id = "wtfisgoingon", bindings = {
> > > > "value=getNumber()" })
> > > >         public abstract IComponent getWTFisgoingon();
> > > >
> > > >         public abstract void setNumber(int n);
> > > > }
> > > >
> > > >
> > > >
> > > > plain.html
> > > >
> > > > <html>
> > > > <body>
> > > > <span jwcid="ifXYZ">Hi XYZ</span>
> > > > <span jwcid="ifABC">Hi ABC</span>
> > > > <span jwcid="ifDEF">Hi DEF</span>
> > > > <span jwcid="ifGHI">Hi GHI</span>
> > > > <span jwcid="wtfisgoingon" />
> > > > </body>
> > > > </html>
> > > >
> > > >
> > > > plain.page is an empty page spec.
> > > >
> > > > Output:
> > > > INFO: Server startup in 3645 ms
> > > > plain: getDoStuff() 1
> > > > plain: getDoStuff() 2
> > > > plain: getDoStuff() 3
> > > > plain: getDoStuff() 4
> > > > plain: getDoStuff() 5
> > > > plain: getDoStuff() 6
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> > Tapestry / Tacos developer
> > Open Source / JEE Consulting
> >
>
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>

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


Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Jesse Kuhnert <jk...@gmail.com>.
No need for JIRA issues - I know exactly why it's doing it and intentionally
have it running this way.

Unfortunately it's the only sane way I know to make sure 4.1.2 is
releasable.  There's no actual need for OGNL expressions to be compiled in
dev mode but otherwise I'd have no way of ensuring that your happily
developed app didn't work quite the same way in production. ...Would you
rather be annoyed for another week or two until the release or get a phone
call at 2am that the app is blowing up and wtf have you done we're totally
screwed? =p

On 5/17/07, Andreas Andreou <an...@di.uoa.gr> wrote:
>
> Add a JIRA please.
> At least since 4.1.2-20070501.233137-64, i can see the first If getting
> called 3 times!
> And it's probably the first @If after an app reset that gets evaluated 3
> times and not
> the first @If of a page.
>
> An old 4.1.2-20070215.051249-15 worked correctly, i cant test other (in
> between)
> versions right now due to dependencies incompatibilities.
>
>
>
> On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> >
> > Ugh.  This is a big pain now.  I have a huge dynamic form that has
> > lots of IFs, and I can see the same queries being called 3 times or
> > more.  =(
> > Everything still works, it's just about 3 times slower.
> >
> > If anyone has solved this problem please let me know!
> >
> > On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> > > Here is another example when more than one IF component is used.
> > >
> > > It seems the conditional for the first IF gets called 3 times, then
> > > the others just get called once.
> > >
> > > plain.java:
> > >
> > > package com.phy6.app;
> > >
> > > import org.apache.tapestry.IComponent;
> > > import org.apache.tapestry.annotations.Component;
> > > import org.apache.tapestry.annotations.InitialValue;
> > > import org.apache.tapestry.html.BasePage;
> > >
> > > public abstract class plain extends BasePage {
> > >
> > >         public boolean getDoStuff() {
> > >                 this.setNumber(this.getNumber() + 1);
> > >                 System.out.println("plain: getDoStuff() " +
> > this.getNumber());
> > >                 return false;
> > >         }
> > >
> > >         @Component(type = "If", id = "ifXYZ", bindings = {
> > "condition=getDoStuff()" })
> > >         public abstract IComponent getIfXYZ();
> > >
> > >         @Component(type = "If", id = "ifABC", bindings = {
> > "condition=getDoStuff()" })
> > >         public abstract IComponent getIfABC();
> > >
> > >         @Component(type = "If", id = "ifDEF", bindings = {
> > "condition=getDoStuff()" })
> > >         public abstract IComponent getIfDEF();
> > >
> > >         @Component(type = "If", id = "ifGHI", bindings = {
> > "condition=getDoStuff()" })
> > >         public abstract IComponent getIfGHI();
> > >
> > >         @InitialValue("0")
> > >         public abstract int getNumber();
> > >
> > >         @Component(type = "Insert", id = "wtfisgoingon", bindings = {
> > > "value=getNumber()" })
> > >         public abstract IComponent getWTFisgoingon();
> > >
> > >         public abstract void setNumber(int n);
> > > }
> > >
> > >
> > >
> > > plain.html
> > >
> > > <html>
> > > <body>
> > > <span jwcid="ifXYZ">Hi XYZ</span>
> > > <span jwcid="ifABC">Hi ABC</span>
> > > <span jwcid="ifDEF">Hi DEF</span>
> > > <span jwcid="ifGHI">Hi GHI</span>
> > > <span jwcid="wtfisgoingon" />
> > > </body>
> > > </html>
> > >
> > >
> > > plain.page is an empty page spec.
> > >
> > > Output:
> > > INFO: Server startup in 3645 ms
> > > plain: getDoStuff() 1
> > > plain: getDoStuff() 2
> > > plain: getDoStuff() 3
> > > plain: getDoStuff() 4
> > > plain: getDoStuff() 5
> > > plain: getDoStuff() 6
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Andreas Andreou <an...@di.uoa.gr>.
Add a JIRA please.
At least since 4.1.2-20070501.233137-64, i can see the first If getting
called 3 times!
And it's probably the first @If after an app reset that gets evaluated 3
times and not
the first @If of a page.

An old 4.1.2-20070215.051249-15 worked correctly, i cant test other (in
between)
versions right now due to dependencies incompatibilities.



On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
>
> Ugh.  This is a big pain now.  I have a huge dynamic form that has
> lots of IFs, and I can see the same queries being called 3 times or
> more.  =(
> Everything still works, it's just about 3 times slower.
>
> If anyone has solved this problem please let me know!
>
> On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> > Here is another example when more than one IF component is used.
> >
> > It seems the conditional for the first IF gets called 3 times, then
> > the others just get called once.
> >
> > plain.java:
> >
> > package com.phy6.app;
> >
> > import org.apache.tapestry.IComponent;
> > import org.apache.tapestry.annotations.Component;
> > import org.apache.tapestry.annotations.InitialValue;
> > import org.apache.tapestry.html.BasePage;
> >
> > public abstract class plain extends BasePage {
> >
> >         public boolean getDoStuff() {
> >                 this.setNumber(this.getNumber() + 1);
> >                 System.out.println("plain: getDoStuff() " +
> this.getNumber());
> >                 return false;
> >         }
> >
> >         @Component(type = "If", id = "ifXYZ", bindings = {
> "condition=getDoStuff()" })
> >         public abstract IComponent getIfXYZ();
> >
> >         @Component(type = "If", id = "ifABC", bindings = {
> "condition=getDoStuff()" })
> >         public abstract IComponent getIfABC();
> >
> >         @Component(type = "If", id = "ifDEF", bindings = {
> "condition=getDoStuff()" })
> >         public abstract IComponent getIfDEF();
> >
> >         @Component(type = "If", id = "ifGHI", bindings = {
> "condition=getDoStuff()" })
> >         public abstract IComponent getIfGHI();
> >
> >         @InitialValue("0")
> >         public abstract int getNumber();
> >
> >         @Component(type = "Insert", id = "wtfisgoingon", bindings = {
> > "value=getNumber()" })
> >         public abstract IComponent getWTFisgoingon();
> >
> >         public abstract void setNumber(int n);
> > }
> >
> >
> >
> > plain.html
> >
> > <html>
> > <body>
> > <span jwcid="ifXYZ">Hi XYZ</span>
> > <span jwcid="ifABC">Hi ABC</span>
> > <span jwcid="ifDEF">Hi DEF</span>
> > <span jwcid="ifGHI">Hi GHI</span>
> > <span jwcid="wtfisgoingon" />
> > </body>
> > </html>
> >
> >
> > plain.page is an empty page spec.
> >
> > Output:
> > INFO: Server startup in 3645 ms
> > plain: getDoStuff() 1
> > plain: getDoStuff() 2
> > plain: getDoStuff() 3
> > plain: getDoStuff() 4
> > plain: getDoStuff() 5
> > plain: getDoStuff() 6
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Daniel Jue <te...@gmail.com>.
Ugh.  This is a big pain now.  I have a huge dynamic form that has
lots of IFs, and I can see the same queries being called 3 times or
more.  =(
Everything still works, it's just about 3 times slower.

If anyone has solved this problem please let me know!

On 5/17/07, Daniel Jue <te...@gmail.com> wrote:
> Here is another example when more than one IF component is used.
>
> It seems the conditional for the first IF gets called 3 times, then
> the others just get called once.
>
> plain.java:
>
> package com.phy6.app;
>
> import org.apache.tapestry.IComponent;
> import org.apache.tapestry.annotations.Component;
> import org.apache.tapestry.annotations.InitialValue;
> import org.apache.tapestry.html.BasePage;
>
> public abstract class plain extends BasePage {
>
>         public boolean getDoStuff() {
>                 this.setNumber(this.getNumber() + 1);
>                 System.out.println("plain: getDoStuff() " + this.getNumber());
>                 return false;
>         }
>
>         @Component(type = "If", id = "ifXYZ", bindings = { "condition=getDoStuff()" })
>         public abstract IComponent getIfXYZ();
>
>         @Component(type = "If", id = "ifABC", bindings = { "condition=getDoStuff()" })
>         public abstract IComponent getIfABC();
>
>         @Component(type = "If", id = "ifDEF", bindings = { "condition=getDoStuff()" })
>         public abstract IComponent getIfDEF();
>
>         @Component(type = "If", id = "ifGHI", bindings = { "condition=getDoStuff()" })
>         public abstract IComponent getIfGHI();
>
>         @InitialValue("0")
>         public abstract int getNumber();
>
>         @Component(type = "Insert", id = "wtfisgoingon", bindings = {
> "value=getNumber()" })
>         public abstract IComponent getWTFisgoingon();
>
>         public abstract void setNumber(int n);
> }
>
>
>
> plain.html
>
> <html>
> <body>
> <span jwcid="ifXYZ">Hi XYZ</span>
> <span jwcid="ifABC">Hi ABC</span>
> <span jwcid="ifDEF">Hi DEF</span>
> <span jwcid="ifGHI">Hi GHI</span>
> <span jwcid="wtfisgoingon" />
> </body>
> </html>
>
>
> plain.page is an empty page spec.
>
> Output:
> INFO: Server startup in 3645 ms
> plain: getDoStuff() 1
> plain: getDoStuff() 2
> plain: getDoStuff() 3
> plain: getDoStuff() 4
> plain: getDoStuff() 5
> plain: getDoStuff() 6
>

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


Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Daniel Jue <te...@gmail.com>.
Here is another example when more than one IF component is used.

It seems the conditional for the first IF gets called 3 times, then
the others just get called once.

plain.java:

package com.phy6.app;

import org.apache.tapestry.IComponent;
import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.InitialValue;
import org.apache.tapestry.html.BasePage;

public abstract class plain extends BasePage {

	public boolean getDoStuff() {
		this.setNumber(this.getNumber() + 1);
		System.out.println("plain: getDoStuff() " + this.getNumber());
		return false;
	}

	@Component(type = "If", id = "ifXYZ", bindings = { "condition=getDoStuff()" })
	public abstract IComponent getIfXYZ();

	@Component(type = "If", id = "ifABC", bindings = { "condition=getDoStuff()" })
	public abstract IComponent getIfABC();

	@Component(type = "If", id = "ifDEF", bindings = { "condition=getDoStuff()" })
	public abstract IComponent getIfDEF();

	@Component(type = "If", id = "ifGHI", bindings = { "condition=getDoStuff()" })
	public abstract IComponent getIfGHI();

	@InitialValue("0")
	public abstract int getNumber();

	@Component(type = "Insert", id = "wtfisgoingon", bindings = {
"value=getNumber()" })
	public abstract IComponent getWTFisgoingon();

	public abstract void setNumber(int n);
}



plain.html

<html>
<body>
<span jwcid="ifXYZ">Hi XYZ</span>
<span jwcid="ifABC">Hi ABC</span>
<span jwcid="ifDEF">Hi DEF</span>
<span jwcid="ifGHI">Hi GHI</span>
<span jwcid="wtfisgoingon" />
</body>
</html>


plain.page is an empty page spec.

Output:
INFO: Server startup in 3645 ms
plain: getDoStuff() 1
plain: getDoStuff() 2
plain: getDoStuff() 3
plain: getDoStuff() 4
plain: getDoStuff() 5
plain: getDoStuff() 6

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


Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Daniel Jue <te...@gmail.com>.
Glad to know I'm not alone.  I've simplified the problem code even
more, to eliminate any confusion:

plain.java:
package com.phy6.app;

import org.apache.tapestry.IComponent;
import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.InitialValue;
import org.apache.tapestry.html.BasePage;

public abstract class plain extends BasePage {

	public boolean getDoStuff() {
		this.setNumber(this.getNumber() + 1);
		System.out.println("plain: getDoStuff() " + this.getNumber());
		return false;
	}

	@Component(type = "If", id = "ifXYZ", bindings = {
		"condition=getDoStuff()" })
	public abstract IComponent getIfXYZ();

	@InitialValue("0")
	public abstract int getNumber();

	@Component(type="Insert",id="wtfisgoingon",bindings={"value=getNumber()"})
	public abstract IComponent getWTFisgoingon();
	public abstract void setNumber(int n);
}


plain.html:

<html>
<body>
<span jwcid="ifXYZ">Hi</span>
<span jwcid="wtfisgoingon" />
</body>
</html>

plain.page is still an empty page spec.

Same output:

May 17, 2007 1:57:40 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5328 ms
plain: getDoStuff() 1
plain: getDoStuff() 2
plain: getDoStuff() 3


Daniel

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


Re: [Tap 4.1.2] Problem with repeated calls to an If component

Posted by Tony Nelson <tn...@starpoint.com>.
I have noticed similar things happening in my code on the 4.1.2 snapshot 
as well.

Trying to debug the issue I'm having w/ DatePicker (different thread) I 
added a conditional to the page, and used your strategy of counting @If 
calls just to see what I get.

The first time I load the page, on the very first display, my page shows 
that the conditional was called 4 times.  Every time I submit the form, 
and it redisplays, the conditional is called only one time.  I am 
actually very hopeful that the solution to this problem, will also yield 
a solution to other problems I am seeing that are very hard to replicate 
that involve nested components throwing OGNL null pointer exceptions 
when I know for a fact that the data should exist.

For completeness, my template:

<span jwcid="@Border" title="Test" showMenu="ognl:true" 
consoleEnabled="ognl:true">
    <form jwcid="@IHForm" clientValidationEnabled="ognl:true">
        <label>Test: </label>
        <input jwcid="asOfDate@DatePicker" value="ognl:theDate"
            translator="translator:date,pattern=M/d/yyyy"
            validators="validators:required"
            displayName="As of Date"/>

        <p><span jwcid="@SubmitButton" listener="listener:submit" /></p>
    </form>

    <span jwcid="@If" condition="ognl:showTheDate">
        You picked <span jwcid="@Insert" value="ognl:theDate" 
format="ognl:format.numericDate" />
    </span>

    <br/>
   
    Current Number: <span jwcid="@Insert" value="ognl:number" />
    <span id="debug">

    </span>
</span>

And my controller

package com.starpoint.instihire.web.tapestry.page;

import org.apache.log4j.Logger;
import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.EventListener;
import org.apache.tapestry.annotations.Meta;
import org.apache.tapestry.annotations.InitialValue;
import org.apache.tapestry.event.BrowserEvent;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.form.TextField;

import java.util.Date;

@Meta("permissions=ANY")
public abstract class Test extends ProtectedPage implements 
PageBeginRenderListener
{
    public static final Logger logger = Logger.getLogger(Test.class);

    public abstract Date getTheDate();
    public abstract void setTheDate(final Date theDate);

    @InitialValue("0")
    public abstract int getNumber();
    public abstract void setNumber(int n);

    public void submit()
    {

    }

    public boolean getShowTheDate()
    {
        setNumber(getNumber() + 1);
        return getTheDate() != null;
    }
}

I hope this helpful.

As always, thanks again
Tony

Daniel Jue wrote:
> Hi,
>
> I experienced this problem after upgrading from Tap 4.1 to Tap 4.1.2 
> Snapshot.
> The problem is that I have an IF component that is being called 3
> times, when it should only be called once.
>
> I have extracted the problem into a simpler page for examination:
>
> plain.page:
>
>
> <?xml version="1.0"?>
> <!DOCTYPE page-specification PUBLIC
>  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
>  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> <page-specification class="com.phy6.app.plain">
> </page-specification>
>
>
>
> plain.java:
>
>
> package com.phy6.app;
>
> import javax.servlet.ServletContext;
>
> import org.apache.tapestry.IComponent;
> import org.apache.tapestry.annotations.Component;
> import org.apache.tapestry.annotations.InitialValue;
> import org.apache.tapestry.annotations.InjectObject;
> import org.apache.tapestry.annotations.InjectStateFlag;
> import org.apache.tapestry.html.BasePage;
>
> public abstract class plain extends BasePage {
>
>     /**
>      * @return a boolean indicating if the the user is logged in
>      */
>     @InjectStateFlag("user")
>     public abstract boolean getUserExists();
>
>     @InitialValue("0")
>     public abstract int getNumber();
>
>     public abstract void setNumber(int n);
>
>     /**
>      * @return the servlet context
>      */
>     @InjectObject("service:tapestry.globals.ServletContext")
>     public abstract ServletContext getServletContext();
>
>     @Component(type = "If", id = "ifUserIsLoggedIn", bindings = {
>         "condition=getUserIsLoggedIn()" })
>     public abstract IComponent getIfUserIsLoggedIn();
>
>     /**
>      * @return a boolean indicating whether or not a user is logged in.
>      */
>     public boolean getUserIsLoggedIn() {
>         setNumber(getNumber() + 1);
>         System.out.println("plain: getUserIsLoggedIn() " + getNumber());
>         return getUserExists();
>     }
>     @Component(type="Insert",id="wtfisgoingon",bindings={"value=getNumber()"}) 
>
>     public abstract IComponent getWTFisgoingon();
> }
>
>
>
> plain.html:
>
>
> <html>
> <body jwcid="$content$">
> <span jwcid="ifUserIsLoggedIn">Hi</span>
> <span jwcid="wtfisgoingon" />
> </body>
> </html>
>
>
> Output to console:
>
> INFO: Server startup in 3966 ms
> plain: getUserIsLoggedIn() 1
> plain: getUserIsLoggedIn() 2
> plain: getUserIsLoggedIn() 3
>
>
> Output to browser:
>
> <html>
> <body>
>
> 3
> </body>
> </html>
>
>
>
> Note that I've stripped the code down.  There is no way for the user
> to exist in this example, I'm simply reloading the page when the
> server starts.  (Tomcat 5.5.23)  This code was part of my Home.page,
> which decides whether or not to display a login component or greet the
> user.
>
> How can I get it to only check the IF component once? (or better yet,
> why is it called three times?)
>
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>