Re: One Resource to multiple views in different locations

2016-07-16 Thread Roy Teeuwen
Hey Vkum,

We use osgi configs per site for this :). We define per sitename the fallback 
roots (so that would in your example be site1 and if not available fall back to 
generic)

Greets
Roy
> On 14 Jul 2016, at 14:48, vkum14  wrote:
> 
> Hi Roy,
> 
> My apology here if I asked the same information. You have been great help
> :). 
> I guess the only thing which is still not clear (and might be either I was
> not able to explain or I didn't get it right) to me is the 2nd point in my
> email below. I got your point on using a separate resourceType and that
> works great but what about the following scenario:
> 1. resourceType is changed from /apps/site/components/comp1 to
> /apps/site1/components/comp1 based on request for a page under site1.
> 2. My scripts reside in 2 folders than just one:
> a) //site1/components/comp1
> b) //generic/components/comp1
> and I want to use all the scripts under these 2 folders to be used in
> weighted alogorith for sling to find the best match, I am not sure how to do
> that. I am thinking to use ResoureProvider here like ResourceMerger does.
> Thanks so much again for all the help.
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062556.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



Re: One Resource to multiple views in different locations

2016-07-14 Thread vkum14
Hi Roy,

My apology here if I asked the same information. You have been great help
:). 
I guess the only thing which is still not clear (and might be either I was
not able to explain or I didn't get it right) to me is the 2nd point in my
email below. I got your point on using a separate resourceType and that
works great but what about the following scenario:
1. resourceType is changed from /apps/site/components/comp1 to
/apps/site1/components/comp1 based on request for a page under site1.
2. My scripts reside in 2 folders than just one:
a) //site1/components/comp1
b) //generic/components/comp1
and I want to use all the scripts under these 2 folders to be used in
weighted alogorith for sling to find the best match, I am not sure how to do
that. I am thinking to use ResoureProvider here like ResourceMerger does.
Thanks so much again for all the help.



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062556.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-14 Thread Roy Teeuwen
Hey vkum,

Sorry, but…

All the info is right there in my previous mails. I’m not going to repeat 
myself 100 times. We solve it by overriding the resource type by using a filter 
that looks at the site name of the current resource. The resource type could be 
ANYWHERE in /apps /libs or whatever extra folder you defined to have resource 
types , thats how resource types work…

Greets
Roy
> On 14 Jul 2016, at 11:19, vkum14  wrote:
> 
> Sure, makes sense :).Just to take this conversation to next level as I am
> thinking more, is it possible to separate views (jsp files) from component?
> What I meant is 1. that cq:component does have dialog and jsps are somewhere
> else in a different folder and I can configure component to pick
> views/scripts from that folder? 2. Also can I have scripts stored in
> multiple folders and not just one?
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062550.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



Re: One Resource to multiple views in different locations

2016-07-14 Thread vkum14
Sure, makes sense :).Just to take this conversation to next level as I am
thinking more, is it possible to separate views (jsp files) from component?
What I meant is 1. that cq:component does have dialog and jsps are somewhere
else in a different folder and I can configure component to pick
views/scripts from that folder? 2. Also can I have scripts stored in
multiple folders and not just one?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062550.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-14 Thread Roy Teeuwen
Hey Vkmag,

I only showed you like two lines ;) of course the handling of this is a lot 
more than this. There is a check that they both inherit from the same 
/apps/site-common/components/header component, with a fallback to the 
site-common header component and stuff like that. You can all do that, thats up 
to you to figure out what requirements you have :D

