Thank you for your advice

I got rid of my CND file and created content using sling:resourceType. I
had the idea that defining my node structure somewhere would allow me to
create form dynamically to add subnodes.

So I've created two classes:
// Document.java
@Model(adaptables=Resource.class)
public class Document {

  @Inject @Named("jcr:title")
  private String title;

  @Inject
  private List<Resource> pages;
}

// Page.java
@Model(adaptables=Resource.class)
public class Page {

  @Inject @Named("jcr:title")
  private String title;

  @Inject
  private List<Resource> components;
}

But I don't see how to map them to a sling:resourceType. Is it with
getResourceType() like in here:
https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
?

Sling definitely has its own rhythm to it and I'm slow to pick it up :)



On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <[email protected]> wrote:

> Agreed, I would also highly suggest looking at Sling Models as an option to
> make your code more strongly typed without requiring a rigid node type
> structure:
> https://sling.apache.org/documentation/bundles/models.html
>
> On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <[email protected]>
> wrote:
>
> > My opinions:
> >
> > Sling is really about being able to take a data set and present that data
> > in multiple ways. For the vast majority of use cases you should use the
> > existing node types and property values and you don't need to  use a CND.
> >
> > A custom nodetype is useful if there is a need to perform some explicit
> > searching over a large set of data or if you absolutely require
> limitations
> > on properties that the existing nodetypes don't help with.
> >
> > Avoid trying to think of it in terms of other frameworks; Sling has its
> > own rhythm to it. You have a request that identifies a resource and then
> > that data is handed off to a renderer.  Using as much out of the box
> > functionality will give you the greatest flexibility.
> >
> >
> > -Jason
> >
> > -----Original Message-----
> > From: Guillaume Lucazeau [mailto:[email protected]]
> > Sent: Friday, November 13, 2015 8:01 AM
> > To: [email protected]
> > Subject: Resource class vs CND
> >
> > Hello,
> >
> > I'm currently studying Sling for a project, to store "documents"
> > containing pages, and components (image, text, maps, graphs etc.)
> >
> > While it seems to fit our needs perfectly, I'm a bit struggling to learn
> > some basic stuff before presenting a POC to our team.
> >
> > My first question would be: on what criteria should I choose to manage my
> > resources using a class extending AbstractResource or a nodetype
> definition
> > in a CND file? Do you have advice on it? I'm tending to use a class to
> keep
> > everything in Java, but I'm wondering if it's more/less/equally flexible,
> > and if it has drawbacks or benefits compared to a CND file.
> >
> > Thank you for every information you could give me
> >
> > Regards,
> > Guillaume
> >
>

Reply via email to