The Gentics Portal | java provides handlers for the available Mesh plugins.
Mesh plugins usually register API endpoints of the form
[projectName]/plugins/[pluginName]/…, and the BasicPluginHandler can be used to easily create proxy handlers for
any custom plugins.
Basic plugin handler
The BasicPluginHandler can be used to easily create proxy handlers to forward requests from
/api/[pluginName]/* to the Mesh endpoint /api/v2/[projectName]/plugins/[pluginName]/*.
BasicPluginHandler instance// ...
private final PluginHandler customPluginHandler;
@Inject
public CustomBootstrapInitializer(
PortalConfig config,
Vertx vertx,
Provider<PortalHttpVerticle> verticleProvider,
MeshRestClient meshClient,
HandlerProvider handlerProvider) {
super(config, vertx, verticleProvider, meshClient);
this.customPluginHandler = new BasicPluginHandler(
"customPlugin",(1)
config,
true,(2)
handlerProvider);
}
@Override
public void start() {
// Other initializations.
deployHttpVerticles(router -> {
customPluginHandler.addRoutes(router);
});
}
| 1 | The name of the plugin (needed to create the proxy URLs) |
| 2 | The boolean parameter controls whether the plugin handler may use the admin token when the current request is
not authenticated. When this argument is false, the
request will be forwarded as anonymous. |
When more fine grained control over the created proxy handler is needed, the BasicPluginHandler constructor can
also be provided with an initialized proxy via new BasicPluginHandler("customPlugin", customProxy).
Available Mesh plugins
Gentics Portal | java already comes with handlers for the following commercial Gentics Mesh plugins, which just need to be
added in the BootstrapInitializer.
Comment plugin
The CommentsHandler will forward all requests for /api/comment/* to the Mesh endpoints
/api/v1/[projectName]/plugins/comment/*. Additional information can be found in the plugins
documentation.
Favorite plugin
The BasicPluginHandler can be used to forward all requests for /api/favorite/* to the Mesh endpoints
/api/v1/[projectName]/plugins/favorite/*. Additional information can be found in the plugins
documentation.
Forms plugin
configuration
When using poll forms add this configuration to the server.yml.
mesh:
proxyHeaderWhitelist:
- Referer
FormsHandler
The FormsHandler will forward all requests necessary to render forms, or submit data to forms to the Mesh
forms plugin. Endpoints for creating new forms are considered a backend functionality and will not be forwarded by the
portal.
The forms handler will also make sure, that the forms-data and forms-voted cookies are properly forwarded to
the plugin.
Rendering forms
The handler will also make the renderForm handlebars helper available, which is used to include the FormGen React Native app which does the actual rendering.
renderForm{{ renderForm form-uuid [language] [pluginName] [externalId] [templateContext] [showResults] }}
| Parameter | Type | Default value | Description |
|---|---|---|---|
|
String |
Mandatory |
The Mesh UUID of the form to be rendered |
|
String |
(empty) |
The desired language to render the given form |
|
String |
(empty) |
The Mesh plugin responsible for handling this form. |
|
String |
(empty) |
ID for forms not handled by the Mesh Forms plugin. |
|
String |
(empty) |
An additional template context which is appended to the base template path by the plugin when searching templates for rendering |
|
Boolean |
|
Only used by poll forms. When set to |
Rendering submitOnce results
Forms with the flag submitOnce set (which is for example used for poll forms, which a user can fill out once and then only sees the results of the poll) are rendered using a Handlebars template that is configurable under pollResultsTemplate (default is poll-results; note the missing extension). This Handlebars template is expected to be in the template path configured under templatesPath (default is data/templates). So with the default configuration, the Handlebars template is expected to have the path data/templates/poll-results.hbs. A simple example for such a template, can be found in the Implementation guides.
FormGen app
The FormGen app itself which must be built separately (see FormGen Customizing for details on the app) and the built app must be placed in the static data directory configured under forms.formgenStaticFileDirectory (which defaults to the path /portal/data/static/cpa/). The app is by default served by the portal under /static/cpa, if it is necessary to change this, the path is configurable in the portal configuration under forms.formgenStaticServePath.
Like plugin
The LikesHandler will forward all requests for /api/like/* to the Mesh endpoints
/api/v1/[projectName]/plugins/like/*. Additional information can be found in the plugins
documentation.
Search plugin
The BasicPluginHandler can be used to forward all requests for /api/search/* to the Mesh endpoints
/api/v1/[projectName]/plugins/search/*. Additional information can be found in the plugins
documentation.
