These steps outline a basic approach for calling the Server Configuration Service from within a stock Hello World application created using the Sakai App Builder plugin for eclipse. The Server Configuration Service provides information about the server itself, including any custom properties used by our application.
- Create a new RSF Hello World app using the App Builder.
- Add the component-api to the build path.
- Add the following code to the template tool/src/webapp/templates/HelloWorld.html:
Unknown macro: {cod<div rsf}
- Add the following code to the producer HelloWorldProducer.java:
within the class itself:and within the fillComponents method:private ServerConfigurationService serverConfigurationService; public void setServerConfigurationService(ServerConfigurationService serverConfigurationService) { this.serverConfigurationService = serverConfigurationService; }
User currentUser = userDirectoryService.getCurrentUser(); UIOutput.make(tofill, "current-displayname", currentUser.getDisplayName()); UIOutput.make(tofill, "current-email", currentUser.getEmail());
- Add the injection to the requestContext.xml:
<property name="serverConfigurationService" ref="org.sakaiproject.component.api.ServerConfigurationService"/>
- Add the dependency to tool/project.xml (show them how to figure out the artifactId:
<dependency> <groupId>sakaiproject</groupId> <artifactId>sakai-user-api</artifactId> <version>${sakai.version}</version> </dependency> <dependency> <groupId>sakaiproject</groupId> <artifactId>sakai-component-api</artifactId> <version>${sakai.version}</version> </dependency>
- Compile and test.
Download the full source code for the completed exercise if you want to see the results in action.