You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Boris Horvat <ho...@gmail.com> on 2014/09/16 00:25:21 UTC

Are component parameters shared between sessions?

Hi all,

I have a question and a problem that I was unable to find in tapestry
documentation.

I have a page that has a filter component. This components basically
accepts a filter and then displays is properties. A user can modify those
properties and when it presses a button this value is set back to the
components parameter. This in returns is then propagated (since parameters
are bi-directional) back to the page that is then able to filter for
correct data.

Now my problem is that since I have

@Persist
@Property
private Filter filter

on my page and once a value from component is is returned to this property
for the user1 it is also applied to the user2.

Is this something expected? I would expect that if the value is returned
for user1 then user2 can't see this, am i wrong?

In my FilterComponent I have

@Parameter
private Filter filter;

and then when a form is submitted I do something like

filter = new Filter(selectedSections())

Reading a tapestry documentation I get that page only has one instance, so
does this mean that once I place something in the component's parameter it
is unable to determine in which session it should be place?

Thanks and let me know if you need more code

-- 
Sincerely
*Boris Horvat*

Re: Are component parameters shared between sessions?

Posted by Robert Zeigler <ro...@roxanemy.com>.
No, something else is going on here. @Persist should be specific to the user session by default. Without seeing more of your page and component class code, I can't offer any conjectures. But I've used @Persistany times with no user-bleed over so something else is definitely going on here. 

Robert

GATAATGCTATTTCTTTAATTTTCGAA

> On Sep 15, 2014, at 5:25 PM, Boris Horvat <ho...@gmail.com> wrote:
> 
> Hi all,
> 
> I have a question and a problem that I was unable to find in tapestry
> documentation.
> 
> I have a page that has a filter component. This components basically
> accepts a filter and then displays is properties. A user can modify those
> properties and when it presses a button this value is set back to the
> components parameter. This in returns is then propagated (since parameters
> are bi-directional) back to the page that is then able to filter for
> correct data.
> 
> Now my problem is that since I have
> 
> @Persist
> @Property
> private Filter filter
> 
> on my page and once a value from component is is returned to this property
> for the user1 it is also applied to the user2.
> 
> Is this something expected? I would expect that if the value is returned
> for user1 then user2 can't see this, am i wrong?
> 
> In my FilterComponent I have
> 
> @Parameter
> private Filter filter;
> 
> and then when a form is submitted I do something like
> 
> filter = new Filter(selectedSections())
> 
> Reading a tapestry documentation I get that page only has one instance, so
> does this mean that once I place something in the component's parameter it
> is unable to determine in which session it should be place?
> 
> Thanks and let me know if you need more code
> 
> -- 
> Sincerely
> *Boris Horvat*

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


Re: Are component parameters shared between sessions?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 15 Sep 2014 19:25:21 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

> Hi all,

Hi!

Answering the question in the subject:

Short answer: no.
Long answer: noooooooooooooooooooooooooooooooooo! :p

On the other hand, you can @Persist a field which is used as a parameter  
to a component or mixin. This is very different from persisting the  
parameter itself, though, as the field is the one being persisted, not the

> @Persist
> @Property
> private Filter filter

As Lance said, never initialize a @Persist field in its declaration.

Example of something you should never do:

@Persist
@Property
private Filter filter = new Filter();

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Are component parameters shared between sessions?

Posted by Lance Java <la...@googlemail.com>.
This type of bleed can occur when you initialize fields in their
declaration
eg:

@Persist
@Property
private Filter filter = new Filter(); // BAD!!

Re: Are component parameters shared between sessions?

Posted by Boris Horvat <ho...@gmail.com>.
Hi Jens,

Let me first try to clean this up a bit, I get a feeling it is too hard to
figure a problem when I have so much parameters (Robert got the impression
that I use @Parameter and @Property on the same field and I dont :))

I agree with you, this doesn't look like tapestry problem but my own, so I
will try to make this code simpler and see if that helps to resolve it, if
not I will be back :)

Thanks all


On Thu, Sep 18, 2014 at 3:13 PM, Robert Zeigler <robert.zeigler@roxanemy.com
> wrote:

> Don't use @persist and @parameter on the same property. If something is a
> parameter, then persistence of the bound property should be handled by the
> container.
>
> Robert
>
> GATAATGCTATTTCTTTAATTTTCGAA
>
> > On Sep 17, 2014, at 4:09 PM, Boris Horvat <ho...@gmail.com>
> wrote:
> >
> > I have never tried to initialize Filter in the field so I don't have such
> > problem. Here is my code
> >
> > In the page I have
> >
> >    @Property
> >    @Persist
> >    private Filter filter;
> >
> > this field is null at the begining, and it is always passed to the
> > hibernate in order to apply data filtering, if it is null, no need to do
> > any filtering.
> >
> > I have a component that is called FilterData
> >
> >        <t:layout.FilterData filter="filter" />
> >
> > In that component I have
> >
> >    @Parameter
> >    private Filter filter;
> >    @Property
> >    @Persist
> >    private Filter selectedFilter;
> >
> > The property selectedFilter is used for the display and manipulation by
> the
> > component (probably I could live without this), and once all of the
> fields
> > are selected and a run button is pressed I execute something like
> >
> > filter = new Filter(selectedFilter)
> >
> > For the user that has done this I can see new object been passed, however
> > if the same page is refreshed by another user (using a different browser,
> > or even different machine) I can see that it also has the same object in
> > the filter property.
> >
> > I will try to clear code a bit and remove selectedFilter if possible and
> > see if that helps. But all in all I think I got my answer, still if
> anyone
> > has any idea why do I see this problem, feel free to shout :)
> >
> > Thanks
> >
> > PS removing @Persist from selectedFilter did not help
> >
> >
> >
> > On Tue, Sep 16, 2014 at 2:56 PM, Thiago H de Paula Figueiredo <
> > thiagohp@gmail.com> wrote:
> >
> >> On Mon, 15 Sep 2014 19:25:21 -0300, Boris Horvat <
> horvat.z.boris@gmail.com>
> >> wrote:
> >>
> >> Reading a tapestry documentation I get that page only has one instance,
> >>> so does this mean that once I place something in the component's
> parameter
> >>> it is unable to determine in which session it should be place?
> >>
> >> No. Tapestry itself never persists parameter values in the session.
> >> Parameters are completely independent from the session. In addition,
> >> Tapestry uses a single page instance for all requests, but the page
> state
> >> (non-annotated fields) is actually stored in a per-request (per-thread)
> >> map, all this done transparently and automatically, so the state of one
> >> request doesn't affect other requests at all.
> >>
> >>
> >> --
> >> Thiago H. de Paula Figueiredo
> >> Tapestry, Java and Hibernate consultant and developer
> >> http://machina.com.br
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Sincerely
*Boris Horvat*

Re: Are component parameters shared between sessions?

Posted by Robert Zeigler <ro...@roxanemy.com>.
Don't use @persist and @parameter on the same property. If something is a parameter, then persistence of the bound property should be handled by the container. 

Robert

GATAATGCTATTTCTTTAATTTTCGAA

> On Sep 17, 2014, at 4:09 PM, Boris Horvat <ho...@gmail.com> wrote:
> 
> I have never tried to initialize Filter in the field so I don't have such
> problem. Here is my code
> 
> In the page I have
> 
>    @Property
>    @Persist
>    private Filter filter;
> 
> this field is null at the begining, and it is always passed to the
> hibernate in order to apply data filtering, if it is null, no need to do
> any filtering.
> 
> I have a component that is called FilterData
> 
>        <t:layout.FilterData filter="filter" />
> 
> In that component I have
> 
>    @Parameter
>    private Filter filter;
>    @Property
>    @Persist
>    private Filter selectedFilter;
> 
> The property selectedFilter is used for the display and manipulation by the
> component (probably I could live without this), and once all of the fields
> are selected and a run button is pressed I execute something like
> 
> filter = new Filter(selectedFilter)
> 
> For the user that has done this I can see new object been passed, however
> if the same page is refreshed by another user (using a different browser,
> or even different machine) I can see that it also has the same object in
> the filter property.
> 
> I will try to clear code a bit and remove selectedFilter if possible and
> see if that helps. But all in all I think I got my answer, still if anyone
> has any idea why do I see this problem, feel free to shout :)
> 
> Thanks
> 
> PS removing @Persist from selectedFilter did not help
> 
> 
> 
> On Tue, Sep 16, 2014 at 2:56 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
> 
>> On Mon, 15 Sep 2014 19:25:21 -0300, Boris Horvat <ho...@gmail.com>
>> wrote:
>> 
>> Reading a tapestry documentation I get that page only has one instance,
>>> so does this mean that once I place something in the component's parameter
>>> it is unable to determine in which session it should be place?
>> 
>> No. Tapestry itself never persists parameter values in the session.
>> Parameters are completely independent from the session. In addition,
>> Tapestry uses a single page instance for all requests, but the page state
>> (non-annotated fields) is actually stored in a per-request (per-thread)
>> map, all this done transparently and automatically, so the state of one
>> request doesn't affect other requests at all.
>> 
>> 
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> -- 
> Sincerely
> *Boris Horvat*

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


Re: Are component parameters shared between sessions?

Posted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
Hi Boris,
can you share the real code because I am confused by "filter" and "selectedFilter". Both are of type "Filter", but assigned using "new"?
Can you show the filter impl? Are you using a filter cache somewhere? Or a service class which is not created on a per request base but only once? And just shouting: are you sure you have different users, different sessions? Don't get me wrong, by asking these silly questions, but personally I doubt it's a Tapestry issue... 