Greetings,
Roy
> On 14 Jul 2016, at 11:09, vkum14  wrote:
> 
> Yes but my use case demands to do the same with same component as to avoid 
> defining a new component when more brands come onboard. Have you done that 
> sort of something as well?
> 
> VINEET KUMAR
> Sr. Specialist
> -
> SapientNitro
> Gurgaon Infospace Limited SEZ, Ground Floor, Tower A, Building 2,
> Sector 21, Old Delhi-Gurgaon Road, Dundahera
> Gurgaon 122 016
> Haryana, India
> 
> desk  +91-124-676-7695
> mobile  +91-88-609-99936
> 
> The information transmitted is intended only for the person or entity to 
> which it is addressed and may contain confidential and/or privileged 
> material. Any review, retransmission, dissemination or other use of, or 
> taking of any action in reliance upon, this information by persons or 
> entities other than the intended recipient is prohibited. If you received 
> this in error, please contact the sender and delete the material from any 
> computer.
> 
> From: Roy Teeuwen [via Apache Sling] 
> [mailto:ml-node+s73963n4062546...@n3.nabble.com]
> Sent: Thursday, July 14, 2016 2:37 PM
> To: Vineet Kumar
> Subject: Re: One Resource to multiple views in different locations
> 
> Two components, as you can clearly see I said we have a component at 
> /apps/siteA/components/header and /apps/siteB/components/header
> 
>> On 14 Jul 2016, at 10:28, vkum14 <[hidden 
>> email]> wrote:
>> 
>> Sounds good. One quick qns- did you have 2 components or one component since
>> you seem to be playing around with resourcetype?
>> 
>> 
>> 
>> --
>> View this message in context: 
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062545.html
>> Sent from the Sling - Users mailing list archive at Nabble.com.
> 
> 
> ________
> If you reply to this email, your message will be added to the discussion 
> below:
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062546.html
> To unsubscribe from One Resource to multiple views in different locations, 
> click 
> here<http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4061093&code=dmt1bWFyMTRAc2FwaWVudC5jb218NDA2MTA5M3wyNTc5NzAxODA=>.
> NAML<http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> 
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062548.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



RE: One Resource to multiple views in different locations

2016-07-14 Thread vkum14
Yes but my use case demands to do the same with same component as to avoid 
defining a new component when more brands come onboard. Have you done that sort 
of something as well?

VINEET KUMAR
Sr. Specialist
-
SapientNitro
Gurgaon Infospace Limited SEZ, Ground Floor, Tower A, Building 2,
Sector 21, Old Delhi-Gurgaon Road, Dundahera
Gurgaon 122 016
Haryana, India

desk  +91-124-676-7695
mobile  +91-88-609-99936

The information transmitted is intended only for the person or entity to which 
it is addressed and may contain confidential and/or privileged material. Any 
review, retransmission, dissemination or other use of, or taking of any action 
in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any computer.

From: Roy Teeuwen [via Apache Sling] 
[mailto:ml-node+s73963n4062546...@n3.nabble.com]
Sent: Thursday, July 14, 2016 2:37 PM
To: Vineet Kumar
Subject: Re: One Resource to multiple views in different locations

Two components, as you can clearly see I said we have a component at 
/apps/siteA/components/header and /apps/siteB/components/header

> On 14 Jul 2016, at 10:28, vkum14 <[hidden 
> email]> wrote:
>
> Sounds good. One quick qns- did you have 2 components or one component since
> you seem to be playing around with resourcetype?
>
>
>
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062545.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062546.html
To unsubscribe from One Resource to multiple views in different locations, 
click 
here<http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4061093&code=dmt1bWFyMTRAc2FwaWVudC5jb218NDA2MTA5M3wyNTc5NzAxODA=>.
NAML<http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062548.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-14 Thread Roy Teeuwen
Two components, as you can clearly see I said we have a component at 
/apps/siteA/components/header and /apps/siteB/components/header


> On 14 Jul 2016, at 10:28, vkum14  wrote:
> 
> Sounds good. One quick qns- did you have 2 components or one component since
> you seem to be playing around with resourcetype?
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062545.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



Re: One Resource to multiple views in different locations

2016-07-14 Thread vkum14
Sounds good. One quick qns- did you have 2 components or one component since
you seem to be playing around with resourcetype?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062545.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-13 Thread vkum14
Sounds good. One quick qns- did you have 2 components or one component since 
you seem to be playing around with resourcetype?

Hey Vkum,

We had the exact same problem, two sites, siteA and siteB, where there was a 
livecopy from siteA to siteB, but siteB had some specific header and footer 
components and stuff like that. How we solved this is by creating a filter that 
went over the resources of the request and when we detected that there was a 
specific implementation of a component for siteB, then we force this supertype.

So for example you have /apps/siteA/components/header and 
/apps/siteB/components/header. If we are in siteB and we see that there is a 
resourceType on the exact same location as the siteA/components/header for 
siteB: siteB/components/header, then we replace it:
final RequestDispatcherOptions requestDispatcherOptions = new 
RequestDispatcherOptions();
requestDispatcherOptions.setForceResourceType(siteSpecificResourceType);
Greets
Roy

