Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Localtab Group
Localtab
activetrue
titleYAML
Code Block
languagejs
subApps:
  main: 
    class: info.magnolia.ui.framework.tools.ToolsSubAppDescriptor
    subAppClass: info.magnolia.ui.framework.tools.ToolsSubApp
    tools:
Localtab
titleJCR node
Advanced Tables - Table Plus
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse
Node nameValue

Mgnl n
subApps

 


Mgnl n
tools


Mgnl p
class

info.magnolia.ui.framework.tools.ToolsSubAppDescriptor

Mgnl p
subAppClass

info.magnolia.ui.framework.tools.ToolsSubApp

...

Localtab Group
Localtab
titleYAML
Code Block
languageyamlyml
urlhttps://git.magnolia-cms.com/projects/DOCUMENTATION/repos/toolssubapp-example/raw/src/main/resources/toolssubapp-example/apps/hello-tools-app.yaml?at=master
 
appClass: info.magnolia.ui.framework.app.BaseApp
label: Sample Tools
icon: icon-development-app
subApps:
  main:
    class: info.magnolia.ui.framework.tools.ToolsSubAppDescriptor
    subAppClass: info.magnolia.ui.framework.tools.ToolsSubApp
    tools:
      dashboard:
        presenterClass: info.magnolia.documentation.apps.toolssubapp.presenters.DashboardToolPresenter
      i18n:
        class: info.magnolia.ui.framework.tools.FormToolDefinition
        actions:
          reloadTranslations:
            implementationClass: info.magnolia.documentation.apps.toolssubapp.actions.ReloadTranslationsAction
      helloworld:
        class: info.magnolia.ui.framework.tools.FormToolDefinition
        presenterClass: info.magnolia.documentation.apps.toolssubapp.presenters.HelloWorldPresenter
        description: This is the hello world example for configured tools
        form:
          label: HWP
          tabs:
            - name: mainTab
              fields:
                - name: name
                  class: info.magnolia.ui.form.field.definition.TextFieldDefinition
                  required: true
        actions:
          commit:
            implementationClass: info.magnolia.documentation.apps.toolssubapp.actions.SayHelloAction
          reset:
            implementationClass: info.magnolia.documentation.apps.toolssubapp.actions.ResetFormAction
Localtab
titleJCR
Advanced Tables - Table Plus
heading0
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse
Node nameValue

Mgnl n
hello-tools-app

-

Mgnl p
appClass

info.magnolia.ui.framework.app.BaseApp

Mgnl p
label

Sample Tools

Mgnl p
icon

icon-development-app

Mgnl p
name

hello-tools-app

Mgnl n
subApps

 -

Mgnl n
main

 -

Mgnl p
class

info.magnolia.ui.framework.tools.ToolsSubAppDescriptor

Mgnl p
subAppClass

info.magnolia.ui.framework.tools.ToolsSubApp

Mgnl n
tools

-

Mgnl n
dashboard

 -

Mgnl p
presenterClass

info.magnolia.documentation.apps.toolssubapp.presenters.DashboardToolPresenter

Mgnl n
i18n

 -

Mgnl p
class

info.magnolia.ui.framework.tools.FormToolDefinition

Mgnl n
actions

-

Mgnl n
helloworld

 -

Mgnl p
class

info.magnolia.ui.framework.tools.FormToolDefinition

Mgnl p
presenterClass

info.magnolia.documentation.apps.toolssubapp.presenters.HelloWorldPresenter

Mgnl p
description

This is the hello world example for configured tools

Mgnl n
form

-

Mgnl n
actions

-
Note

Note that this example requires Java 1.8 or higher to run. You can download the .jar file here: 

Javadoc resource link
classNameinfo.magnolia.documentation
renderTypeasynchronous
. See Installing a module for help.

Properties:

<subapp name>

required

Subapp node name. This is the internal ID of the subapp. In this example it is main.

class

required

For a tools subapp must be info.magnolia.ui.framework.tools.ToolsSubAppDescriptor or a subclass.