Jens

Von meinem iPhone gesendet

> Am 18.09.2014 um 00:09 schrieb Boris Horvat <ho...@gmail.com>:
> 
> I have never tried to initialize Filter in the field so I don't have such
> problem. Here is my code
> 
> In the page I have
> 
>    @Property
>    @Persist
>    private Filter filter;
> 
> this field is null at the begining, and it is always passed to the
> hibernate in order to apply data filtering, if it is null, no need to do
> any filtering.
> 
> I have a component that is called FilterData
> 
>        <t:layout.FilterData filter="filter" />
> 
> In that component I have
> 
>    @Parameter
>    private Filter filter;
>    @Property
>    @Persist
>    private Filter selectedFilter;
> 
> The property selectedFilter is used for the display and manipulation by the
> component (probably I could live without this), and once all of the fields
> are selected and a run button is pressed I execute something like
> 
> filter = new Filter(selectedFilter)
> 
> For the user that has done this I can see new object been passed, however
> if the same page is refreshed by another user (using a different browser,
> or even different machine) I can see that it also has the same object in
> the filter property.
> 
> I will try to clear code a bit and remove selectedFilter if possible and
> see if that helps. But all in all I think I got my answer, still if anyone
> has any idea why do I see this problem, feel free to shout :)
> 
> Thanks
> 
> PS removing @Persist from selectedFilter did not help
> 
> 
> 
> On Tue, Sep 16, 2014 at 2:56 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
> 
>> On Mon, 15 Sep 2014 19:25:21 -0300, Boris Horvat <ho...@gmail.com>
>> wrote:
>> 
>> Reading a tapestry documentation I get that page only has one instance,
>>> so does this mean that once I place something in the component's parameter
>>> it is unable to determine in which session it should be place?
>> 
>> No. Tapestry itself never persists parameter values in the session.
>> Parameters are completely independent from the session. In addition,
>> Tapestry uses a single page instance for all requests, but the page state
>> (non-annotated fields) is actually stored in a per-request (per-thread)
>> map, all this done transparently and automatically, so the state of one
>> request doesn't affect other requests at all.
>> 
>> 
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> -- 
> Sincerely
> *Boris Horvat*

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


Re: Are component parameters shared between sessions?

Posted by Boris Horvat <ho...@gmail.com>.
I have never tried to initialize Filter in the field so I don't have such
problem. Here is my code

In the page I have

    @Property
    @Persist
    private Filter filter;

this field is null at the begining, and it is always passed to the
hibernate in order to apply data filtering, if it is null, no need to do
any filtering.

I have a component that is called FilterData

        <t:layout.FilterData filter="filter" />

In that component I have

    @Parameter
    private Filter filter;
    @Property
    @Persist
    private Filter selectedFilter;

The property selectedFilter is used for the display and manipulation by the
component (probably I could live without this), and once all of the fields
are selected and a run button is pressed I execute something like

filter = new Filter(selectedFilter)

For the user that has done this I can see new object been passed, however
if the same page is refreshed by another user (using a different browser,
or even different machine) I can see that it also has the same object in
the filter property.

I will try to clear code a bit and remove selectedFilter if possible and
see if that helps. But all in all I think I got my answer, still if anyone
has any idea why do I see this problem, feel free to shout :)

Thanks

PS removing @Persist from selectedFilter did not help



On Tue, Sep 16, 2014 at 2:56 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 15 Sep 2014 19:25:21 -0300, Boris Horvat <ho...@gmail.com>
> wrote:
>
>  Reading a tapestry documentation I get that page only has one instance,
>> so does this mean that once I place something in the component's parameter
>> it is unable to determine in which session it should be place?
>>
>
> No. Tapestry itself never persists parameter values in the session.
> Parameters are completely independent from the session. In addition,
> Tapestry uses a single page instance for all requests, but the page state
> (non-annotated fields) is actually stored in a per-request (per-thread)
> map, all this done transparently and automatically, so the state of one
> request doesn't affect other requests at all.
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Sincerely
*Boris Horvat*

Re: Are component parameters shared between sessions?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 15 Sep 2014 19:25:21 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

> Reading a tapestry documentation I get that page only has one instance,  
> so does this mean that once I place something in the component's  
> parameter it is unable to determine in which session it should be place?

No. Tapestry itself never persists parameter values in the session.  
Parameters are completely independent from the session. In addition,  
Tapestry uses a single page instance for all requests, but the page state  
(non-annotated fields) is actually stored in a per-request (per-thread)  
map, all this done transparently and automatically, so the state of one  
request doesn't affect other requests at all.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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