Latest Posts

Archives [+]

Categories [+]

Authors [+]

Another Sling Sample App

Here's another little example application that demonstrates how to use Apache Sling (and its underlying Java Content Repository). The app is called "Notes". It allows users to save a written note and attach a zip file to it. Notes can be edited which creates a new version (old versions remain in the repository). They can also be commented upon in a hierarchical way (i.e. comments can get comments again). Comments are also versioned. Finally, you can search through existing notes.

The app is packaged with CRX Quickstart's Package Manager. In order to install it just fire up the Package Manager and select Upload Package. This will install the scripts at /apps/notes as well as some initial content. After that just hit http://localhost:7402/content/notes.html.

Notes is designed to show off a number of JCR/Sling features like hierarchical storage, binary data storage, search, versioning and Ajax (via JSON). The latter will be visible in the search results page: the Quick View link that appears behind a search result retrieves the comments thread on the fly using Sling's built-in JSON renderer (try search term "jcr"). Comment versioning will become apparent when you edit an existing comment: there will be a new link "old versions".

A quick tour of the code

The front page is rendered by html.jsp. In there, child nodes are retrieved and rendered directly (by accessing their properties) The real Sling way is shown in the thread view (file thread.jsp): child nodes are rendered by using sling.include and the selector "detail". For this, the file detail.jsp is invoked recursively down the comment tree.

Posting new threads and comments is handled by POST.jsp. I decided to implement this a) for instructive reasons and b) because I wanted all nodes to be versionable (so I add the mixins mix:versionable and mix:referenceable to new nodes).

search.jsp demonstrates how to perform a search over the content repository and how to retrieve and use nodes via JSON. The URL /path/to/node.-1.json will rerurn the full sub tree below a node.

I gave up on my attempt to write a css file. The one that is included is from bluerobot.com. If you want to delete the initial content make sure that there is still a node left at /content/notes. This is assumed by the app (like many other things). In fact, this is not to be considered a real app, but just a sample to get you started with content-centric apps on Sling. Hence, it includes some sub-optimal aspects (feel free to fix them...): node UUIDs are exposed as anchors, node names are ugly and file uploads are not mime-type aware (there is probably more).

 
(optional)
12 comments
Nice sample code, including XPATH queries. I wouldn't call it elegant, rather JSP-vanilla, but it's good to have a sample from the sling source anyway!

Thanks to Michael!
0 Replies » Reply
this just looks like JSP together with JCR...
0 Replies » Reply
WOW! nice tutorial! that's what I exactly need. You are explaining in such a simple and straightforward! why others can't do it as you've done? may be it's a talent... thanx a lot!
0 Replies » Reply
Andreas Hartmann
Andreas Hartmann January 28, 2009 9:58 AM
Hi Michael,

does the example application also work with plain sling (without the CRX package manager)? If yes, how do I install it?

TIA!
0 Replies » Reply
I just found the corresponding patch in the Sling issue tracker and go on from there.
0 Replies » Reply
Hi Andreas,
yup, here's the best place to look at if you want to run the app in Sling: https://issues.apache.org/jira/browse/SLING-572
Michael
0 Replies » Reply
Is there any way to make new nodes versionables using the SlingPostServlet?

I don't want to overwrite the POST.

Any idea?
0 Replies » Reply
Hello!
Your site is in our list of resourses where we posting our partners links in advertising aims. If you don't want to get our posts, please e-mail us at tyro73fa1@yahoo.ca with Theme:Delete. Write in letter your hosts and it will be deleted from our list.
Thank you.
0 Replies » Reply
for overdose I to patient ancer higher overnight glycol, tramahexal tablets , zcklp,
0 Replies » Reply
to Mineral The sent liquid able to It gradually tab, tramal sr 100mg , =-(((,
0 Replies » Reply
ultram lexapro tramadol (Ultram, Ultram ER) Drug Information by tramadol hcl tab 50mg Tramadol is a man-made (synthetic) analgesic (pain reliever). tramadol prescription drug Its exact mechanism of action is unknown but similar morphine. is tramadol a narcotic Like morphine, tramadol binds to receptors in the brain tramadol pregnancy (opioid receptors) that are important for transmitting the tramadol pain medication sensation of pain from throughout the body to. Tramadol, ultram vs hydrocodone like other narcotics used for the treatment of pain, ultram snorting may be abused. Tramadol is not a nonsteroidal buy cheap ultram online antiinflammatory drug (NSAID) and does not have the tramadol rash increased risk of stomach ulceration and internal bleeding what type of drug is tramadol that can occur with NSAIDs. Erowid Experience Vaults: zydol overdose Pharms - Tramadol (also Ultram) Main IndexMethadone, tramadol side effects dogs Tramadol, Propoxyphene, Hydrocodone & Oxycodone, tramadol 50 mg hcl Heroin, AMT & 2C-C UND POLICE | The University of tramadol or hydrocodone North Dakota The police officers on the UND police cheap tramadol online overnight delivery staff have full arrest powers and are licensed by the tramadol pain relief State of North Dakota. The UND Police provide vehicle what is tramadol used for in dogs patrol 24 hours a day year-round and foot and bicycle tramadol medicine for dogs patrols when weather and manpower conditions permit. ultram schedule UND Police report violations of University regulations canine tramadol dosage and enforce state laws. Initial criminal reports, investigations tramadol experiences and cases are developed for prosecution. The UND Police tramadol order are armed and maintain contact with PSAP tramadol hcl acetaminophen (Public Service Answering Point). Student security ultram zoloft (student employees under the supervision of UND Police) tramadol effects of assist UND Police during the evening hours by checking tramal buy exterior doors, vehicles parked in UND parking lots and
0 Replies » Reply