You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tomáš Drenčák <to...@gmail.com> on 2005/09/16 18:13:41 UTC

jwc files and annotations

Hello,
could someone tell me, if it is possible to have just page class and
html template for one page or I have to create jwc file which is
almost empty because I use annotations?

Thanks 
     tomas

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


Re: jwc files and annotations

Posted by Tomáš Drenčák <to...@gmail.com>.
Well, I have written page without .page file and seems strange to me,
that there must be a page (.html) in root directory, localization file
in WEB-INF (.properties) and finally class in classes directory. I
think that this should be set up some way... Any ideas?

2005/9/16, Tomáš Drenčák <to...@gmail.com>:
> Thanks a lot.
> 
> Another question... You are using pageValidate to set up thisPerson
> property. I'm still little bit confused about page initialization.
> What are pageBeginRender, pageValidate and prepareForRender for? Where
> to initialize e.g. thisPerson from passed personId parameter? I've
> used pageBeginRender, lazy initialization, but which method is
> specially designed for this purpose?
> 
> tomas
> 
> 2005/9/16, Alan Chandler <al...@chandlerfamily.org.uk>:
> > On Friday 16 September 2005 17:40, Sylvain COUTANT wrote:
> > > Hi,
> > >
> > > I'm fairly new to Tapestry, but I thought jwc files were to define
> > > components, not pages.
> > >
> > > For pages, I have no .page file. Tap 4 supports a package list
> > > (org.apache.tapestry.page-class-packages) to search for a java class having
> > > the same name as the page.
> > >
> > > For components, I didn't find how I could avoid the jwc file. It's required
> > > by the <component-type> element in application description ...
> >
> > I'm fairly new to tapestry also, but I am creating my entire application (so
> > far) without needing any page or component specifications.  The entire thing
> > is done with html templates and java classes.
> >
> >
> > Basically, my application is called famtree, and therefore in
> >
> > WEB-INF/famtree.application file I have the following
> >
> > <application name="famtree"
> > engine-class="org.apache.tapestry.engine.BaseEngine">
> >     <description>Family tree</description>
> >         <meta key="org.apache.tapestry.page-class-packages" >
> >                 uk.org.chandlerfamily.tapestry.famtree
> >         </meta>
> >         <meta key="org.apache.tapestry.component-class-packages">
> >                 uk.org.chandlerfamily.tapestry.components
> >         </meta>
> > ...
> >
> > Which defines where it looks for both my pages and my components.
> >
> > Each component class then looks a bit like the following example
> >
> > package uk.org.chandlerfamily.tapestry.components;
> > import org.apache.tapestry.annotations.*;
> > import org.apache.tapestry.BaseComponent;
> >
> > import java.util.List;
> >
> > import uk.org.chandlerfamily.sqlmap.famtree.PersonSummary;
> >
> > @ComponentClass
> > public abstract class Children extends BaseComponent {
> >
> >         @Parameter
> >         public abstract List<PersonSummary> getChildList();
> >
> >         public abstract void setThisChild(PersonSummary thisChild);
> >         public abstract PersonSummary getThisChild();
> >
> > }
> >
> > Where this defines a component called "Children" which will take a parameter
> > called "childList" and which has a @Foreach loop in the html template which
> > interate over the list and use "ognl:thisChild.someproperty to get a property
> > of the child.
> >
> > Page files look a bit like
> >
> > public abstract class Details extends BasePage implements PageValidateListener
> > {
> >
> >
> >         public abstract int getPersonId();
> >         public abstract void setPersonId(int personId);
> >
> >         public abstract Person getThisPerson();
> >         public abstract void setThisPerson(Person thisPerson);
> >
> >         public void pageValidate (PageEvent event) {
> > ...  code to set up "thisPerson" data from a database with a paramter
> > "personId" passed in via a listener in another page which returns with this
> > page in its return statement.
> >
> >         }
> > }
> >
> >
> > --
> > Alan Chandler
> > http://www.chandlerfamily.org.uk
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>

