You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sa...@women-at-work.org on 2004/04/05 16:59:14 UTC

Newbee - putting it all together...

Hi folks!

I am new to Tapestry and I have one important question that would help me to
put all the bits and pieces together to get a clearer Tapestry picture.

I am trying to do a discussion board using tapestry.

I extend from BasePage a "DiscussionBoardBasePage."

Within this BasePage I implemented a getter method called getIPAddress()
that will return the current IP address from a user (in order to prevent
flooding with messages).


// "Your ip address is 112.61.121.12" for instance 

// BasePage

public String getIPAddress(){
return
this.getRequestCycle().getRequestContext().getRequest().getRemoteAddr();
}


// Welcome.html

Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.

// Welcome.page

<page-specification
class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
<property-specification name="iPAddress" type="java.lang.String"/>


I have the feeling I missed something important.

Anyway, I am a bit confused still and need some pointing into the right
direction.

I would like to be able to access  the ip address on every page....

Any help is welcome!







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


Re: Newbee - putting it all together...

Posted by sa...@women-at-work.org.
Yes!

Thanks for all your help and quick replies! 


> is WelcomePage extending DiscussionBoardBasePage?
> 
> 
> 
> sarah.simbad@women-at-work.org wrote:
> > Hi folks!
> > 
> > I am new to Tapestry and I have one important question that would help
> me to
> > put all the bits and pieces together to get a clearer Tapestry picture.
> > 
> > I am trying to do a discussion board using tapestry.
> > 
> > I extend from BasePage a "DiscussionBoardBasePage."
> > 
> > Within this BasePage I implemented a getter method called getIPAddress()
> > that will return the current IP address from a user (in order to prevent
> > flooding with messages).
> > 
> > 
> > // "Your ip address is 112.61.121.12" for instance 
> > 
> > // BasePage
> > 
> > public String getIPAddress(){
> > return
> > this.getRequestCycle().getRequestContext().getRequest().getRemoteAddr();
> > }
> > 
> > 
> > // Welcome.html
> > 
> > Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.
> > 
> > // Welcome.page
> > 
> > <page-specification
> > class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
> > <property-specification name="iPAddress" type="java.lang.String"/>
> > 
> > 
> > I have the feeling I missed something important.
> > 
> > Anyway, I am a bit confused still and need some pointing into the right
> > direction.
> > 
> > I would like to be able to access  the ip address on every page....
> > 
> > Any help is welcome!
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > 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
> 


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


Re: Newbee - putting it all together...

Posted by Jeff Emminger <je...@jeffemminger.com>.
is WelcomePage extending DiscussionBoardBasePage?



sarah.simbad@women-at-work.org wrote:
> Hi folks!
> 
> I am new to Tapestry and I have one important question that would help me to
> put all the bits and pieces together to get a clearer Tapestry picture.
> 
> I am trying to do a discussion board using tapestry.
> 
> I extend from BasePage a "DiscussionBoardBasePage."
> 
> Within this BasePage I implemented a getter method called getIPAddress()
> that will return the current IP address from a user (in order to prevent
> flooding with messages).
> 
> 
> // "Your ip address is 112.61.121.12" for instance 
> 
> // BasePage
> 
> public String getIPAddress(){
> return
> this.getRequestCycle().getRequestContext().getRequest().getRemoteAddr();
> }
> 
> 
> // Welcome.html
> 
> Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.
> 
> // Welcome.page
> 
> <page-specification
> class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
> <property-specification name="iPAddress" type="java.lang.String"/>
> 
> 
> I have the feeling I missed something important.
> 
> Anyway, I am a bit confused still and need some pointing into the right
> direction.
> 
> I would like to be able to access  the ip address on every page....
> 
> Any help is welcome!
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Newbee - putting it all together...

Posted by sa...@women-at-work.org.
Thanks everyone for the help!

It is working this way...really easy - just a getter method and you can
start using it, which is cool.

But what about components?

Assuming I wanted to display/access an ipaddress (just as an example, it
could be anything really)
within components.....

Would I extend BaseComponent and add a method that will call getPage() and
then the previous method getiPAddress() ?

What is the easiest/laziest(!) way of having access to the ipaddress in all
components without the need
of specifying it in every single component specification?


Sarah

> hey sarah,
> 
> you are on the right way.
> all your pages can now extend from your DiscussionBoardBasePage and you 
> are able to access the getter.
> however, you don't  have to specifiy ipaddress in your *.page file.
> 
> if you specify ipaddress in your page file, a getter/setter and the 
> property ipaddress will be automatically created by tapestry.
> this is what you don't want in your case.
> just remove
> 
> <property-specification name="iPAddress" type="java.lang.String"/>
> 
> and let the getter where it is, extend you pages from 
> DiscussionBoardBasePage and you will be fine.
> 
> hope that helps
> andreas
> 
> 
> if you want to access your ip getter from every page, you could create a
> 
> sarah.simbad@women-at-work.org wrote:
> 
> >Hi folks!
> >
> >I am new to Tapestry and I have one important question that would help me
> to
> >put all the bits and pieces together to get a clearer Tapestry picture.
> >
> >I am trying to do a discussion board using tapestry.
> >
> >I extend from BasePage a "DiscussionBoardBasePage."
> >
> >Within this BasePage I implemented a getter method called getIPAddress()
> >that will return the current IP address from a user (in order to prevent
> >flooding with messages).
> >
> >
> >// "Your ip address is 112.61.121.12" for instance 
> >
> >// BasePage
> >
> >public String getIPAddress(){
> >return
> >this.getRequestCycle().getRequestContext().getRequest().getRemoteAddr();
> >}
> >
> >
> >// Welcome.html
> >
> >Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.
> >
> >// Welcome.page
> >
> ><page-specification
> >class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
> ><property-specification name="iPAddress" type="java.lang.String"/>
> >
> >
> >I have the feeling I missed something important.
> >
> >Anyway, I am a bit confused still and need some pointing into the right
> >direction.
> >
> >I would like to be able to access  the ip address on every page....
> >
> >Any help is welcome!
> >
> >
> >
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >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
> 


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


