"You could probably use their tools to create bundles then just deploy the bundles to your sling instance."
Just need to say that using their tools in this manor may violate the developer edition's license agreement, I don't know. I'd still suggest looking into the product to help learn the language, but make sure you carefully read the license agreement before actually deploying bundles to sling. -----Original Message----- From: Mark Herman Sent: Thursday, July 07, 2011 9:04 AM To: users@sling.apache.org Subject: RE: Beginners question with Sling. In reference to ESP vs JSP: You may be able to use Day CRX (now Adobe) documentation as a resource. They have a series of blogs called "CRX Gems." Some are product specific but most are really just taking advantage of sling. http://dev.day.com/content/ddc/blog.html?_charset_=ISO-8859-1&query=crx+gems& main_entries_start=15&blog=search&y=0&x=0 Page back into newer topics as well. Here are some links that I have stashed away that may be of interest to you: http://dev.day.com/content/ddc/blog/2010/07/learning_about_espv.html https://cwiki.apache.org/SLING/scripting-variables.html http://www.lucamasini.net/Home/sling-and-cq5/accessing-relational-data-as-sli ng-restful-urls I recently looked into whether to go with ESP or JSP and decided to go with JSP for the following reasons: - JSP is more standard, easier for others to jump on a project - As you have found documentation for ESP is scarce. - I wasn't able to find any advantages of using ESP besides that the common sling objects are provided for you. In JSP you just have to include a taglib and call the call sling:define objects. - It seems the people who write/use the product tend to use JSP more and are starting to shy away from ESP. - IDE support should be a bit better with JSP I don't think there is anything wrong with ESP, but it just seems like it doesn't have any major advantage make it a must have. A couple of discussions I have found: http://www.mail-archive.com/users@sling.apache.org/msg01105.html http://tech.groups.yahoo.com/group/Day-Communique/message/2464 Sorry I can't help with your issues. As you probably have guessed most my experience is with Day/Adobe's product, so I suggest you may want to get a license for a developer edition of CRX. It's free (last i checked), and is basically a jackrabbit repository with sling on top plus their tools. They have an Eclipse ide with debugging, a node browser, and a web based ide. It's very easy to install, although you will need to register for a free license. Also note, eclipse ide is a separate download. You could probably use their tools to create bundles then just deploy the bundles to your sling instance. Good luck. -----Original Message----- From: Phil Rice [mailto:phil.rice.erud...@googlemail.com] Sent: Thu 7/7/2011 3:56 AM To: users@sling.apache.org Subject: Re: Beginners question with Sling. Thanks for the swift reply - I'll raise a bug about "Sling in 15 minutes" as soon as I can make a unit test to capture it. - I'm hoping someone can point me to a tutorial or reference materials for ESP. Playing with javascript through reflection is hard work! - Thanks for the idea of running Sling in the same OSGI container. I suspect that won't work for crowd sourcing (you want one central repository), but I think it would be an excellent way to learn how everything ties together - I was puzzled that PUT was the wrong method. As I understand it PUT is the mechanism to "create or replace" in REST. However I replaced the call to a post, and I just get internal server error 500s with nothing appearing in the logs. I will chase that down when I have sorted out the next point: - Assuming that there is a problem in my understanding in what is going on, I reduced to the simplest thing that could wrong and produced the following HTML page <html> <head><title>Testing</title></head> <body> <form action="http://localhost:8080/newNode1" method="post"> <label for="name1">Name1</label> <input type="text" id="name1" value="Value1" /><br /> <label for="name2">Name3</label> <input type="text" id="name2" value="Value2" /><br /> <label for="name3">Name4</label> <input type="text" id="name3" value="Value3" /><br /> <label for="name4">Name5</label> <input type="text" id="name4" value="Value4" /><br /> <button>Submit</button> </form> </body> </html> My hope is that when I click the button this would create newNode1 with attributes name1 = Value1 etc. And indeed (after logging in) it created newNode1. However when I examine the node created using the url http://localhost:8080/newNode1.json I find the following page: {"jcr:primaryType":"nt:unstructured"} However if I use curl -u admin:admin -F"name1=value1" -F"name2=value2" http://localhost:8080/newNodeQ1 And surf to http://localhost:8080/newNodeQ1.json I find {"name2":"value2","jcr:primaryType":"nt:unstructured","name1":"value1"} I would appreciate some advice on how to get the HTML to work similar to curl Thanks again for the help --------------- My software stack is: - Windows 7 64 bit - JDK1.6.0_24 - Eclipse Indigo Release build 20110615-0604 - I am using jar "org.apache.sling.launchpad.base.jar", which I downloaded earlier this week. - I am running the jar using Eclipse using only defaults (no VM arguments, no program arguments). The main method is from class org.apache.sling.launchpad.app.Main The console output from sling is 07.07.2011 07:54:18.570 *INFO* [main] Setting sling.home=sling (default) 07.07.2011 07:54:18.572 *INFO* [main] Starting Sling in sling (C:\Users\Phil\workspace\Sling\sling) 07.07.2011 07:54:18.620 *INFO* [main] Checking launcher JAR in folder sling 07.07.2011 07:54:18.640 *INFO* [main] Existing launcher is up to date, using it: 2.3.0 (org.apache.sling.launchpad.base.jar) 07.07.2011 07:54:18.642 *INFO* [main] Loading launcher class org.apache.sling.launchpad.base.app.MainDelegate from org.apache.sling.launchpad.base.jar 07.07.2011 07:54:18.662 *INFO* [main] Starting launcher ... 07.07.2011 07:54:18.666 *INFO* [main] HTTP server port: 8080 07.07.2011 07:54:20.736 *INFO* [main] Startup completed On Wed, Jul 6, 2011 at 11:02 PM, Justin Edelson <jus...@justinedelson.com>wrote: > > > On Jul 6, 2011, at 5:16 PM, Phil Rice <phil.rice.erud...@googlemail.com> > wrote: > > > Hello everyone. > > Hi > > > > > I have just downloaded Sling, and am very impressed with it. I am > planning > > on using it in conjunction with an Eclipse plugin to crowd source > > information about open source projects. > > Sounds interesting. Are you able to reuse code between the server side and > client side as both Sling and Eclipse are OSGi based? > > > > > I am having the usual teething problems that I get whenever I use an open > > source product, and I am hoping to get some assistance. I have spent > three > > days getting going, so I have tried quite a few combinations. > > > > Some general information for you "getting going with sling in 15 minutes" > > was very helpful. I have a version of Sling built from the source code > using > > Maven, and a second which is the standalone Jar. On both of them the > > following curl command didn't work: > > > > curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some > > title" http://localhost:8080/content/mynode > > > > > > I had to replace it with: > > > > > > curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some > > title" http://localhost:8080/mynode > > This should have worked. Can you file a bug report? > > > > > > > At the moment my Sling-fu is weak and I am not sure if this is some > > configuration problem. > > --------------- > > > > I am now at the point at which I feel the master of Sling (pride comes > > before a fall) using Curl, so I have moved to Java. I have tried a number > of > > Java libraries include the Apache HttpClient, http-unit and Rest-assured. > I > > am now at the point at which I can get information out of Sling that I > put > > in with Curl, but I am unable to programatically add it. Specifically I > can > > create the node, but the attributes do not appear. Fairly obviously I am > > missing some critical configuration > > > > So I have the following questions: > > > > - ESP looks very nice. Where can I find information on how to use it. I > > have found some samples using it, but have not been very successful in > > finding tutorials / reference material. > > - What is the Java side client software that you recommend for use with > > Sling, and do you have any example code? > > The majority of the Sling integration test suite is written with Apache > HttpClient 3.x. That's a good point if reference. > > > - Can you advise why the following code does not set param1=value1, > > param2=value2? > > > > You're doing a PUT. I'm assuming you are using the default servlets and the > functionality which accepts form parameters and sets node properties from > them is in the default POST servlet. Of course, you're free to write your > own servlet which accepts PUTs. > > HTH, > Justin > > > > import org.apache.http.*; > > public class PopulateRepository { > > public static void main(String[] args) throws Exception { > > BasicCredentialsProvider credentialsProvider = new > > BasicCredentialsProvider(); > > credentialsProvider.setCredentials(AuthScope.ANY, new > > UsernamePasswordCredentials("admin", "admin")); > > DefaultHttpClient client = new DefaultHttpClient(); > > client.setCredentialsProvider(credentialsProvider); > > > > String nodeName = "newNodeName"; > > List<NameValuePair> formParams = Arrays.<NameValuePair> asList(new > > BasicNameValuePair("param1", "value1"), new BasicNameValuePair("param2", > > "value2")); > > UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, > "UTF-8"); > > HttpPut action = new HttpPut("http://localhost:8080/" + nodeName); > > HttpResponse response = client.execute(action); > > }} > > > > Thanks for making such an interesting product > > >