You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Unmesh Joshi <un...@gmail.com> on 2010/12/03 07:50:01 UTC

Questions about sling and Day CQ

Hi,

I am trying to learn apache sling and have following questions to start with

I assume that resource resolvers need to be added as OSGI bundles.
Where does the view part (JSPs etc) fit in? I am not clear on few
things yet.

1. One a resource is resolved by resource resolver. How the final
representation (HTML in our case) is rendered? Where do you place
actual JSPs etc?
2. If I have to submit some information.. How is POST handled?
3. How are Day CQ and Sling related? Because we are unable to get dev
licenses for Day CQ. Is it worth doing spikes on Apache sling and
assume that the same thing will fit in Day CQ?

Do we have any sample source code that you can share for these things?

Thanks,
Unmesh

Re: Questions about sling and Day CQ

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Sun, Dec 5, 2010 at 8:52 AM, Unmesh Joshi <un...@gmail.com> wrote:
> ...I do not get any support for DI the way MVC frameworks like spring-mvc
> or struts provide. So I need to write custom servlets for all the
> resources and somehow integrate with Dependency injection framework....

Forgot to answer that bit...Sling is based on OSGi which should
provide all you need in terms of assembling software components. We do
not speak of MVC in Sling as our interaction model is that of the Web,
but once you understand how Sling processes requests it's not too
different in the end.

-Bertrand

Re: Questions about sling and Day CQ

Posted by Justin Edelson <ju...@justinedelson.com>.

On Dec 6, 2010, at 3:56 AM, Bertrand Delacretaz <bd...@apache.org> wrote:

> Hi,
> 
> To me, and without deep knowledge of either Spring MVC or Struts,
> running those in distinct webapps and collaborating with the Sling app
> might be the less risky option.
> 
> -Bertrand

Just wanted to echo Bertrand here. Using Sling and SpringMVC in the same webapp is setting yourself up for a world of hurt. There's nothing wrong, however, with using SpringDM, Gemini, or Aries Blueprint (or Peaberry  for that matter) in the Sling app if you really need that style of dependency injection. But try DS... you might like it :) 

Justin

Re: Questions about sling and Day CQ

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Sun, Dec 5, 2010 at 8:52 AM, Unmesh Joshi <un...@gmail.com> wrote:
> I my example a valid thing to do in apache sling? Because nothing
> there is a JCR resource node.. So I probably need to write a custom
> resource resolver which resolves my application urls to resources and
> then write a servlet which acts on these resources...

IIUC your examples has two main parts:

1) Login to Sling using credentials coming from an external system
For this you might want to study how Sling authentication works, start
at http://sling.apache.org/site/authentication.html

There should be sufficient extension points to plugin any type of
authentication.

2) Displaying user profiles that mix Sling data with external data
As you say, you could implement a resource resolver for the external
data, that's the most integrated way of doing it.

You could also just call up that data on demand, from the script or
servlet that does the rendering of the user profile, and just
integrate the external data in the rendered output.

> ...The tricky bit is
> I do not get any support for DI the way MVC frameworks like spring-mvc
> or struts provide. So I need to write custom servlets for all the
> resources and somehow integrate with Dependency injection framework....

>
> If I have an existing application that uses spring-mvc or struts..
> There is no way to fit that on Day CQ then?...

We do not answer questions specific to Day CQ here. About "fitting
such apps on Sling", I guess it depends how much integration you need.
To me, and without deep knowledge of either Spring MVC or Struts,
running those in distinct webapps and collaborating with the Sling app
might be the less risky option.

-Bertrand

Re: Questions about sling and Day CQ

Posted by Unmesh Joshi <un...@gmail.com>.
I my example a valid thing to do in apache sling? Because nothing
there is a JCR resource node.. So I probably need to write a custom
resource resolver which resolves my application urls to resources and
then write a servlet which acts on these resources. The tricky bit is
I do not get any support for DI the way MVC frameworks like spring-mvc
or struts provide. So I need to write custom servlets for all the
resources and somehow integrate with Dependency injection framework.

If I have an existing application that uses spring-mvc or struts..
There is no way to fit that on Day CQ then?


