You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ford prefect <fo...@yahoo.de> on 2004/03/13 10:08:55 UTC

Nested Components [Pethshop/Tapestry for Dummys]

Hi Folks!
~~~~~~~~

My goal is to learn tapestry this weekend!

It would really help me a lot to finally get started
if you could help me to answer the following queries
that refer to the Pethshop example. 

My first attempt is add a login window within the
Border component that will automatically display a
login window if the visitor is not logged in.

What I did so far:

Step A. Modifying Border.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I added the line:

<span jwcid="loginWindow" condition="ognl:!loggedIn"/>

Query A: 
Where is loggedIn set within the Petshop example?
Within visit.java I could only find isUserLoggedIn.
I would have assumed to find it somewhere there.....


Step B. Border.jwc
~~~~~~~~~~~~~~~~~~~

Making loginWindow known....

<component-type type="LoginWindow"
specification-path="LoginWindow.jwc"/>

<component id="loginWindow" type="LoginWindow"/>	

Query B: Will it not find LoginWindow.jwc
automatically?


Step C.  LoginWindow.jwc
~~~~~~~~~~~~~~~~~~~~~~~~

public abstract class LoginWindow extends
BaseComponent implements PageRenderListener
{
	public void pageBeginRender(PageEvent event)
	{
		Visit visit = (Visit) getPage().getEngine()
getVisit();
		if (visit == null)
		{
			setLoggedIn(false);
			setShowBanner(false);
		}
		else
		{
			setLoggedIn(visit.isUserLoggedIn());
			setShowBanner(true);
		}
	}

	
	public abstract void setLoggedIn(boolean b);

}

Query C: Who will implement the method setLoggedIn ?

Step D: LoginWindow.html
~~~~~~~~~~~~~~~~~~~~~~~~

<html stuff/>


Now I do "ant run" and see what happends:

----------------------------------------------------
Method 'public abstract void
org.apache.tapestry.pets.presentation.components.LoginWindow.setLoggedIn(boolean)'
(declared in class
org.apache.tapestry.pets.presentation.components.LoginWindow)
has no implementation in class
org.apache.tapestry.pets.presentation.components.LoginWindow
(or enhanced subclass
org.apache.tapestry.pets.presentation.components.LoginWindow$Enhance_4).

----------------------------------------------------

setLoggedIn is also not implemented in te Border.java.

Strange ...


Thanks in advance for your help/comments....











	
		
Mit schönen Grüßen von Yahoo! Mail - http://mail.yahoo.de

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


RE: Nested Components [Pethshop/Tapestry for Dummys]

Posted by Petter Måhlén <pe...@elevance.se>.
> Query A: 
> Where is loggedIn set within the Petshop example?
> Within visit.java I could only find isUserLoggedIn.
> I would have assumed to find it somewhere there.....

loggedIn is a page/component level property, meaning that it needs to be
defined in the page/component specification with a <property-specification>
tag. To access something in the Visit object, you need something like
"visit.myProperty", and for a component (as opposed to a page), you may in
fact need something like "page.visit.myProperty". This is translated to a
Java call similar to getPage().getVisit().getMyProperty().

> Query C: Who will implement the method setLoggedIn ?

That is implemented behind the scenes by Tapesty in an enhanced class, if
you have provided a corresponding <property-specification> tag, and if there
is no (non-abstract) method implementation in your Java class.

> 
> setLoggedIn is also not implemented in te Border.java.

Probably because there is no property-specification in Border.jwc?

/ Petter


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