> On 13 Jul 2016, at 19:02, vkum14 <[hidden 
> email]> wrote:
>
> Ohhh now I see what you are saying. Makes sense for simple use cases but here 
> your breadcrumb is taking the responsibility of figuring out what script to 
> load. Consider for use cases where in you have to identify script based on 
> selector, extn etc, you will end up replicating what sling does very well. I 
> would like to leverage same capability here so if I could tell sling to use 
> scripts from different set of folders, nothing better than that.
>
> On Jul 13, 2016 9:23 PM, "Jason Bailey [via Apache Sling]" <[hidden 
> email] <mailto:[hidden 
> email]>> wrote:
>>
>> I've never needed to have the resource resolver select a different script.
>>
>> Referencing your example of breadcrumb.  I've had the main breadcrumb script 
>> import the specific implementation based on a configuration.
>>
>> /apps/www/components/breadcrumb/breadcrumb.jsp
>> /apps/www/components/breadcrumb/breadcrumb-site1.jsp
>> /apps/www/components/breadcrumb/breadcrumb-site2.jsp
>>
>> The main breadcrumb.jsp is always executed and within that script is the 
>> logic that determines which version of the breadcrumb we want to provide. At 
>> that point we pull in the relevant jsp to render the site specific markup.
>>
>> This keeps all your breadcrumb logic within a single structure. It also adds 
>> value in the form of being able to offer sites options on how they would 
>> like their breadcrumbs to look that could be controlled by configuration.
>>
>>
>>
>> -Original Message-
>> From: vkum14 [mailto:[hidden email]]
>> Sent: Wednesday, July 13, 2016 10:27 AM
>> To: [hidden email]
>> Subject: Re: One Resource to multiple views in different locations
>>
>> Hi Jason,
>>
>> I believe you are talking about css/js here while my use case is to have 
>> even different markups for the same component based on the site, it is being 
>> rendered. IMO, this is a typical use case of telling servletresourceresolver 
>> to pick different scripts based on the site input. Have you done some sorts 
>> of that?
>>
>>
>>
>> --
>> View this message in context: 
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html
>>  
>> <http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html>
>> Sent from the Sling - Users mailing list archive at Nabble.com 
>> <http://nabble.com/>.
>>
>>
>> ________
>> If you reply to this email, your message will be added to the discussion 
>> below:
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062524.html
>>  
>> <http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062524.html>
>> To unsubscribe from One Resource to multiple views in different locations, 
>> click here.
>> NAML
>
>
>
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062529.html
>  
> <http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062529.html>
> Sent from the Sling - Users mailing list archive at Nabble.com 
> <http://nabble.com/>.




If you reply to this email, your message will be added to the discussion below:
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062530.html
T

Re: One Resource to multiple views in different locations

2016-07-13 Thread Roy Teeuwen
Hey Vkum,

We had the exact same problem, two sites, siteA and siteB, where there was a 
livecopy from siteA to siteB, but siteB had some specific header and footer 
components and stuff like that. How we solved this is by creating a filter that 
went over the resources of the request and when we detected that there was a 
specific implementation of a component for siteB, then we force this supertype.