On Sat, Dec 4, 2010 at 11:12 AM, Unmesh Joshi <un...@gmail.com> wrote:
> I want to try following example, which is in nutshell how our application is
>
> User Login And Profile
>
> 1. User sends a GET request to http://sample.com/login
> 2. System renders a login form
>        I expect to write a JSP using some tag libraries. Do I put it
> in /apps folder?
>        BTW.. where is the /apps folder in sling installation? I am
> missing some very basic thing here.
> 3. User makes a POST request to http://sample.com/login with her login
> credentials.
> 4. System validates user by comparing password in the database.
>       I expect to write some spring/hibernate code here to validate
> user against database. How do I package that with sling?
> 5. If its a valid user system sends a Redirect (HTTP 303) to
> http://sample.com/profile/{userid}
>       How do I send redirects in sling?
> 6  Browser sends a GET request to http://sample.com/profile/{userid}
> (This is typical POST-REDIRECT-GET)
> 7 System makes a external web service call to fetch user profile
>    We have a central system which stores user profiles etc. I need to
> use something like CXF to make this call.
> 8. System renders profile html.
>
> Step 8 might have some more interesting issue in our case. We might
> want some part of the profile page to be content managed. So all the
> profile information will come from backend system, but I want a
> portion of the page to be content managed in Day CQ.
>
> I will get great if someone can help me understand how do I fit above
> use case in sling..
>
> Thanks,
> Unmesh
>
> On Fri, Dec 3, 2010 at 2:36 PM, Vidar Ramdal (Kolibri)
> <ko...@idium.no> wrote:
>> On Fri, Dec 3, 2010 at 7:50 AM, Unmesh Joshi <un...@gmail.com> wrote:
>>> I am trying to learn apache sling and have following questions to start with
>>>
>>> I assume that resource resolvers need to be added as OSGI bundles.
>>> Where does the view part (JSPs etc) fit in? I am not clear on few
>>> things yet.
>>>
>>> 1. One a resource is resolved by resource resolver. How the final
>>> representation (HTML in our case) is rendered? Where do you place
>>> actual JSPs etc?
>>
>> They are placed in the resource tree (either in the JCR repository) or
>> as bundle resources, under /apps.
>> The resource type of the requested resource is used to determine which
>> script/servlet to use for rendering.
>> See the Request Handling section at
>> http://sling.apache.org/site/the-sling-engine.html, and especially the
>> "Servlets and Scripts" page.
>>
>>> 2. If I have to submit some information.. How is POST handled?
>>
>> By default POST requests are handled by the SingPostServlet, which
>> takes care of persisting the changes.
>> See http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
>>
>>> 3. How are Day CQ and Sling related? Because we are unable to get dev
>>> licenses for Day CQ. Is it worth doing spikes on Apache sling and
>>> assume that the same thing will fit in Day CQ?
>>
>> I don't work for Day, so I'll leave this to someone who can better
>> answer your question.
>>
>>> Do we have any sample source code that you can share for these things?
>>
>> --
>> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
>> Sommerrogata 13-15, N-0255 Oslo, Norway
>> + 47 22 00 84 00 / +47 22 00 84 76
>> Quando omni flunkus moritatus!
>>
>

Re: Questions about sling and Day CQ

Posted by Unmesh Joshi <un...@gmail.com>.
I want to try following example, which is in nutshell how our application is

User Login And Profile

1. User sends a GET request to http://sample.com/login
2. System renders a login form
        I expect to write a JSP using some tag libraries. Do I put it
in /apps folder?
        BTW.. where is the /apps folder in sling installation? I am
missing some very basic thing here.
3. User makes a POST request to http://sample.com/login with her login
credentials.
4. System validates user by comparing password in the database.
       I expect to write some spring/hibernate code here to validate
user against database. How do I package that with sling?
5. If its a valid user system sends a Redirect (HTTP 303) to
http://sample.com/profile/{userid}
       How do I send redirects in sling?
6  Browser sends a GET request to http://sample.com/profile/{userid}
(This is typical POST-REDIRECT-GET)
7 System makes a external web service call to fetch user profile
    We have a central system which stores user profiles etc. I need to
use something like CXF to make this call.
8. System renders profile html.

Step 8 might have some more interesting issue in our case. We might
want some part of the profile page to be content managed. So all the
profile information will come from backend system, but I want a
portion of the page to be content managed in Day CQ.

I will get great if someone can help me understand how do I fit above
use case in sling..

Thanks,
Unmesh

On Fri, Dec 3, 2010 at 2:36 PM, Vidar Ramdal (Kolibri)
<ko...@idium.no> wrote:
> On Fri, Dec 3, 2010 at 7:50 AM, Unmesh Joshi <un...@gmail.com> wrote:
>> I am trying to learn apache sling and have following questions to start with
>>
>> I assume that resource resolvers need to be added as OSGI bundles.
>> Where does the view part (JSPs etc) fit in? I am not clear on few
>> things yet.
>>
>> 1. One a resource is resolved by resource resolver. How the final
>> representation (HTML in our case) is rendered? Where do you place
>> actual JSPs etc?
>
> They are placed in the resource tree (either in the JCR repository) or
> as bundle resources, under /apps.
> The resource type of the requested resource is used to determine which
> script/servlet to use for rendering.
> See the Request Handling section at
> http://sling.apache.org/site/the-sling-engine.html, and especially the
> "Servlets and Scripts" page.
>
>> 2. If I have to submit some information.. How is POST handled?
>
> By default POST requests are handled by the SingPostServlet, which
> takes care of persisting the changes.
> See http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
>
>> 3. How are Day CQ and Sling related? Because we are unable to get dev
>> licenses for Day CQ. Is it worth doing spikes on Apache sling and
>> assume that the same thing will fit in Day CQ?
>
> I don't work for Day, so I'll leave this to someone who can better
> answer your question.
>
>> Do we have any sample source code that you can share for these things?
>
> --
> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 22 00 84 76
> Quando omni flunkus moritatus!
>