Re: Newbee - putting it all together...

Posted by Andreas Bohnert <ab...@online.de>.
hey sarah,

you are on the right way.
all your pages can now extend from your DiscussionBoardBasePage and you 
are able to access the getter.
however, you don't  have to specifiy ipaddress in your *.page file.

if you specify ipaddress in your page file, a getter/setter and the 
property ipaddress will be automatically created by tapestry.
this is what you don't want in your case.
just remove

<property-specification name="iPAddress" type="java.lang.String"/>

and let the getter where it is, extend you pages from 
DiscussionBoardBasePage and you will be fine.

hope that helps
andreas


if you want to access your ip getter from every page, you could create a

sarah.simbad@women-at-work.org wrote:

>Hi folks!
>
>I am new to Tapestry and I have one important question that would help me to
>put all the bits and pieces together to get a clearer Tapestry picture.
>
>I am trying to do a discussion board using tapestry.
>
>I extend from BasePage a "DiscussionBoardBasePage."
>
>Within this BasePage I implemented a getter method called getIPAddress()
>that will return the current IP address from a user (in order to prevent
>flooding with messages).
>
>
>// "Your ip address is 112.61.121.12" for instance 
>
>// BasePage
>
>public String getIPAddress(){
>return
>this.getRequestCycle().getRequestContext().getRequest().getRemoteAddr();
>}
>
>
>// Welcome.html
>
>Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.
>
>// Welcome.page
>
><page-specification
>class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
><property-specification name="iPAddress" type="java.lang.String"/>
>
>
>I have the feeling I missed something important.
>
>Anyway, I am a bit confused still and need some pointing into the right
>direction.
>
>I would like to be able to access  the ip address on every page....
>
>Any help is welcome!
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>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: Newbee - putting it all together...

Posted by Eric Schneider <er...@centralparksoftware.com>.
Sarah,

> <property-specification name="iPAddress" type="java.lang.String"/>

You do not need this property specification line.  iPAddress isn't an
instance variable on the page, it's really just a helper method that returns
the client's ip address.

> Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.

I think there might be a case sensitivity problem here.  Try
value="ognl:iPAddress".

Hope this helps,
eric


----- Original Message -----
From: <sa...@women-at-work.org>
To: <ta...@jakarta.apache.org>
Sent: Monday, April 05, 2004 10:59 AM
Subject: Newbee - putting it all together...


> Hi folks!
>
> I am new to Tapestry and I have one important question that would help me
to
> put all the bits and pieces together to get a clearer Tapestry picture.
>
> I am trying to do a discussion board using tapestry.
>
> I extend from BasePage a "DiscussionBoardBasePage."
>
> Within this BasePage I implemented a getter method called getIPAddress()
> that will return the current IP address from a user (in order to prevent
> flooding with messages).
>
>
> // "Your ip address is 112.61.121.12" for instance
>
> // BasePage
>
> public String getIPAddress(){
> return
> this.getRequestCycle().getRequestContext().getRequest().getRemoteAddr();
> }
>
>
> // Welcome.html
>
> Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.
>
> // Welcome.page
>
> <page-specification
> class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
> <property-specification name="iPAddress" type="java.lang.String"/>
>
>
> I have the feeling I missed something important.
>
> Anyway, I am a bit confused still and need some pointing into the right
> direction.
>
> I would like to be able to access  the ip address on every page....
>
> Any help is welcome!
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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: Newbee - putting it all together...

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
<property-specification> is to create a NEW property. There's no need for it, because you are
creating a synthetic (that is, a calculated, read-only) property in your base class.

Just ensure that WelcomePage extends from your BasePage class (that class that provides the
IPAddress property).

You said it didn't work, but you didn't say how.  Please see:
http://jakarta.apache.org/tapestry/problems.html

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://howardlewisship.com


> -----Original Message-----
> From: sarah.simbad@women-at-work.org 
> [mailto:sarah.simbad@women-at-work.org] 
> Sent: Monday, April 05, 2004 10:59 AM
> To: tapestry-user@jakarta.apache.org
> Subject: Newbee - putting it all together...
> 
> 
> Hi folks!
> 
> I am new to Tapestry and I have one important question that 
> would help me to
> put all the bits and pieces together to get a clearer 
> Tapestry picture.
> 
> I am trying to do a discussion board using tapestry.
> 
> I extend from BasePage a "DiscussionBoardBasePage."
> 
> Within this BasePage I implemented a getter method called 
> getIPAddress()
> that will return the current IP address from a user (in order 
> to prevent
> flooding with messages).
> 
> 
> // "Your ip address is 112.61.121.12" for instance 
> 
> // BasePage
> 
> public String getIPAddress(){
> return
> this.getRequestCycle().getRequestContext().getRequest().getRem
> oteAddr();
> }
> 
> 
> // Welcome.html
> 
> Your ip address is <span jwcid="@Insert" value="ognl:IPAddress"/>.
> 
> // Welcome.page
> 
> <page-specification
> class="org.apache.tapestry.pets.presentation.pages.WelcomePage">
> <property-specification name="iPAddress" type="java.lang.String"/>
> 
> 
> I have the feeling I missed something important.
> 
> Anyway, I am a bit confused still and need some pointing into 
> the right
> direction.
> 
> I would like to be able to access  the ip address on every page....
> 
> Any help is welcome!
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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