So for example you have /apps/siteA/components/header and 
/apps/siteB/components/header. If we are in siteB and we see that there is a 
resourceType on the exact same location as the siteA/components/header for 
siteB: siteB/components/header, then we replace it:
final RequestDispatcherOptions requestDispatcherOptions = new 
RequestDispatcherOptions();
requestDispatcherOptions.setForceResourceType(siteSpecificResourceType);
Greets
Roy
> On 13 Jul 2016, at 19:02, vkum14  wrote:
> 
> Ohhh now I see what you are saying. Makes sense for simple use cases but here 
> your breadcrumb is taking the responsibility of figuring out what script to 
> load. Consider for use cases where in you have to identify script based on 
> selector, extn etc, you will end up replicating what sling does very well. I 
> would like to leverage same capability here so if I could tell sling to use 
> scripts from different set of folders, nothing better than that.
> 
> On Jul 13, 2016 9:23 PM, "Jason Bailey [via Apache Sling]" 
>  <mailto:ml-node+s73963n4062524...@n3.nabble.com>> wrote:
>> 
>> I've never needed to have the resource resolver select a different script. 
>> 
>> Referencing your example of breadcrumb.  I've had the main breadcrumb script 
>> import the specific implementation based on a configuration. 
>> 
>> /apps/www/components/breadcrumb/breadcrumb.jsp 
>> /apps/www/components/breadcrumb/breadcrumb-site1.jsp 
>> /apps/www/components/breadcrumb/breadcrumb-site2.jsp 
>> 
>> The main breadcrumb.jsp is always executed and within that script is the 
>> logic that determines which version of the breadcrumb we want to provide. At 
>> that point we pull in the relevant jsp to render the site specific markup. 
>> 
>> This keeps all your breadcrumb logic within a single structure. It also adds 
>> value in the form of being able to offer sites options on how they would 
>> like their breadcrumbs to look that could be controlled by configuration. 
>> 
>> 
>> 
>> -Original Message- 
>> From: vkum14 [mailto:[hidden email]] 
>> Sent: Wednesday, July 13, 2016 10:27 AM 
>> To: [hidden email] 
>> Subject: Re: One Resource to multiple views in different locations 
>> 
>> Hi Jason, 
>> 
>> I believe you are talking about css/js here while my use case is to have 
>> even different markups for the same component based on the site, it is being 
>> rendered. IMO, this is a typical use case of telling servletresourceresolver 
>> to pick different scripts based on the site input. Have you done some sorts 
>> of that? 
>> 
>> 
>> 
>> -- 
>> View this message in context: 
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html
>>  
>> <http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html>
>> Sent from the Sling - Users mailing list archive at Nabble.com 
>> <http://nabble.com/>. 
>> 
>> 
>> 
>> If you reply to this email, your message will be added to the discussion 
>> below:
>> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062524.html
>>  
>> <http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062524.html>
>> To unsubscribe from One Resource to multiple views in different locations, 
>> click here.
>> NAML
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062529.html
>  
> <http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062529.html>
> Sent from the Sling - Users mailing list archive at Nabble.com 
> <http://nabble.com/>.



RE: One Resource to multiple views in different locations

2016-07-13 Thread vkum14
Ohhh now I see what you are saying. Makes sense for simple use cases but here 
your breadcrumb is taking the responsibility of figuring out what script to 
load. Consider for use cases where in you have to identify script based on 
selector, extn etc, you will end up replicating what sling does very well. I 
would like to leverage same capability here so if I could tell sling to use 
scripts from different set of folders, nothing better than that.

On Jul 13, 2016 9:23 PM, "Jason Bailey [via Apache Sling]" 
 wrote:
>
> I've never needed to have the resource resolver select a different script. 
>
> Referencing your example of breadcrumb.  I've had the main breadcrumb script 
> import the specific implementation based on a configuration. 
>
> /apps/www/components/breadcrumb/breadcrumb.jsp 
> /apps/www/components/breadcrumb/breadcrumb-site1.jsp 
> /apps/www/components/breadcrumb/breadcrumb-site2.jsp 
>
> The main breadcrumb.jsp is always executed and within that script is the 
> logic that determines which version of the breadcrumb we want to provide. At 
> that point we pull in the relevant jsp to render the site specific markup. 
>
> This keeps all your breadcrumb logic within a single structure. It also adds 
> value in the form of being able to offer sites options on how they would like 
> their breadcrumbs to look that could be controlled by configuration. 
>
>
>
> -Original Message- 
> From: vkum14 [mailto:[hidden email]] 
> Sent: Wednesday, July 13, 2016 10:27 AM 
> To: [hidden email] 
> Subject: Re: One Resource to multiple views in different locations 
>
> Hi Jason, 
>
> I believe you are talking about css/js here while my use case is to have even 
> different markups for the same component based on the site, it is being 
> rendered. IMO, this is a typical use case of telling servletresourceresolver 
> to pick different scripts based on the site input. Have you done some sorts 
> of that? 
>
>
>
> -- 
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html
> Sent from the Sling - Users mailing list archive at Nabble.com. 
>
>
> ____________
> If you reply to this email, your message will be added to the discussion 
> below:
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062524.html
> To unsubscribe from One Resource to multiple views in different locations, 
> click here.
> NAML



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062529.html
Sent from the Sling - Users mailing list archive at Nabble.com.


RE: One Resource to multiple views in different locations

2016-07-13 Thread Jason Bailey
I've never needed to have the resource resolver select a different script.