Re: Questions about sling and Day CQ

Posted by "Vidar Ramdal (Kolibri)" <ko...@idium.no>.
On Fri, Dec 3, 2010 at 7:50 AM, Unmesh Joshi <un...@gmail.com> wrote:
> I am trying to learn apache sling and have following questions to start with
>
> I assume that resource resolvers need to be added as OSGI bundles.
> Where does the view part (JSPs etc) fit in? I am not clear on few
> things yet.
>
> 1. One a resource is resolved by resource resolver. How the final
> representation (HTML in our case) is rendered? Where do you place
> actual JSPs etc?

They are placed in the resource tree (either in the JCR repository) or
as bundle resources, under /apps.
The resource type of the requested resource is used to determine which
script/servlet to use for rendering.
See the Request Handling section at
http://sling.apache.org/site/the-sling-engine.html, and especially the
"Servlets and Scripts" page.

> 2. If I have to submit some information.. How is POST handled?

By default POST requests are handled by the SingPostServlet, which
takes care of persisting the changes.
See http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html

> 3. How are Day CQ and Sling related? Because we are unable to get dev
> licenses for Day CQ. Is it worth doing spikes on Apache sling and
> assume that the same thing will fit in Day CQ?

I don't work for Day, so I'll leave this to someone who can better
answer your question.

> Do we have any sample source code that you can share for these things?

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 22 00 84 76
Quando omni flunkus moritatus!

Re: Questions about sling and Day CQ

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Dec 3, 2010 at 5:46 PM, Richard Frovarp <rf...@apache.org> wrote:
>... Is your Slingbucks project going to end up in samples? It would be quite
> helpful as a starting point for a project we're trying to figure out how to
> best do....

Yes, it's on my (long) list of (belated) things to do...hopefully in
the next few days.
-Bertrand

Re: Questions about sling and Day CQ

Posted by Richard Frovarp <rf...@apache.org>.
On 12/03/2010 03:19 AM, Bertrand Delacretaz wrote:

>
>>
>> Do we have any sample source code that you can share for these things?...
>
> There are some samples at
> http://svn.apache.org/repos/asf/sling/trunk/samples/ , I recommend
> starting with the espblog sample.
>
> -Bertrand

Is your Slingbucks project going to end up in samples? It would be quite 
helpful as a starting point for a project we're trying to figure out how 
to best do.

Richard

Re: Questions about sling and Day CQ

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Umesh,

On Fri, Dec 3, 2010 at 7:50 AM, Unmesh Joshi <un...@gmail.com> wrote:
> ...I assume that resource resolvers need to be added as OSGI bundles.
> Where does the view part (JSPs etc) fit in? I am not clear on few
> things yet....

http://sling.apache.org/site/discover-sling-in-15-minutes.html should
help, that shows how rendering works.

> ...3. How are Day CQ and Sling related? Because we are unable to get dev
> licenses for Day CQ. Is it worth doing spikes on Apache sling and
> assume that the same thing will fit in Day CQ?...

CQ5 runs on Sling, so most of the things you try with Sling will work
there and it's a good way of learning the basic principles.

However, CQ5 provides lots of additional tools, for example to manage
"CQ5 components" which group together editing, rendering and other
functionality for blocks of content.

>
> Do we have any sample source code that you can share for these things?...

There are some samples at
http://svn.apache.org/repos/asf/sling/trunk/samples/ , I recommend
starting with the espblog sample.

-Bertrand

Re: Questions about sling and Day CQ

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 03.12.10 07:50, "Unmesh Joshi" <un...@gmail.com> wrote:
>3. How are Day CQ and Sling related? Because we are unable to get dev
>licenses for Day CQ. Is it worth doing spikes on Apache sling and
>assume that the same thing will fit in Day CQ?

CQ's rendering is done by Sling, so all the things you learn in (core)
Sling can be applied to CQ.

Otherwise CQ provides "more" in many aspects, like providing a component
model, that itself uses the normal sling:resourceType for rendering. And
all the features and UI you need for a proper WCM, of course.

Regards,
Alex

-- 
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel