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/18 23:58:08 UTC
Re[5]: page & components activation contexts
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