cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best surf development configuration?

ojaro
Champ in-the-making
Champ in-the-making
Hi all,

Been spending my day getting frustrated with Surf. It seems like all documentation is badly out of date and tools such as Surf roo addon are badly out of date and therefore no longer work.

But I assume Surf is still very much being used since Alfresco itself it going strong?

Could someone advice what is the best way to go about a Surf development? People clearly cannot be using SpringSource Tool Suite/Roo route since that does not look like it has been maintained any longer. So what are people doing? Is the only way really to download Alfresco and start decoding the share application source code?

Sorry for so many questions. But have spent a day reading various documentations and they all seems to lead me to dead ends… Hopefully someone is able to share their knowledge on this.

Massive thanks already in advance,

Olli
11 REPLIES 11

ddraper
World-Class Innovator
World-Class Innovator
Hi Olli,

First of all, apologies that you've had so much frustration getting started with Surf development… you're right on both counts that it is very much alive and that regrettably the documentation is badly in need of being updated. The Spring Roo approach basically failed at the first hurdle due to a lack of Roo plugin documentation at the time (its possible that this has subsequently been improved) and there has not been any continued investment in the Roo development approach for a long time.  Surf itself is still based around Spring MVC so there could be some benefits to using the SpringSource Tool Suite but I typically make do with just a basic Eclipse IDE.

It would be helpful to know what you'd like to do with Surf …. for example, are you planning to write a standalone application? are you trying to customize Alfresco Share? or are you just trying to get a better understanding of how Alfresco uses it?

If you can provide some information on what you're trying to do then hopefully I'll be able to assist you,

Regards,
Dave

ojaro
Champ in-the-making
Champ in-the-making
Hi Dave,

Thank you so much for such a quick reply.

I have a requirement for a custom application development with its own database backend and ui. However, I want to run it within alfresco in order to leverage the user database/authentication as minimum, but potentially to also to use the templating or create some custom views in the share part of alfresco.

Regards

Olli 

ddraper
World-Class Innovator
World-Class Innovator
Hi Olli,

Its possible to create a completely custom UI on top of Share whilst retaining its user authentication and access to the repository through the REST API fairly simply (I've described how to do this in these blog posts: http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced-share-customization-part-1/ & http://blogs.alfresco.com/wp/ddraper/2011/11/03/advanced-share-customization-part-2/ which describe how to replace the login page and the home page so that you are effectively hiding Share).
You can use the Alfresco REST api to access the repository using the "remote" object provided to WebScripts:

var conn = remote.connect("alfresco");   // "alfresco" is the default configured endpoint name for the repositoryvar json = conn.get("/api/people");if (json.status == 200){   // Create JavaScript objects from the response   var obj = eval('(' + json + ')');   if (obj)   {      // Perform processing on the js objects      // set results into the model for the template      model.results = somearray;   }}‍‍‍‍‍‍‍‍‍‍‍‍‍

To write an application in Surf to work with Alfresco I'd recommend that you stick to using WebScripts (rather than say JSP or  FreeMarker) for rendering your Components. There are good resources on WebScripts here: http://wiki.alfresco.com/wiki/Web_Scripts

Essentially you need to define a Page object in Surf which contains a Template object which maps to a FreeMarker template which can optionally have Regions which are bound to Components each of which is rendered (typically by a WebScript, but could be JSP, FreeMarker or a custom renderer).

I know the above might seem a bit (unnecessarily!) complicated at first but its actually quite simple once you get used to it. Unfortunately you are stuck with basic editors for creating the Surf objects (Pages, Templates, etc) as there is no official tooling.

Taking a look at how Share works is probably not a bad place to start and using the SurfBug tool (http://blogs.alfresco.com/wp/ddraper/2011/08/31/surfbug/) to help you deconstruct it and locate the appropriate source files.

I guess the one thing to note is that using this approach you're limited to using the Alfresco REST api and therefore won't have any direct database access (at least none that I'm aware of) unless you write something custom so you'll just be storing data to the Alfresco repository (e.g. the database would only be used for managing rather than storing the content)… I could be wrong about this of course - I just work on the UI!

Hopefully this will be of some use - if there's any specific areas that you're struggling with then please post your questions on this forum and I'll do my best to answer them,

Regards,
Dave

ojaro
Champ in-the-making
Champ in-the-making
Hi Dave,

Thanks for these pointers. Will look through.

Regards,

Olli

edfarias
Champ in-the-making
Champ in-the-making
Hello!

I'm as well as Olli going through Surf Implementation. Dave's post was very helpful but I have a couple of questions:

-From the wiki I saw that Web Scripts were the implementation for Alfresco 3.2 (and backwards) and for newer versions Spring Surf  was  the core scrip technology used. But as Spring Surf can no longer work with newer version for Eclipse nor STS, that means that we have to try with WebScript?

-Is better to work with Eclipse by itself than trying STS IDE?

-Is roo scafolding implementation no longer used?

Appreciate any help on this, I might have some concepts mixed up here Smiley Very Happy

Thanks!
Daniel

ddraper
World-Class Innovator
World-Class Innovator
Hi Daniel,

Just to clarify… Spring Surf is built around WebScripts. My understanding is that the WebScripts and original (Alfresco) Surf libraries were forked into Spring with the intention of trying to enable developers to build standalone applications using it…  but in principle both Alfresco 3.2 and subsequent versions use WebScripts but from different libraries (i.e. internal Alfresco vs public Spring Surf) - although clearly there have been developments in the Spring Surf libraries since the code was forked.

Since Alfresco is built around the Spring framework there will be some benefits to using STS (e.g. editors specifically written to work with bean configuration) but there is really no point in attempting to use Roo to build Surf applications… I personally just use "vanilla" Eclipse for development.

Hopefully this answers your question,

Regards,
Dave

edfarias
Champ in-the-making
Champ in-the-making
Hello Dave,

Thanks a lot for your answer! and yes, now it makes sense. Certainly the 'public' Spring surf  version looks cool with all the implementation having Roo and STS plugins and else, but sadly it seems to be currently forgotten and no longer supported by newer versions so I failed trying to run the tutorials found on internet.

As it is my intention to use and customize newest Alfresco version for my company needs, then I must focus on work with just Eclipse newest version  and get the Alfresco SDK and WebScript jars and that it'll do it right?

Now it depends if I want to do templates with FreeMarker or just PHP or something like it I guess

Thanks again Dave for your help!

ddraper
World-Class Innovator
World-Class Innovator
Spring Surf has not been forgotten by any means. There is continued investment in the core features that are used by Alfresco Share and whilst these updates are used in builds found within Alfresco releases they aren't necessarily in the builds that are available to be downloaded from the Spring Surf website.  There has been no continued investment into the STS and Roo plugins so the benefits you gain from using STS will only be with regards to general Spring/Spring MVC development (bearing in mind that Spring Surf builds on top of the Spring MVC framework). You should have no realistic expectation of being able to develop Spring Surf applications using Roo or specific STS plug-in tooling.

I would certainly recommend using WebScripts (which make use of FreeMarker) rather than PHP as this is what Alfresco Share is developed with.

Regards,
Dave

edfarias
Champ in-the-making
Champ in-the-making
I'll take all that in account.

You have been of great help Dave!

Thanks.