Referencing your example of breadcrumb.  I've had the main breadcrumb script 
import the specific implementation based on a configuration.

/apps/www/components/breadcrumb/breadcrumb.jsp
/apps/www/components/breadcrumb/breadcrumb-site1.jsp
/apps/www/components/breadcrumb/breadcrumb-site2.jsp

The main breadcrumb.jsp is always executed and within that script is the logic 
that determines which version of the breadcrumb we want to provide. At that 
point we pull in the relevant jsp to render the site specific markup. 

This keeps all your breadcrumb logic within a single structure. It also adds 
value in the form of being able to offer sites options on how they would like 
their breadcrumbs to look that could be controlled by configuration. 



-Original Message-
From: vkum14 [mailto:vkuma...@sapient.com] 
Sent: Wednesday, July 13, 2016 10:27 AM
To: users@sling.apache.org
Subject: Re: One Resource to multiple views in different locations

Hi Jason,

I believe you are talking about css/js here while my use case is to have even 
different markups for the same component based on the site, it is being 
rendered. IMO, this is a typical use case of telling servletresourceresolver to 
pick different scripts based on the site input. Have you done some sorts of 
that?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-13 Thread vkum14
Hi Jason,

I believe you are talking about css/js here while my use case is to have
even different markups for the same component based on the site, it is being
rendered. IMO, this is a typical use case of telling servletresourceresolver
to pick different scripts based on the site input. Have you done some sorts
of that?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-12 Thread Jason E Bailey
You have two distinct paths defined

/content/site1/en/home/breadcrumb.mobile.html
/content/site2/en/home/breadcrumb.mobile.html

I'm assuming that the output of the breadcrumb for these sites need to
be structurally different.

If you are building each site from scratch, or can modify the structure
of that site. Just use a different breadcrumb for what you want it to
do.

If you are using a stock or copied site  then I would suggest having the
component render itself differently depending on which site it's in and
then decide on a way to pass that information to the component.

Here are the ways that I know of getting that information to the
component without directly modifying the component.

1. The component scans up the page structure to look for the node
directly under content and  uses the site name (site1, site2) as the key
to the rendering. 
2. In AEM you would obtain the information from a design and set the
design for the site at the top level page ( site1, site2)
3. You would set a property on the top level site node (site1,site2) so
that you could use an InheritanceValueMap and locate the value that
determines the rendering style.

--
Jason


Re: One Resource to multiple views in different locations

2016-07-12 Thread vkum14
Thanks Jason for the response. I agree with you but my query was a little
different. Please allow me to explain this in detail:
*Scenarios:*
1. Consider following content structure
/content/site/en/home [cq:page]
  - breadcrumb [sling:resourceType=site/components/breadcrumb]
2. Consider following structure
/apps/site/components/breadcrumb
  - breadcrumb.jsp
  - mobile.jsp
/etc/site/components/breadcrumb
  - breadcrumb.jsp
  - mobile.jsp

Now if I want to render breadcrumb component using breadcrumb.jsp script, I
will just access url: /content/site/en/home/breadcrumb.html and to use
mobile.jsp script, url will be
/content/site/en/home/breadcrumb.mobile.html, since jsp extension has a
script engine defined. And I believe this is what you were also referring
to.

So far with me? To explain further, SlingServletResolver uses a
configuration "executionPath" to construct the folder where-in it has to
search for best match script using some weighted algorithm. So for example
if searchPath is [/apps, /libs, /etc], best script will be searched in
/apps/site/components/breadcrumb and then /libs/site/components/breadcrumb
and then /etc/site/components/breadcrumb. So Sling does a great job and help
me even separate views [I am talking about jsp files here] from component
definition. The only issue with this is that there is one-o-one mapping
between component and folder which can have these jsps. I have been trying
to figure out as to how I could manipulate executionpaths for a tenant vs.
another while both of them uses the same sling component. This will help us
leverage the same component across tenants but using different views/jsps as
per business need. So in short, I am trying following:

*Component Definition*
 /apps/site/components/breadcrumb

*Views/Scripts*
/etc/site/components/breadcrumb
   - breadcrumb.jsp
  -  mobile.jsp

/etc/site1/components/breadcrumb
   - breadcrumb.jsp
  -  mobile.jsp

/etc/site2/components/breadcrumb
   - breadcrumb.jsp
  -  mobile.jsp

