Hi all,
Ralf Hirning - 09/Sep/08 09:34 AM
Greg, could you please describe what the impacts are if selectors are deprecated?
First off, and to make everything clear: if a feature is deprecated, it only means its usage is "discouraged". If we deprecate something now, it will not be removed in 3.6.2, and most probably not in 3.7 (although that would make our lifes easier). 3.8 or 4.0 would be the target release for removal of a feature we would deprecate now.
For example we use the selector in an image gallery. In the standard view you see all images. If you click on an image we generate an URL including the image nonde name as selector. The URI looks like
/fotos/examples.preview-0_00.html.
As we display this page in Liferay portal using WSRP the window view will be added to get
/fotos/examples.window-maximized.preview-0_00.html.
So we need the selector to add request data without the possibility to cache.
How can that be done using virtual URI mapping?
Okay, so the selector as get it from Magnolia (AggregationState.getSelector()) is always one single string. From the looks of your examples and the usages I found in some project indicate that this string is split on dots, but in both your example, you'll start working based on strings like preview-0_00 or window-maximized.preview-0_00, right ?
Now, let's say you setup a virtual uri mapping:
The only thing to do is modify your templates so that instead of doing AggregationState.getSelector() or Resource.getSelector(), you'll do request.getParameter("selector").
Note that:
- you don't have to define this virtualUriMapping specifically for "/fotos/examples" and if you map {{/([a-zA-Z0-9_/-]+\.(.*)\.html}} to /$1.html?selector=$2 you'll essentially get the same behaviour as currently.
- the cache key will be the original URI (ie /fotos/examples.preview-0_00.html), so there's no caching issue.
- you can define your own implementation of VirtualURIMapping which can potentially do much more complex mappings. (but possibly simpler to configure)
Wolfgang Habicht - 09/Sep/08 09:48 AM
We also use selectors a lot in our projects.
I see still some more problems replacing selectors with URI mappings:
- assume the case having selectors and optional URL parameters: is this possible with a regexp? (you need to add ?selector=... or &selector=...)
[Alternatively a new VirtualURIMapping class could be written...]
- to remove them internally might work - however I do not see any advantage (see below)
- removing selectors also in URLs is much more than just search/replace; there could be also some string operations concatenating URL-parts; potentially also in Java Script.
1. yes, I'd write a new VirtualURIMapping for this (I'm pretty sure a regex would be feasible, but just thinking about it gives me headaches) - thanks for pointing this out; if we reach an agreement here, we'll make sure to provide it for replacement.
2. Advantage for Magnolia's code base: streamline/simplify both the filters and the aggregation state-related classes. Advantage for templates: one way of doing things instead of 2.
3. You wouldn't need to remove them from your pages' url: quite the contrary, you'll want to keep them (nicer URLs, cacheable). The only place that needs to change is where the selector is USED (i.e template/code)
The question whether to remove selectors came from the idea to allow dots in (only some?) node names. I didn't get the advantage of removing selectors in the proposed way to achieve dots in names; they still exist in the URI - and are "only" removed during processing.
It's more that, while researching why dots in user name were currently not allowed/working, Jan ran accross this and we realized that
- the selector mechanism prevented from accessing nodes with dots in their name through a url.
- this was redundant wiuth the intentions, and less powerful than, the virtual uri mappings.
If you remove them from the URI (as sent by the client) too, you run into caching problems.
Unless I missed something, no, see explanations above.
If you have really good reasons to remove selectors, please do not do it in a major release (i.e. Magnolia 4.0) as in my opinion this is a major change.
It is indeed, which is why we wanted to deprecate it now, and as said above, not remove it until a further major version.
Giancarlo Berner - 09/Sep/08 10:12 AM
We also use selectors a lot, especially in combination with Base64 encoding. One important reason is caching: While requests with parameters are not returned from cache (e.g. Web servers), requests with selectors are. So if e.g. a user iterates through an image gallery, these images would be cached.
As mentioned above, the original request (i.e with the "selector" in the url) will be cached.
Another problem when removing selectors are the existing projects. It would indeed be very cumbersome to rework each and every project.
Well, two things, it seems I have to insist on:
- we're only deprecating it.
- is what I proposed above (replacing Resource.getSelector() by request.getParameter("selector")) really cumbersome ?
Thanks for the feedback guys, I hope this shed some light on your fears. Let us know what you think.
How do you judge that selectors can be deprecated?
We use selectors intensively in the projects and I do not see how to get the same results with virtual URI mappings.