The OpenCms Workplace in Version 10 will be rewritten using the popular Vaadin Framework. This new implementation also brings an improved interface to create Workplace extensions or “Apps” in OpenCms.
Apps in OpenCms 10 can be used for all kind of graphical Workplace extensions, for example to add use case specific management functions or to provide custom views on external data sources. By providing apps in OpenCms, developers can easily create Workplace dialogs and provide the content manager with a consistent user experience.
In this session, it is explained how to write apps for OpenCms 10. It is show what kind of configuration and extension points the new Workplace provides and how modules are created that extend the OpenCms user interface. It is also show how to migrate existing Workplace extensions to OpenCms 10.
3. ● Widget-based web GUI framework
● Only requires writing server-side Java code to
add new functionality
● UI actions trigger AJAX requests to the server
● UI is updated when response received
3
OpenCms Workplace with Vaadin
4. ● Why not GWT?
● No dynamic loading of new code
● Need to recompile everything for any change
● Slow compilation
● Vaadin is based on GWT, but
● Only need to recompile client code if you want to
add new widgets which aren‘t composed of
existing widgets
4
OpenCms Workplace with Vaadin
5. VerticalLayout layout = new VerticalLayout();
layout.addComponent(new Label("Foo"));
Button ok = new Button("OK");
layout.addComponent(ok);
ok.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
// do stuff
}
});
5
Vaadin – GUI in Java code
12. ● Icon
● Opens dialog when clicked
● Title (localizable)
● ID
● Can override other app with same ID
● App dialog can also be opened directly by URL
http://.../workplace#appid
● Order & Priority
● Category (currently only „Main“, „Legacy“)
12
App configuration class
13. ● Created by app configuration when user activates the
app
● Respond to URI fragment changes
● onStateChange
● Make use of forward / back buttons in browser
● Example: current site & folder in explorer app
● Responsible for initializing the UI
● Use I_CmsAppUIContext for showing widgets in specific
slots
13
App instance
15. ● Can use whole OpenCms API
● Get CmsObject for current user with
A_CmsUI.getCmsObject()
● Change part of fragment after app ID with
CmsAppWorkplaceUI.changeCurrentAppState(state)
15
API Access
16. ● Example: Git app
● Other apps currently hard-coded
● Using ServiceLoader mechanism to load app
configurations:
● Compile your classes and put them in a JAR
● JAR needs to contain the following file with the
class name(s) of your implementation(s):
● META-INF/services/org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration
● Copy JAR to WEB-INF/lib folder of OpenCms
instance, restart servlet container
16
Registering an app
17. ● Ported from existing JSP
● Which can still be seen in „old“ Administration
● Simple UI flow:
● Form fields are filled with presets, changable by
the user
● The user clicks on a button
● Some action is performed and the results are
presented to the user
17
Git App
19. ● Configure subclass of
I_CmsContextMenuItemProvider
● Acts as factory for I_CmsContextMenuItem
● Difference from „old“ context menu
configuration:
● No individual lists of menu options for each
resource type
● But context menu items can choose for which
resource types they should be displayed
19
Adding context menu items
21. ● Still missing:
● „Standard“ widgets for OpenCms specific functions
● user / group selection
● Multi-value input fields
● …
● Reports for long-running tasks
● Bookmarks for app states
● More extension points
● More convenience for the developer
21
// TODO