You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dany <du...@hotmail.com> on 2011/03/02 03:30:42 UTC

Tapestry 5.2 - Request data shared in different client browser

Hi,

I am developing in tapestry 5.2. I have including pages and component but i
noticed one problem:

        @Property
        Private LoginVo loginVo;

	@Log
	@PageLoaded
	void pageLoaded()
	{
		loginVo =new LoginVo();
	}

<input type="text" t:id="userName" t:type="TextField" t:label="User Name"
t:value="loginVo.username" t:validate="required"/>

<input type="text" t:id="userName" t:type="TextField" t:label="User Name"
t:value="loginVo.password" t:validate="required"/>

if we include this value object in the page and initializes in the
PageLoaded  the page will be render, providing a response to the browser.

we fille up this values with any value for example xxx and yyy and press
submit.Then if we open a  new browser instance and we call to this page it
is appear the form with the fields values xxx and yyy even. I test this
behabiour in diferent PC browser with the same result.

In tapestry 5.2 we have a sigleton page and not pooled pages but the session
can not be share with the rest of user i try to use ResetPaged but it
doesn´t work finally and setup tapestry for the used of pooled pages.  

I check it the same example in tapestry 5.1.5 and this it work fine. If you
call with diferent browser intances the fields are null even if you
initializes the values in a instance browser.

Is this a bug in tapestry 5.2 or has to be used in a diferent way??
In which method i have to initializes the POJO´s attribubes?

Any help will be welcome. Thanks in advance.


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Request-data-shared-in-different-client-browser-tp3405994p3405994.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5.2 - Request data shared in different client browser

Posted by Dany <du...@hotmail.com>.
Hi Howard,

Thanks for you soon reply. I have a doubt with repesct to you reply. If in
tapestry 5.2 it works with only one instance (like in a servlet) then it is
imposible to make the maching in a POJO/tml because this elements always is
going to be a mutable objects (in the same way that a servlet with global
variables).

Then for this example (in tapestry 5.2) how do you make the machting the tml
fields with java class without all users see the data bleed. Would you mind
to provide an exanple for the correct use?

Thanks in advance

Kind Regards

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Request-data-shared-in-different-client-browser-tp3405994p3406223.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5.2 - Request data shared in different client browser

Posted by Howard Lewis Ship <hl...@gmail.com>.
Yes, this is a subtle offshoot of the 5.2 changes.  What you've done
is identify that single instance of LoginVO as the default value for
the loginVo field.

In 5.1, your bug was that different clients who accessed the same page
instance sequentially would see data bleed from one request to the
next.

In 5.2, your bug is that all users see the data bleed, because there's
only one instance of your page, and so, only one instance of LoginVO.

Don't use objects with mutable state as the default values for fields.
It causes data to bleed between requests and clients.


On Tue, Mar 1, 2011 at 6:30 PM, Dany <du...@hotmail.com> wrote:
> Hi,
>
> I am developing in tapestry 5.2. I have including pages and component but i
> noticed one problem:
>
>        @Property
>        Private LoginVo loginVo;
>
>        @Log
>        @PageLoaded
>        void pageLoaded()
>        {
>                loginVo =new LoginVo();
>        }
>
> <input type="text" t:id="userName" t:type="TextField" t:label="User Name"
> t:value="loginVo.username" t:validate="required"/>
>
> <input type="text" t:id="userName" t:type="TextField" t:label="User Name"
> t:value="loginVo.password" t:validate="required"/>
>
> if we include this value object in the page and initializes in the
> PageLoaded  the page will be render, providing a response to the browser.
>
> we fille up this values with any value for example xxx and yyy and press
> submit.Then if we open a  new browser instance and we call to this page it
> is appear the form with the fields values xxx and yyy even. I test this
> behabiour in diferent PC browser with the same result.
>
> In tapestry 5.2 we have a sigleton page and not pooled pages but the session
> can not be share with the rest of user i try to use ResetPaged but it
> doesn´t work finally and setup tapestry for the used of pooled pages.
>
> I check it the same example in tapestry 5.1.5 and this it work fine. If you
> call with diferent browser intances the fields are null even if you
> initializes the values in a instance browser.
>
> Is this a bug in tapestry 5.2 or has to be used in a diferent way??
> In which method i have to initializes the POJO´s attribubes?
>
> Any help will be welcome. Thanks in advance.
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Request-data-shared-in-different-client-browser-tp3405994p3405994.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Tapestry 5.2 - Request data shared in different client browser

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 04 Mar 2011 06:11:59 -0300, Dany <du...@hotmail.com> wrote:

> Hi,

Hi!

> This works an data don´t blood in requester but at the you have to  
> controll in your code. We follow this pattern because our application is  
> complex and we have to make component, following 3 layers (with EJB  
> (business logic) + hibernate ) and not two like is orientated tapestry.

There's some misunderstanding here. Tapestry doesn't care at all about how  
you architect your application. You could write an 1 or an 10 layers with  
Tapestry as a front end.

> In this structure at the end we have problems in the comunication between
> components and Pages events + validations as well as data blood as we
> disccuss in this thread.

Your code now avoids the data bleed.

> I am not an expert in tapestry but I think that
> data blood problems will have been controlled by the framework like it  
> was controlled  in the version 5.01 or to clarify that the tapestry 5.2   
> has
> changed become from a POJO to a tipically in a Servlet.

You could have what you call a data bleed in any Tapestry version if you  
initialized a field in its declaration, unless the value is immutable.
A Tapestry class is a POJO, is *not* a servlet nor looks like one. What  
Howard said is that 5.2 doesn't use a page pool anymore.
The Tapestry recommendation is that you initialize any fields needed in  
render lifecycle events (@SetupRender, @BeginRender), the activate event  
or even some component event (like the prepare event of Form).

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Tapestry 5.2 - Request data shared in different client browser

Posted by Dany <du...@hotmail.com>.
Hi,

Ok i provide you an example. Our objective is to build small component like
personal data, address etc... This small components are included in a Page.
Page will controller the validation for all components and general events.

For example:Page Tml



>    
>      
>      
> ....
> 


Page POJO
public class NewPage 
{
	
	@Component(id="newForm")
	private Form newContractParticularPage;
	
	@Property
	@Persist
	private PersonalDataVo _personalDataVo;
...
}


The first problem that you can faced it that the variable _personalDataVo
has to be initializes the first time. Ok, you can do it is initializes the
Value Objects in the pageLoaded Method, but it is not enoug because if you
have a singleton page  the data blood for all request once one user fill up
this value Object. How to avoid, let see the components part. If you realize
we have machting tesfield with t:value="personalDataVo.nombre". if you see
the code for Java component at the end we make responsible for
initialization of Value Object to the component throught to the
setupInializes.


personalDataCmp TML


> 
> 
> 
> 


personalDataCmp POJO

public class PersonalDataCmp
{
	
	@Property
	@Parameter(required= true)
	private PersonalDataVo personalDataVo;
	
    @SetupRender
    void initializeValue()
    {

   		if (personalDataVo==null)
   			personalDataVo=new PersonalDataVo();
    }


...
}


This works an data don´t blood in requester but at the you have to controll
in your code. We follow this pattern because our application is complex and
we have to make component, following 3 layers (with EJB (business logic) +
hibernate ) and not two like is orientated tapestry. For this reason we need
indenpendance ValueObject (POJO) as databag to call EJB part and to reduce
the complex in tapestry POJO. 


In this structure at the end we have problems in the comunication between
components and Pages events + validations as well as data blood as we
disccuss in this thread. I am not an expert in tapestry but I think that
data blood problems will have been controlled by the framework like it was
controlled  in the version 5.01 or to clarify that the tapestry 5.2  has
changed become from a POJO to a tipically in a Servlet.


In other hand thanks for your help and quick reply.

Get in touch...

Kind Regards
 










Howard Lewis Ship wrote:
> 
> To reiterate: your code was broken in 5.1, just not as obviously as in
> 5.2.
> On Wed, Mar 2, 2011 at 3:06 AM, Thiago H. de Paula Figueiredo
>  wrote:
>> On Tue, 01 Mar 2011 23:30:42 -0300, Dany  wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>>        @Property
>>>        Private LoginVo loginVo;
>>>
>>>        @Log
>>>        @PageLoaded
>>>        void pageLoaded()
>>>        {
>>>                loginVo =new LoginVo();
>>>        }
>>
>> @PageLoaded is triggered just once, when the page is instantiated. As
>> Howard
>> said, since 5.2, Tapestry has just one instance of each page and its
>> state
>> is stored in a per-request Map instead of the fields themselves. Just use
>> onActivate() or @SetupRender instead and your problem will go away.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and
>> instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

