You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Yury Luneff <bi...@ya.ru> on 2009/05/13 17:59:20 UTC

page & components activation contexts

Hello, users.

Is there a way to separate activation contexts for page and its
components?

I wrote a component that uses AJAX to interact from client side.
Render part of the component creates links for callbacks using
ComponentResources. And callbacks are method with fixed number
of arguments (2 for ex.).

When the page that contains that component tries to introduce its own
activation context, callback url will have page's context embedded. So
now AJAX calls to component with 3 context elements - 1 from page and
2 from component. And as the component knows nothing about this, it
must be treated in a special way (for now I retained only onActivate
part of the page so it's not a fully pages context that is saved).

Is there a way to clearly separate contexts of the page and component
events so that component could be unaware of any page it is embedded
to?

-- 
Best regards,
 Yury


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


Re: page & components activation contexts

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You should use an EventLink instead - that's what they're for. :)

/Filip

Yury Luneff skrev:
> Hello, users.
> 
> Is there a way to separate activation contexts for page and its
> components?
> 
> I wrote a component that uses AJAX to interact from client side.
> Render part of the component creates links for callbacks using
> ComponentResources. And callbacks are method with fixed number
> of arguments (2 for ex.).
> 
> When the page that contains that component tries to introduce its own
> activation context, callback url will have page's context embedded. So
> now AJAX calls to component with 3 context elements - 1 from page and
> 2 from component. And as the component knows nothing about this, it
> must be treated in a special way (for now I retained only onActivate
> part of the page so it's not a fully pages context that is saved).
> 
> Is there a way to clearly separate contexts of the page and component
> events so that component could be unaware of any page it is embedded
> to?
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEcBAEBAgAGBQJKC9YoAAoJEEfiH7PpjaMnMeYH/3DxibIPmP0c1mVrDqoo0Nob
swgq+Fuw8oxjH7ck8exjEwHrkbune93AButw0RLn/VyE4HpUEV+kr0zeJT85gqOj
D86O1Uf7x/vxyLyhPgiTIVkjmjsI6cDGjlTJmcI/z5Cq0pWlP/ojb10Flkn1mTMM
Yy9SzFSrsGhOammXHI4JyjkVV64FAcgeqMydcdE65fnKLtNBURMGzhLqHDq8Bc8G
+RlQHGqEzesoJbF0Ln2gVTT9TdSZ5OnQpMy/aIR87kklPbavTQpQ0rE6ZA88NsvG
UQp8S7nv3Vx7uewX1iT8FLSqQB2CmFyrekFQeIj4lZklyeFLgz5sBFG01376rDE=
=ncaC
-----END PGP SIGNATURE-----

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


Re[5]: page & components activation contexts

Posted by Yury Luneff <bi...@ya.ru>.
sorry :) i managed to make it work ok. The problem was really on
the JS part (as you suggested). As I don't have possibility to make
event links on client-side I did it by hand and it revealed, that the
one case I used to make an event-handler url is not the only case
tapestry has. Another is when "?t:ac=" is added. So, for now i've
merely changed url rewriting urls in my js code (as i _don't_ have
possibility to make event-links on client-side for changing context
parameters of the event in a standard way). Not the best solution,
probably, but it works and I'm happy of that :)

PS. the hack was smth like:
if (url.match(/\?/)) {
        // this part is required more rarely, but it is required
        // to be handled :)
        result = url.replace('?', '/' + contextPart + '?')
    } else {
        result = url + contextPart;
    }
(ugly, i know :)

>> Again Yuri you have not posted the relevant code, but at a guess
> it is the most relevant i have except the JS part :)
>> this is likely where you are going wrong:
>>>where "info" constructs server url from request
> for Ajax i think i must give full url and not the one with only
> context path (without server port, etc). "info" object doesn't do any
> troubles here.

>> Your link object should probably be constructing the relevant
>> context for your link, and not from the request:
> well, i need to construct these links in js code according to the
> logic i have choosen. I mean, js produces some arbitrary Ajax requests
> to the component and I can't build URL once at the server side as it
> changes all the time (actually, only two of those parameters). So i
> create event link which has none of these parameters in the context
> and add them manually on the client side according to the logic of my
> code and js event handling.

>> Link el = componentResources.createEventLink("getchildren", new Object[] { param1,param2 });

>> param 1 and 2 should be wired to the relevant component parameters of course.

>> Peter

>> ----- Original Message -----
>> From: "Yury Luneff" <bi...@ya.ru>
>> To: "Tapestry users" <us...@tapestry.apache.org>
>> Sent: Thursday, 14 May, 2009 13:28:06 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
>> Subject: Re[2]: page & components activation contexts

>> ok.

>> The component has:
>> @SuppressWarnings("unchecked")
>>     public StreamResponse onGetChildren(Long watcherId, Long domId) {
>>     ...}

>>     as component event. Hence, 2 context params

>>     links are created like that:
>> Link el = componentResources.createEventLink("getchildren");
>>         renderSupport.addScript("cascadeUrl = \"" + info.getServerURL() +
>>                 el.toAbsoluteURI() + "/\";");

>> (where "info" constructs server url from request). Maybe that's not
>> the true way, but javascript transforms this url by adding "/0/0" for
>> ex. I can't trigger "createEventLink" from client side and even if i
>> could, i would need to know pages context that is unrelated to the
>> component.

>> the page that uses the component:
>> private Integer type;

>>     public void onActivate(Integer type) {
>>         this.type = type;
>>     }

>>     public Integer onPassivate() {
>>            return type;
>>     }
>> --
>> therefore the page introduces its own activation context of one
>> parameter.

>> When the script constructs ajax request, the url becomes something
>> like "page/0/0/0", where the first one is from the page itself (and
>> provided by createEventLink) and the 2 latter are added by script.

>> And as the callback has only 2 parameters as context, it fails, as
>> tapestry tries to search onGetChildren with 3 parameters, one of which
>> is unrelated to the component.

>> I guess, now the problem is clearly described  
>>> Hi Yury,

>>> Please post some code, it will be easier to guide you.

>>> Peter

>>> ----- Original Message -----
>>> From: "Yury Luneff" <bi...@ya.ru>
>>> To: users@tapestry.apache.org
>>> Sent: Wednesday, 13 May, 2009 18:59:20 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
>>> Subject: page & components activation contexts

>>> Hello, users.

>>> Is there a way to separate activation contexts for page and its
>>> components?

>>> I wrote a component that uses AJAX to interact from client side.
>>> Render part of the component creates links for callbacks using
>>> ComponentResources. And callbacks are method with fixed number
>>> of arguments (2 for ex.).

>>> When the page that contains that component tries to introduce its own
>>> activation context, callback url will have page's context embedded. So
>>> now AJAX calls to component with 3 context elements - 1 from page and
>>> 2 from component. And as the component knows nothing about this, it
>>> must be treated in a special way (for now I retained only onActivate
>>> part of the page so it's not a fully pages context that is saved).

>>> Is there a way to clearly separate contexts of the page and component
>>> events so that component could be unaware of any page it is embedded
>>> to?






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




-- 
С уважением,
 Yury                          mailto:bitterman@ya.ru


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


Re[4]: page & components activation contexts

Posted by Yury Luneff <bi...@ya.ru>.
> Again Yuri you have not posted the relevant code, but at a guess
it is the most relevant i have except the JS part :)
> this is likely where you are going wrong:
>>where "info" constructs server url from request
for Ajax i think i must give full url and not the one with only
context path (without server port, etc). "info" object doesn't do any
troubles here.

> Your link object should probably be constructing the relevant
> context for your link, and not from the request:
well, i need to construct these links in js code according to the
logic i have choosen. I mean, js produces some arbitrary Ajax requests
to the component and I can't build URL once at the server side as it
changes all the time (actually, only two of those parameters). So i
create event link which has none of these parameters in the context
and add them manually on the client side according to the logic of my
code and js event handling.

> Link el = componentResources.createEventLink("getchildren", new Object[] { param1,param2 });

> param 1 and 2 should be wired to the relevant component parameters of course.

> Peter

> ----- Original Message -----
> From: "Yury Luneff" <bi...@ya.ru>
> To: "Tapestry users" <us...@tapestry.apache.org>
> Sent: Thursday, 14 May, 2009 13:28:06 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
> Subject: Re[2]: page & components activation contexts

> ok.

