Create your own application for Cyklotron 2
Here we will guide You through the process of creating new application in Cyklotron 2 environment. We choose simple forum application as an example.
Assumptions
- one forum per High Level Resource i.e. site
- many discussions in forum
- many messages in discussion in tree form for reply messages
- simple workflow based on moderation bit
- roles: administrator (manage and moderate discussions), participant(can post) and visitor (can read messages)
Prepare RML scripts
Create definition script your_app.rml and init script your_app-init.rml
Within cyklotron_core_api project create new scripts:
src/main/resources/rml/cyklotron/forum/forum.rml
src/main/resources/rml/cyklotron/forum/forum-registry.rml
Register forum as an available application for Site in file:
src/main/resources/rml/cyklotron/site/site-apps.rml
Register forum scripts in following files:
src/main/resources/rml/cyklotron/cyklotron-core-api.list
src/main/rml-sources.list
Generate Coral wrappers
Be sure you have setup your Cyklotron developer's workspace correctly.
Go to cyklotron_core_api project and run:
maven coral:generator
Goto you IDE, refresh content of cyklotron_core_api project and compile classes.
Create and register the Forum Manager component.
Manager component should keep all business logic for forum application. For more details see forum manager interface and its implementation in following classes:
cyklotron_core_api module: src/main/java/org/cyklotron/forum/ForumManager.java
cyklotron_core module: src/main/java/org/cyklotron/forum/DefaultForumManager.java
Register component in config container.xml
| Explanation We decided to use interface - implementation for future implementation modifications but You can write only implementation class and register it as a component. |
Implement custom methods in application definition class.
Add custom methods to ForumApplicationDefinitionImpl class. See all code added below the following line:
// @custom methods ///////////////////////////////////////////////////////
Once again regenerate Coral wrappers.
I18n
Add following entries with resource meta data translations to resource_en_US.xml
Icons and and resource images
Add following icons to webapp content subdirectories:
content/res-tree
- forum.ApplicationNode.gif
- forum.ApplicationNode-minus.gif
- forum.ApplicationNode-plus.gif
- forum.Discussion.gif
- forum.Discussion-minus.gif
- forum.Discussion-plus.gif
- forum.Message.gif
- forum.Message-minus.gif
- forum.Message-plus.gif
content/res-icons:
- forum.ApplicationNode.png
- forum.Discussion.png
- forum.Message.png
Run the application for the first time.
If you have your Cyklotron instance already installed you'll have to selectively run rml scripts described above.
For new instance simply run maven installator in cyklotron_webapp module:
maven init
Then:
- start tomcat
- login
- create new organization with enabled site application
- create new site with enabled forum application
All the work were done well if forum node appears in site tree and forum administrator and participant privileges are created!
Finishing the application UI
As You noticed forum application were successfully installed but You have nothing but forum application node created during site creation. All links in forum application does not work. Clicking on link add discussion you should see following stacktrace:
Error occured while rendering forum.AddDiscussion view. org.objectledge.web.mvc.builders.MissingViewException: originalViewName=forum.AddDiscussion,... org.objectledge.web.mvc.builders.BuilderExecutorValve.process(BuilderExecutorValve.java:159) org.objectledge.pipeline.ErrorHandlingPipeline.process(ErrorHandlingPipeline.java:83)
Now it's time to develop application UI: views, components and actions!
