You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Rory Douglas <ro...@oracle.com> on 2009/01/13 03:32:19 UTC
Problem with replaceSelectors in tag
I have a resource of type test/A, which has 2 rendering scripts at:
(1) /apps/test/A/edit.html.jsp and
(2) /apps/test/A/view.html.jsp.
In those scripts I render resources of type test/B, which has rendering
scripts at:
(3) /apps/test/B/edit.small.jsp and
(4) /apps/test/B/view.small.jsp
(5) /apps/test/B/edit.html.jsp
What is the correct syntax of a <sling:include tag> to include the
edit.small rendering (3) of test/B inside the edit rendering (1) of test/A?
I have <sling:include replaceSelectors="edit.small" path="..." /> but
that doesn't work. I also tried addSelectors="small" but that didn't
work either. Both of those yield an include of edit.html.jsp (5)
instead of edit.small.html.jsp (3).
Rory
Re: Problem with replaceSelectors in tag
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Rory,
On Tue, Jan 13, 2009 at 6:35 PM, Rory Douglas <ro...@oracle.com> wrote:
> ...I was tracing through the code in debug yesterday, and I think the problem
> with not considering 2+ component selectors strings is in
> ResourceCollector.getWeightedResources (lines 174-247)....
Could you look at the tests in [1] to see if that clarifies your
question? There are a few testMultipleSelectors..() test methods that
do similar things than what you want to achieve.
Feel free to suggest more tests if that makes sense - I'd like that
test class to hold the Absolute Truth About Script Selection ;-)
-Bertrand
[1] http://svn.apache.org/repos/asf/incubator/sling/trunk/servlets/resolver/src/test/java/org/apache/sling/servlets/resolver/helper/ScriptSelectionTest.java
Re: Problem with replaceSelectors in tag
Posted by Rory Douglas <ro...@oracle.com>.
Thanks Alex, that explanation about IDEs makes a lot of sense.
I was tracing through the code in debug yesterday, and I think the
problem with not considering 2+ component selectors strings is in
ResourceCollector.getWeightedResources (lines 174-247).
I notice the do-while loop exited before considering my "edit.small"
selector (requestSelectors[1]) because of the IF block at line 242: with
selector "edit" (requestSelectors[0]) it attempts to set resource
"current" to the resource path "current"/"selector" (which exists if I
have my script as /apps/test/B/edit/small.html.jsp, but not if I only
have /apps/test/B/edit.small.html.jsp). Current becomes null & causes
the loop to exit.
Is the solution perhaps to order the requestSelectors array prior to the
do-while loop by decreasing number of dot-separated components?
Regards,
Rory
Alexander Klimetschek wrote:
> On Tue, Jan 13, 2009 at 5:43 PM, Rory Douglas <ro...@oracle.com> wrote:
>
>> Sorry, I incorrectly copied down the script names for (3) and (4) they are:
>>
>> (3) /apps/test/B/edit.small.html.jsp
>> (4) /apps/test/B/view.small.html.jsp
>>
>> However, your suggestion works ((A) /apps/test/B/edit/small.html.jsp). It's
>> a little confusing to me though, since (B) /apps/test/B/edit/small/html.jsp
>> also works.
>>
>> Does that imply that at only the first dot-separated component of the
>> scriptname can be considered as part of the selector string? Wouldn't it be
>> more consistent to either:
>>
>> a) consider all dot-separated components part of the selector except the
>> last 2 (those last 2 being the extension and the script language identifier)
>> (like (3) and (4) or
>> b) only allow the script name to be <extension>.<script language
>> identifier>, and selectors have to be /-separated components of the path
>> (like (B) above)
>>
>> Is there a specific reason for the current implementation behavior?
>>
>
> It was once changed so that filenames can "look" different if you have
> them open at the same time in your favorite editor or IDE that only
> displays the filename in the tab. And since you are typically using
> the same scripting language for those files, you could end up with a
> lot of "html.jsp" files for example (/apps/test/B/edit/small/html.jsp
> and /apps/test/B/view/small/html.jsp).
>
> This, btw, was at first the "normal" case, ie. selectors had to be
> folders and the filename of the script was always <extension>.<script
> language>, as you mention in b). This was modified to allow filenames
> such as "small.html.jsp", but not sure why Sling only allows to use
> the last selector as part of the script file name ("small" in your
> case). Might be a bug.
>
> Regards,
> Alex
>
>
--
Rory Douglas | Senior Principal Consultant
Fax: +1-201-604-6428 | Mobile: +1-917-498-5344
Oracle North America Consulting
ORACLE United States | | San Diego, CA
"Please consider your environmental responsibility before printing this
e-mail"
Re: Problem with replaceSelectors in tag
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, Jan 13, 2009 at 5:43 PM, Rory Douglas <ro...@oracle.com> wrote:
> Sorry, I incorrectly copied down the script names for (3) and (4) they are:
>
> (3) /apps/test/B/edit.small.html.jsp
> (4) /apps/test/B/view.small.html.jsp
>
> However, your suggestion works ((A) /apps/test/B/edit/small.html.jsp). It's
> a little confusing to me though, since (B) /apps/test/B/edit/small/html.jsp
> also works.
>
> Does that imply that at only the first dot-separated component of the
> scriptname can be considered as part of the selector string? Wouldn't it be
> more consistent to either:
>
> a) consider all dot-separated components part of the selector except the
> last 2 (those last 2 being the extension and the script language identifier)
> (like (3) and (4) or
> b) only allow the script name to be <extension>.<script language
> identifier>, and selectors have to be /-separated components of the path
> (like (B) above)
>
> Is there a specific reason for the current implementation behavior?
It was once changed so that filenames can "look" different if you have
them open at the same time in your favorite editor or IDE that only
displays the filename in the tab. And since you are typically using
the same scripting language for those files, you could end up with a
lot of "html.jsp" files for example (/apps/test/B/edit/small/html.jsp
and /apps/test/B/view/small/html.jsp).
This, btw, was at first the "normal" case, ie. selectors had to be
folders and the filename of the script was always <extension>.<script
language>, as you mention in b). This was modified to allow filenames
such as "small.html.jsp", but not sure why Sling only allows to use
the last selector as part of the script file name ("small" in your
case). Might be a bug.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: Problem with replaceSelectors in tag
Posted by Rory Douglas <ro...@oracle.com>.
Sorry, I incorrectly copied down the script names for (3) and (4) they are:
(3) /apps/test/B/edit.small.html.jsp
(4) /apps/test/B/view.small.html.jsp
However, your suggestion works ((A) /apps/test/B/edit/small.html.jsp).
It's a little confusing to me though, since (B)
/apps/test/B/edit/small/html.jsp also works.
Does that imply that at only the first dot-separated component of the
scriptname can be considered as part of the selector string? Wouldn't
it be more consistent to either:
a) consider all dot-separated components part of the selector except the
last 2 (those last 2 being the extension and the script language
identifier) (like (3) and (4) or
b) only allow the script name to be <extension>.<script language
identifier>, and selectors have to be /-separated components of the path
(like (B) above)
Is there a specific reason for the current implementation behavior?
Regards,
Rory
Felix Meschberger wrote:
> Hi Rory,
>
> Rory Douglas schrieb:
>
>> I have a resource of type test/A, which has 2 rendering scripts at:
>> (1) /apps/test/A/edit.html.jsp and
>> (2) /apps/test/A/view.html.jsp.
>>
>> In those scripts I render resources of type test/B, which has rendering
>> scripts at:
>> (3) /apps/test/B/edit.small.jsp and
>> (4) /apps/test/B/view.small.jsp
>>
>
> Shouldn't these rather be
>
> (3) /apps/test/B/edit/small.html.jsp and
> (4) /apps/test/B/view/small.html.jsp
>
> ?
>
> Regards
> Felix
>
>
>> (5) /apps/test/B/edit.html.jsp
>>
>> What is the correct syntax of a <sling:include tag> to include the
>> edit.small rendering (3) of test/B inside the edit rendering (1) of test/A?
>>
>> I have <sling:include replaceSelectors="edit.small" path="..." /> but
>> that doesn't work. I also tried addSelectors="small" but that didn't
>> work either. Both of those yield an include of edit.html.jsp (5)
>> instead of edit.small.html.jsp (3).
>>
>> Rory
>>
>>
Re: Problem with replaceSelectors in tag
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Rory,
Rory Douglas schrieb:
> I have a resource of type test/A, which has 2 rendering scripts at:
> (1) /apps/test/A/edit.html.jsp and
> (2) /apps/test/A/view.html.jsp.
>
> In those scripts I render resources of type test/B, which has rendering
> scripts at:
> (3) /apps/test/B/edit.small.jsp and
> (4) /apps/test/B/view.small.jsp
Shouldn't these rather be
(3) /apps/test/B/edit/small.html.jsp and
(4) /apps/test/B/view/small.html.jsp
?
Regards
Felix
> (5) /apps/test/B/edit.html.jsp
>
> What is the correct syntax of a <sling:include tag> to include the
> edit.small rendering (3) of test/B inside the edit rendering (1) of test/A?
>
> I have <sling:include replaceSelectors="edit.small" path="..." /> but
> that doesn't work. I also tried addSelectors="small" but that didn't
> work either. Both of those yield an include of edit.html.jsp (5)
> instead of edit.small.html.jsp (3).
>
> Rory
>