> The component has:
> @SuppressWarnings("unchecked")
>     public StreamResponse onGetChildren(Long watcherId, Long domId) {
>     ...}

>     as component event. Hence, 2 context params

>     links are created like that:
> Link el = componentResources.createEventLink("getchildren");
>         renderSupport.addScript("cascadeUrl = \"" + info.getServerURL() +
>                 el.toAbsoluteURI() + "/\";");

> (where "info" constructs server url from request). Maybe that's not
> the true way, but javascript transforms this url by adding "/0/0" for
> ex. I can't trigger "createEventLink" from client side and even if i
> could, i would need to know pages context that is unrelated to the
> component.

> the page that uses the component:
> private Integer type;

>     public void onActivate(Integer type) {
>         this.type = type;
>     }

>     public Integer onPassivate() {
>            return type;
>     }
> --
> therefore the page introduces its own activation context of one
> parameter.

> When the script constructs ajax request, the url becomes something
> like "page/0/0/0", where the first one is from the page itself (and
> provided by createEventLink) and the 2 latter are added by script.

> And as the callback has only 2 parameters as context, it fails, as
> tapestry tries to search onGetChildren with 3 parameters, one of which
> is unrelated to the component.

> I guess, now the problem is clearly described  
>> Hi Yury,

>> Please post some code, it will be easier to guide you.

>> Peter

>> ----- Original Message -----
>> From: "Yury Luneff" <bi...@ya.ru>
>> To: users@tapestry.apache.org
>> Sent: Wednesday, 13 May, 2009 18:59:20 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
>> Subject: page & components activation contexts

>> Hello, users.

>> Is there a way to separate activation contexts for page and its
>> components?

>> I wrote a component that uses AJAX to interact from client side.
>> Render part of the component creates links for callbacks using
>> ComponentResources. And callbacks are method with fixed number
>> of arguments (2 for ex.).

>> When the page that contains that component tries to introduce its own
>> activation context, callback url will have page's context embedded. So
>> now AJAX calls to component with 3 context elements - 1 from page and
>> 2 from component. And as the component knows nothing about this, it
>> must be treated in a special way (for now I retained only onActivate
>> part of the page so it's not a fully pages context that is saved).

>> Is there a way to clearly separate contexts of the page and component
>> events so that component could be unaware of any page it is embedded
>> to?






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


Re: Re[2]: page & components activation contexts

Posted by Peter Stavrinides <P....@albourne.com>.
Again Yuri you have not posted the relevant code, but at a guess this is likely where you are going wrong:
>where "info" constructs server url from request

Your link object should probably be constructing the relevant context for your link, and not from the request:

Link el = componentResources.createEventLink("getchildren", new Object[] { param1,param2 });

param 1 and 2 should be wired to the relevant component parameters of course.

Peter

----- Original Message -----
From: "Yury Luneff" <bi...@ya.ru>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Thursday, 14 May, 2009 13:28:06 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re[2]: page & components activation contexts

ok.

The component has:
@SuppressWarnings("unchecked")
    public StreamResponse onGetChildren(Long watcherId, Long domId) {
    ...}

    as component event. Hence, 2 context params

    links are created like that:
Link el = componentResources.createEventLink("getchildren");
        renderSupport.addScript("cascadeUrl = \"" + info.getServerURL() +
                el.toAbsoluteURI() + "/\";");

(where "info" constructs server url from request). Maybe that's not
the true way, but javascript transforms this url by adding "/0/0" for
ex. I can't trigger "createEventLink" from client side and even if i
could, i would need to know pages context that is unrelated to the
component.

the page that uses the component:
private Integer type;

    public void onActivate(Integer type) {
        this.type = type;
    }

    public Integer onPassivate() {
           return type;
    }
--
therefore the page introduces its own activation context of one
parameter.

When the script constructs ajax request, the url becomes something
like "page/0/0/0", where the first one is from the page itself (and
provided by createEventLink) and the 2 latter are added by script.

And as the callback has only 2 parameters as context, it fails, as
tapestry tries to search onGetChildren with 3 parameters, one of which
is unrelated to the component.

I guess, now the problem is clearly described :)
> Hi Yury,

> Please post some code, it will be easier to guide you.

> Peter