Re: jwc files and annotations

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Friday 16 September 2005 18:29, Tomáš Drenčák wrote:
> Thanks a lot.
>
> Another question... You are using pageValidate to set up thisPerson
> property. I'm still little bit confused about page initialization.
> What are pageBeginRender, pageValidate and prepareForRender for? Where
> to initialize e.g. thisPerson from passed personId parameter? I've
> used pageBeginRender, lazy initialization, but which method is
> specially designed for this purpose?


I must admit, this was a bit trial and error.  

I pass the personId parameter via the following code in another component.


	@InjectPage("Details") 
	public abstract Details getDetailsPage(); 
	 
	public IPage doShowDetails(int personId) { 
	    Details details = getDetailsPage(); 
	    details.setPersonId(personId); 
	    return details; 
	} 
}

Where this code gets set up in the html template for this component as

<div class="surname">
	<span jwcid="@DirectLink"
		listener="listener:doShowDetails"
		parameters="ognl:person.id"
		><span jwcid="@Insert"
			value="ognl:person.surname"
			>Chandler</span></span>
</div>


I think PageBeginRender failed  (thinking back to when I orginally had it 
here) because there seems to be a validation phase of the page before then, 
and I had not set up the record, and had null pointer exceptions.

I think the page initialisation failed because the setPersonId call hadn't 
happened (maybe - difficult to remember now) the initialisation got called 
when I did the first call to getDetailsPage in the listener above.

-- 
Alan Chandler
http://www.chandlerfamily.org.uk

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


Re: jwc files and annotations

Posted by Tomáš Drenčák <to...@gmail.com>.
Thanks a lot.

Another question... You are using pageValidate to set up thisPerson
property. I'm still little bit confused about page initialization.
What are pageBeginRender, pageValidate and prepareForRender for? Where
to initialize e.g. thisPerson from passed personId parameter? I've
used pageBeginRender, lazy initialization, but which method is
specially designed for this purpose?

tomas

2005/9/16, Alan Chandler <al...@chandlerfamily.org.uk>:
> On Friday 16 September 2005 17:40, Sylvain COUTANT wrote:
> > Hi,
> >
> > I'm fairly new to Tapestry, but I thought jwc files were to define
> > components, not pages.
> >
> > For pages, I have no .page file. Tap 4 supports a package list
> > (org.apache.tapestry.page-class-packages) to search for a java class having
> > the same name as the page.
> >
> > For components, I didn't find how I could avoid the jwc file. It's required
> > by the <component-type> element in application description ...
> 
> I'm fairly new to tapestry also, but I am creating my entire application (so
> far) without needing any page or component specifications.  The entire thing
> is done with html templates and java classes.
> 
> 
> Basically, my application is called famtree, and therefore in
> 
> WEB-INF/famtree.application file I have the following
> 
> <application name="famtree"
> engine-class="org.apache.tapestry.engine.BaseEngine">
>     <description>Family tree</description>
>         <meta key="org.apache.tapestry.page-class-packages" >
>                 uk.org.chandlerfamily.tapestry.famtree
>         </meta>
>         <meta key="org.apache.tapestry.component-class-packages">
>                 uk.org.chandlerfamily.tapestry.components
>         </meta>
> ...
> 
> Which defines where it looks for both my pages and my components.
> 
> Each component class then looks a bit like the following example
> 
> package uk.org.chandlerfamily.tapestry.components;
> import org.apache.tapestry.annotations.*;
> import org.apache.tapestry.BaseComponent;
> 
> import java.util.List;
> 
> import uk.org.chandlerfamily.sqlmap.famtree.PersonSummary;
> 
> @ComponentClass
> public abstract class Children extends BaseComponent {
> 
>         @Parameter
>         public abstract List<PersonSummary> getChildList();
> 
>         public abstract void setThisChild(PersonSummary thisChild);
>         public abstract PersonSummary getThisChild();
> 
> }
> 
> Where this defines a component called "Children" which will take a parameter
> called "childList" and which has a @Foreach loop in the html template which
> interate over the list and use "ognl:thisChild.someproperty to get a property
> of the child.
> 
> Page files look a bit like
> 
> public abstract class Details extends BasePage implements PageValidateListener
> {
> 
> 
>         public abstract int getPersonId();
>         public abstract void setPersonId(int personId);
> 
>         public abstract Person getThisPerson();
>         public abstract void setThisPerson(Person thisPerson);
> 
>         public void pageValidate (PageEvent event) {
> ...  code to set up "thisPerson" data from a database with a paramter
> "personId" passed in via a listener in another page which returns with this
> page in its return statement.
> 
>         }
> }
> 
> 
> --
> Alan Chandler
> http://www.chandlerfamily.org.uk
> 
> ---------------------------------------------------------------------
> 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


