...
These
...
steps
...
outline
...
a
...
basic
...
approach
...
for
...
calling
...
the
...
Server
...
Configuration
...
Service
...
from
...
within
...
a
...
stock
...
Hello
...
World
...
application
...
created
...
using
...
the
...
...
...
...
...
...
...
.
...
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:
...
Code Block <div rsf:id="optional-block:"> You have set myPropertyString to "<span rsf:id="property-value">value</span>". </div>
...
- Add the following code to the producer HelloWorldProducer.java:
...
within
...
- the
...
- class
...
- itself:
...
Code Block
...
private ServerConfigurationService serverConfigurationService; public void setServerConfigurationService(ServerConfigurationService serverConfigurationService) { this.serverConfigurationService = serverConfigurationService; }
...
and
...
- within
...
- the
...
- fillComponents
...
- method:
...
Code Block
...
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:
...
Code Block
...
<property name="serverConfigurationService" ref="org.sakaiproject.component.api.ServerConfigurationService"/>
...
- Add the dependency to tool/project.xml
...
- (show
...
- them
...
- how
...
- to
...
- figure
...
- out
...
- the
...
- artifactId:
...
Code Block
...
<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.