> ----- Original Message -----
> From: "Yury Luneff" <bi...@ya.ru>
> To: users@tapestry.apache.org
> Sent: Wednesday, 13 May, 2009 18:59:20 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
> Subject: page & components activation contexts

> Hello, users.

> Is there a way to separate activation contexts for page and its
> components?

> I wrote a component that uses AJAX to interact from client side.
> Render part of the component creates links for callbacks using
> ComponentResources. And callbacks are method with fixed number
> of arguments (2 for ex.).

> When the page that contains that component tries to introduce its own
> activation context, callback url will have page's context embedded. So
> now AJAX calls to component with 3 context elements - 1 from page and
> 2 from component. And as the component knows nothing about this, it
> must be treated in a special way (for now I retained only onActivate
> part of the page so it's not a fully pages context that is saved).

> Is there a way to clearly separate contexts of the page and component
> events so that component could be unaware of any page it is embedded
> to?



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


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


Re[2]: page & components activation contexts

Posted by Yury Luneff <bi...@ya.ru>.
ok.

The component has:
@SuppressWarnings("unchecked")
    public StreamResponse onGetChildren(Long watcherId, Long domId) {
    ...}

    as component event. Hence, 2 context params

    links are created like that:
Link el = componentResources.createEventLink("getchildren");
        renderSupport.addScript("cascadeUrl = \"" + info.getServerURL() +
                el.toAbsoluteURI() + "/\";");

(where "info" constructs server url from request). Maybe that's not
the true way, but javascript transforms this url by adding "/0/0" for
ex. I can't trigger "createEventLink" from client side and even if i
could, i would need to know pages context that is unrelated to the
component.

the page that uses the component:
private Integer type;

    public void onActivate(Integer type) {
        this.type = type;
    }

    public Integer onPassivate() {
           return type;
    }
--
therefore the page introduces its own activation context of one
parameter.

When the script constructs ajax request, the url becomes something
like "page/0/0/0", where the first one is from the page itself (and
provided by createEventLink) and the 2 latter are added by script.

And as the callback has only 2 parameters as context, it fails, as
tapestry tries to search onGetChildren with 3 parameters, one of which
is unrelated to the component.

I guess, now the problem is clearly described :)
> Hi Yury,

> Please post some code, it will be easier to guide you.

> Peter

> ----- Original Message -----
> From: "Yury Luneff" <bi...@ya.ru>
> To: users@tapestry.apache.org
> Sent: Wednesday, 13 May, 2009 18:59:20 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
> Subject: page & components activation contexts

> Hello, users.

> Is there a way to separate activation contexts for page and its
> components?

> I wrote a component that uses AJAX to interact from client side.
> Render part of the component creates links for callbacks using
> ComponentResources. And callbacks are method with fixed number
> of arguments (2 for ex.).

> When the page that contains that component tries to introduce its own
> activation context, callback url will have page's context embedded. So
> now AJAX calls to component with 3 context elements - 1 from page and
> 2 from component. And as the component knows nothing about this, it
> must be treated in a special way (for now I retained only onActivate
> part of the page so it's not a fully pages context that is saved).

> Is there a way to clearly separate contexts of the page and component
> events so that component could be unaware of any page it is embedded
> to?



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


Re: page & components activation contexts

Posted by Peter Stavrinides <P....@albourne.com>.
Hi Yury,

Please post some code, it will be easier to guide you.

Peter

----- Original Message -----
From: "Yury Luneff" <bi...@ya.ru>
To: users@tapestry.apache.org
Sent: Wednesday, 13 May, 2009 18:59:20 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: page & components activation contexts

Hello, users.

Is there a way to separate activation contexts for page and its
components?

I wrote a component that uses AJAX to interact from client side.
Render part of the component creates links for callbacks using
ComponentResources. And callbacks are method with fixed number
of arguments (2 for ex.).

When the page that contains that component tries to introduce its own
activation context, callback url will have page's context embedded. So
now AJAX calls to component with 3 context elements - 1 from page and
2 from component. And as the component knows nothing about this, it
must be treated in a special way (for now I retained only onActivate
part of the page so it's not a fully pages context that is saved).

Is there a way to clearly separate contexts of the page and component
events so that component could be unaware of any page it is embedded
to?

-- 
Best regards,
 Yury


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


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