Now I want that if /content/site1/en/home/breadcrumb.mobile.html is
fired, folders /etc/site1/components/breadcrumb &
/etc/site/components/breadcrumb be searched for best script match in this
order which means /etc/site1/components/breadcrumb/mobile.jsp to be used.
But if if /content/site2/en/home/breadcrumb.mobile.html is fired,
folders /etc/site2/components/breadcrumb & /etc/site/components/breadcrumb
be searched for best script match in this order which means
/etc/site2/components/breadcrumb/mobile.jsp to be used. I tried using
combination of ResourceDecorator and ResourceProvider with some success but
wanted to set experts view around the same.

Please let me know if this makes sense.



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062448.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-12 Thread vkum14
Thanks Bertrand and I completely agree. Just posted detailed query around the
same so please have a look and let me know if that makes sense.



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062450.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-12 Thread Bertrand Delacretaz
On Tue, Jul 12, 2016 at 3:56 PM, Jason E Bailey  wrote:
> ...When discussing different views for a resource, the key thing is that a
> URL should define one view. If you want a resource to be displayed in
> different ways, you want to modify the URL to be different. Either by
> extension or selector...

+1, that's how Sling sees things.

-Bertrand


Re: One Resource to multiple views in different locations

2016-07-12 Thread Jason E Bailey
My understanding of this is slightly different.

1.  The url specifies the resource.
2.  The extension defines which rendering engine handles this request
3.  It's the extension that uses the information in the resource to
determine the script/scripts to be executed, with the default html
engine utilizing the sling:resourceType to determine the execution
script

When discussing different views for a resource, the key thing is that a
URL should define one view. If you want a resource to be displayed in
different ways, you want to modify the URL to be different. Either by
extension or selector.

--
Jason

On Mon, Jul 11, 2016, at 01:20 PM, vkum14 wrote:
> I guess what Shivika is referring to as view is actually Script:
> In sling request, first resource is resolved and sling:resourceType
> property
> in that node is using by ServletResolver to identify the best script in
> the
> folder on path of sling:resourceType property value. Which actually
> results
> into one to one mapping between a component and the folder which contains
> the script. Is there a way where-in sling:resourceType can be an array in
> defined sequence of folders to be used by ServletResolver to find the
> script? Or any other idea might be ResourceMerger?
> 
> Hope that helps!
> 
> 
> 
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062395.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-11 Thread vkum14
I guess what Shivika is referring to as view is actually Script:
In sling request, first resource is resolved and sling:resourceType property
in that node is using by ServletResolver to identify the best script in the
folder on path of sling:resourceType property value. Which actually results
into one to one mapping between a component and the folder which contains
the script. Is there a way where-in sling:resourceType can be an array in
defined sequence of folders to be used by ServletResolver to find the
script? Or any other idea might be ResourceMerger?

Hope that helps!



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062395.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-04-27 Thread Robert Munteanu
Hi Shivika,

On Tue, 2016-04-26 at 03:27 -0700, shivika_sharma wrote:
> Is it possible for Sling to map one resource to multiple views. Say I
> have a
> component @ /apps//components/breadcrumb and this has multiple views
> under
> /etc/1/components/breadcrumb/view.jsp and
> /etc/2/components/breadcrumb/view.jsp, I want Sling to check if view
> is
> present in /etc/2 hierarchy then pick that one else pick the one in
> etc/1
> hierarchy . Is it possible to implement this with current Sling
> Resource
> Resolver ?

I am not sure I understand your question, what is a 'view' in the
scenario that you described?

Thanks,

Robert

> 
> Regards
> 
> Shivika
> 
> 
> 
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com
> /One-Resource-to-multiple-views-in-different-locations-tp4061093.html
> Sent from the Sling - Users mailing list archive at Nabble.com.



One Resource to multiple views in different locations

2016-04-26 Thread shivika_sharma

Is it possible for Sling to map one resource to multiple views. Say I have a
component @ /apps//components/breadcrumb and this has multiple views under
/etc/1/components/breadcrumb/view.jsp and
/etc/2/components/breadcrumb/view.jsp, I want Sling to check if view is
present in /etc/2 hierarchy then pick that one else pick the one in etc/1
hierarchy . Is it possible to implement this with current Sling Resource
Resolver ?

Regards

Shivika



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093.html
Sent from the Sling - Users mailing list archive at Nabble.com.