Howard Lewis Ship wrote:
> 
> To reiterate: your code was broken in 5.1, just not as obviously as in
> 5.2.
> 
> On Wed, Mar 2, 2011 at 3:06 AM, Thiago H. de Paula Figueiredo
>  wrote:
>> On Tue, 01 Mar 2011 23:30:42 -0300, Dany  wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>>        @Property
>>>        Private LoginVo loginVo;
>>>
>>>        @Log
>>>        @PageLoaded
>>>        void pageLoaded()
>>>        {
>>>                loginVo =new LoginVo();
>>>        }
>>
>> @PageLoaded is triggered just once, when the page is instantiated. As
>> Howard
>> said, since 5.2, Tapestry has just one instance of each page and its
>> state
>> is stored in a per-request Map instead of the fields themselves. Just use
>> onActivate() or @SetupRender instead and your problem will go away.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and
>> instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

Howard Lewis Ship wrote:
> 
> To reiterate: your code was broken in 5.1, just not as obviously as in
> 5.2.
> 
> On Wed, Mar 2, 2011 at 3:06 AM, Thiago H. de Paula Figueiredo
>  wrote:
>> On Tue, 01 Mar 2011 23:30:42 -0300, Dany  wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>>        @Property
>>>        Private LoginVo loginVo;
>>>
>>>        @Log
>>>        @PageLoaded
>>>        void pageLoaded()
>>>        {
>>>                loginVo =new LoginVo();
>>>        }
>>
>> @PageLoaded is triggered just once, when the page is instantiated. As
>> Howard
>> said, since 5.2, Tapestry has just one instance of each page and its
>> state
>> is stored in a per-request Map instead of the fields themselves. Just use
>> onActivate() or @SetupRender instead and your problem will go away.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and
>> instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

Howard Lewis Ship wrote:
> 
> To reiterate: your code was broken in 5.1, just not as obviously as in
> 5.2.
> 
> On Wed, Mar 2, 2011 at 3:06 AM, Thiago H. de Paula Figueiredo
>  wrote:
>> On Tue, 01 Mar 2011 23:30:42 -0300, Dany  wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>>        @Property
>>>        Private LoginVo loginVo;
>>>
>>>        @Log
>>>        @PageLoaded
>>>        void pageLoaded()
>>>        {
>>>                loginVo =new LoginVo();
>>>        }
>>
>> @PageLoaded is triggered just once, when the page is instantiated. As
>> Howard
>> said, since 5.2, Tapestry has just one instance of each page and its
>> state
>> is stored in a per-request Map instead of the fields themselves. Just use
>> onActivate() or @SetupRender instead and your problem will go away.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and
>> instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-2-Request-data-shared-in-different-client-browser-tp3405994p3409129.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5.2 - Request data shared in different client browser

Posted by Howard Lewis Ship <hl...@gmail.com>.
To reiterate: your code was broken in 5.1, just not as obviously as in 5.2.

On Wed, Mar 2, 2011 at 3:06 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Tue, 01 Mar 2011 23:30:42 -0300, Dany <du...@hotmail.com> wrote:
>
>> Hi,
>
> Hi!
>
>>        @Property
>>        Private LoginVo loginVo;
>>
>>        @Log
>>        @PageLoaded
>>        void pageLoaded()
>>        {
>>                loginVo =new LoginVo();
>>        }
>
> @PageLoaded is triggered just once, when the page is instantiated. As Howard
> said, since 5.2, Tapestry has just one instance of each page and its state
> is stored in a per-request Map instead of the fields themselves. Just use
> onActivate() or @SetupRender instead and your problem will go away.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Tapestry 5.2 - Request data shared in different client browser

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 01 Mar 2011 23:30:42 -0300, Dany <du...@hotmail.com> wrote:

> Hi,

Hi!

>         @Property
>         Private LoginVo loginVo;
>
> 	@Log
> 	@PageLoaded
> 	void pageLoaded()
> 	{
> 		loginVo =new LoginVo();
> 	}

@PageLoaded is triggered just once, when the page is instantiated. As  
Howard said, since 5.2, Tapestry has just one instance of each page and  
its state is stored in a per-request Map instead of the fields themselves.  
Just use onActivate() or @SetupRender instead and your problem will go  
away.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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