I am learning SalesForce Aura via the documentation provided on github. https://github.com/forcedotcom/aura

mvn archetype:generate -DarchetypeCatalog=http://repo.auraframework.org/libs-release-local/archetype-catalog.xml

However, I have run into a bit of a hitch. I would like to make some forms and try out some situations where I am posting data to the back end.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm

has some good advice for implementing that. However, within the provided example I noticed that all of the servlets are being called from compiled classes. I see no clear place to drop in a new controller to test out my code.

Is there an intended path where users learning from the official documentation can drop in server-side classes into the sample application? Alternatively, is there a guide for integrating Aura API into a known Java webframework (spring works!)

I searched for this information quite a bit, but didn't find anything listing out how to get Aura working with spring on a developer machine.

I did find:

http://blog.jeffdouglas.com/2015/03/13/tutorial-building-lightning-components-with-spring-15/

but it seems to assume you are coding up your controllers on a SF controlled server.

Maybe Aura is just not meant to be developed outside of the Salesforce provided environment? I could not find any 3rd party developed Aura applications.

How can I write a controller that will work on my machine for the test application? What folder would it go in within the test application?

It's in the manual, under the section Using Java (about page 151 at the time of this answer).

Basically, you write up a controller:

// Java
package org.auraframework.demo.controllers;

@Controller
public class SimpleServerSideController {
    //Use @AuraEnabled to enable client- and server-side access to the method
    @AuraEnabled
    public static String serverEcho(@Key("firstName")String firstName) {
        return ("From server: " + firstName);
    }
}

Then you link it into your component:

<!-- component code -->
<aura:component controller="java://org.auraframework.demo.controllers.SimpleServerSideController">

Then you just fire it off as normal:

// JavaScript controller method...
var action = cmp.get("c.serverEcho");
action.setParams({ firstName : cmp.get("v.firstName") });
action.setCallback( ... );
$A.enqueueAction(action);

I really suggest you read the manual, as this is something of a 30,000 foot view of doing it, since I don't have the time to rig up a server right now.

As you can see, it doesn't matter where you put the controller as long as it is in the correct physical location and associated with your component correctly.


Salesforce has intended this to be an OSS project, and I do see that there's about 150 forks of this, but I'm not sure if anyone outside of salesforce is using it. I might try it out and let you know how it goes, because it'd be pretty cool to have a lightning-esque website of my own.

  • But where folder wise does it reside in the template project? There's no mvc style file structure in the template project. I know what to write, just not where to put the files and how to recompile it all together. – baordog Jul 21 '16 at 22:35
  • And it can't be put anywhete, since the class path will be influenced by the location in the file structure. – baordog Jul 21 '16 at 22:37
  • @baordog it appears that "aura-impl/src/main/java/" is the root source path. I'd recommend probably "aura-impl/src/main/java/org/yourname/controllers/TestController.java" as a starting point. I'm going to see if I can get this running later today, since I've already accidentally forked the project. – sfdcfox Jul 21 '16 at 22:47
  • Also, how would you suggest I recompile the template project? I didn't see an ant script or anything to automate that process. – baordog Jul 22 '16 at 18:42
  • @baordog mvn clean install to build. You'll need Java 1.8 and Apache Maven to get that far. – sfdcfox Jul 22 '16 at 18:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.