Javadoc resource link
rangeHigherVersion5.7
classNameinfo.magnolia.ui.framework.tools.ToolsSubAppDescriptor
renderTypeasynchronous
defines a subapp with several tools.

subAppClass

required

For a tools subapp must be info.magnolia.ui.framework.tools.ToolsSubApp or a subclass.

Javadoc resource link
rangeHigherVersion5.7
classNameinfo.magnolia.ui.framework.tools.ToolsSubApp
renderTypeasynchronous
implements a subapp with several tools.

   tools

required

Map of ToolDefinition.

Tools are defined by 

Javadoc resource link
rangeHigherVersion5.7
classNameinfo.magnolia.ui.framework.tools.ToolDefinition
renderTypeasynchronous
(where you may have to define the presenter class that implements ToolPresenter ).

name

required

Name of the tool. In this example, there are three tools named dashboard, i18n and helloworld .

class

optional, default is info.magnolia.ui.framework.tools.ToolDefinition

presenterClass

required

Must implement 

Javadoc resource link
rangeHigherVersion5.7
classNameinfo.magnolia.ui.framework.tools.ToolPresenter
renderTypeasynchronous
.

...

 
Code Pro
languageyaml
sections%%(dashboard)%% - %%(DashboardToolPresenter)%%
urlhttps://git.magnolia-cms.com/projects/DOCUMENTATION/repos/toolssubapp-example/raw/src/main/resources/toolssubapp-example/apps/hello-tools-app.yaml?at=master

This is the custom presenter:

...

Expand
titleClick here to see DashboardToolPresenter
 
Code Pro
languagejava
firstline1
titleinfo.magnolia.documentation.apps.toolssubapp.presenters.DashboardToolPresenter
linenumberstrue
sections%%(package)%% -
urlhttps://git.magnolia-cms.com/projects/DOCUMENTATION/repos/toolssubapp-example/browse/src/main/java/info/magnolia/documentation/apps/toolssubapp/presenters/DashboardToolPresenter.java?at=master&raw

Note:


  • The presenter implements #start which returns the View.
  • The method uses Lambda expression. This is why the example requires Java 8 or higher.

i18n tool

The i18n tool has the value info.magnolia.ui.framework.tools.FormToolDefinition set for the class property. 

Javadoc resource link
rangeHigherVersion5.7
classNameinfo.magnolia.ui.framework.tools.FormToolDefinition
renderTypeasynchronous
(or actually its implementation 
Javadoc resource link
rangeHigherVersion5.7
classNameinfo.magnolia.ui.framework.tools.ConfiguredFormToolDefinition
renderTypeasynchronous
 ) provides a default presenterClass.

...

Expand
titleClick here to see ReloadTranslationsAction.java
Code Pro
languagejava
firstline1
titleReloadTranslationsAction.java
linenumberstrue
sections%%(public class)%% -
urlhttps://git.magnolia-cms.com/projects/DOCUMENTATION/repos/toolssubapp-example/browse/src/main/java/info/magnolia/documentation/apps/toolssubapp/actions/ReloadTranslationsAction.java?at=master&raw
 

Note:


  • You should inject the definition class in the constructor.
  • You can inject other components such as
    Javadoc resource link
    rangeHigherVersion5.7
    classNameinfo.magnolia.i18nsystem.TranslationService
    renderTypeasynchronous
    and
    Javadoc resource link
    rangeHigherVersion5.7
    classNameinfo.magnolia.ui.api.context.UiContext
    renderTypeasynchronous
    (lines 7-8).

...

Expand
titleClick here to see HelloWorldPresenter.java
Code Pro
languagejava
firstline1
titleHelloWorldPresenter.java
linenumberstrue
sections%%(public class)%% -
urlhttps://git.magnolia-cms.com/projects/DOCUMENTATION/repos/toolssubapp-example/browse/src/main/java/info/magnolia/documentation/apps/toolssubapp/presenters/HelloWorldPresenter.java?at=master&raw
 

Other tool implementation examples

...

You typically have to implement your own presenterClass to fulfill your requirements. However, extending FormToolPresenter may be a good starting point.