Re: jwc files and annotations

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Friday 16 September 2005 17:40, Sylvain COUTANT wrote:
> Hi,
>
> I'm fairly new to Tapestry, but I thought jwc files were to define
> components, not pages.
>
> For pages, I have no .page file. Tap 4 supports a package list
> (org.apache.tapestry.page-class-packages) to search for a java class having
> the same name as the page.
>
> For components, I didn't find how I could avoid the jwc file. It's required
> by the <component-type> element in application description ...

I'm fairly new to tapestry also, but I am creating my entire application (so 
far) without needing any page or component specifications.  The entire thing 
is done with html templates and java classes.


Basically, my application is called famtree, and therefore in

WEB-INF/famtree.application file I have the following

<application name="famtree" 
engine-class="org.apache.tapestry.engine.BaseEngine">
    <description>Family tree</description>
 	<meta key="org.apache.tapestry.page-class-packages" >
		uk.org.chandlerfamily.tapestry.famtree
	</meta>
 	<meta key="org.apache.tapestry.component-class-packages">
 		uk.org.chandlerfamily.tapestry.components
 	</meta>
...

Which defines where it looks for both my pages and my components.

Each component class then looks a bit like the following example

package uk.org.chandlerfamily.tapestry.components; 
import org.apache.tapestry.annotations.*; 
import org.apache.tapestry.BaseComponent; 
 
import java.util.List; 
 
import uk.org.chandlerfamily.sqlmap.famtree.PersonSummary; 
 
@ComponentClass 
public abstract class Children extends BaseComponent { 
 
	@Parameter 
	public abstract List<PersonSummary> getChildList(); 
	 
	public abstract void setThisChild(PersonSummary thisChild); 
	public abstract PersonSummary getThisChild(); 
 
}

Where this defines a component called "Children" which will take a parameter 
called "childList" and which has a @Foreach loop in the html template which 
interate over the list and use "ognl:thisChild.someproperty to get a property 
of the child.

Page files look a bit like

public abstract class Details extends BasePage implements PageValidateListener 
{

	
	public abstract int getPersonId();
	public abstract void setPersonId(int personId);
	
	public abstract Person getThisPerson();
	public abstract void setThisPerson(Person thisPerson);
	
	public void pageValidate (PageEvent event) {
...  code to set up "thisPerson" data from a database with a paramter 
"personId" passed in via a listener in another page which returns with this 
page in its return statement.

	}
}


-- 
Alan Chandler
http://www.chandlerfamily.org.uk

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


RE: jwc files and annotations

Posted by Sylvain COUTANT <sc...@adviseo.fr>.
Hi,

I'm fairly new to Tapestry, but I thought jwc files were to define components, not pages.

For pages, I have no .page file. Tap 4 supports a package list (org.apache.tapestry.page-class-packages) to search for a java class having the same name as the page.

For components, I didn't find how I could avoid the jwc file. It's required by the <component-type> element in application description ...


--
Sylvain COUTANT

ADVISEO
http://www.adviseo.fr/
http://www.open-sp.fr/

> -----Message d'origine-----
> De : Tomáš Drencák [mailto:tomas.drencak@gmail.com]
> Envoyé : vendredi 16 septembre 2005 18:14
> À : Tapestry users
> Objet : jwc files and annotations
> 
> Hello,
> could someone tell me, if it is possible to have just page class and
> html template for one page or I have to create jwc file which is
> almost empty because I use annotations?
> 
> Thanks
>      tomas
> 
> ---------------------------------------------------------------------
> 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