如何在Magnolia应用程序中使用FreeMarker模板? [英] How to use a FreeMarker template in a Magnolia App?
问题描述
我正在使用Magnolia 5.4,并已按照文档开发了一个应用程序:
https://documentation.magnolia-cms.com/display/DOCS54/Apps
该应用程序已在木兰外壳中正确呈现。
打开应用程序将显示文档中所述的 Hello World消息:
https://documentation.magnolia-cms.com/display/DOCS54/Programming+an+app#Programminganapp-MainSubApp
我已删除了不必要的代码,并最终得到了以下代码:
公共类HelloWorldMainSubAppViewImpl实现HelloWorldMainSubAppView {
private VerticalLayout layout = new VerticalLayout();
私人侦听器;
public HelloWorldMainSubAppViewImpl(){
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponent(new Label( Hello World!));
}
@Override
公共组件asVaadinComponent(){
返回布局;
}
}
我不想使用Label组件一个FreeMarker模板,我在其中定义了一个自定义视图。
通读了文档,但我还没有弄清楚如何做到这一点。
这是根据之前的工作所解决的问题。
这是« «自定义应用中所述的EmbeddedPageSubApp»方法>»
-
在导航中的某个位置创建常规页面。
-
打开配置应用程序,转到
/ modules /< APP_NAME> / apps /< APP_NAME> / subApps / main
并将url属性添加到mainSubApp -
更改类属性
/ modules /< APP_NAME> / apps /的值< APP_NAME> / s ubApps / main
到info.magnolia.ui.framework.app.embedded.EmbeddedPageSubAppDescriptor
-
将
subAppClass
属性的值更改为info.magnolia.ui.framework.app.embedded.EmbeddedPageSubApp
-
如果您不希望该页面可见将其访问限制在超级用户组/角色中,以便只有管理员才能使用它。
这会将其与iframe绑定在一起。您应该选择一个空白模板,因为嵌入式页面的导航元素在应用程序中可见。
I'm using Magnolia 5.4 and have developed an app following the documentation: https://documentation.magnolia-cms.com/display/DOCS54/Apps
The app is being rendered correctly in the magnolia shell. Opening the app shows a «Hello World» message as described in the documentation: https://documentation.magnolia-cms.com/display/DOCS54/Programming+an+app#Programminganapp-MainSubApp
I've removed the unnecessary code and ended up with this:
public class HelloWorldMainSubAppViewImpl implements HelloWorldMainSubAppView {
private VerticalLayout layout = new VerticalLayout();
private Listener listener;
public HelloWorldMainSubAppViewImpl() {
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponent(new Label("Hello World!"));
}
@Override
public Component asVaadinComponent() {
return layout;
}
}
Instead of using the Label component I would like to use a FreeMarker template where I define a custom view.
Having read through the documentation I haven't figured out yet how to do this.
Here is the solution to my problem, based on the previous work.
This is the «EmbeddedPageSubApp» approach as described under «Custom App»
Create a regular page somewhere in your navigation.
Open the Configuration app, go to
/modules/<APP_NAME>/apps/<APP_NAME>/subApps/main
and add a url property to the mainSubApp with an absolute path to the previously created page.Change value of the class property
/modules/<APP_NAME>/apps/<APP_NAME>/subApps/main
toinfo.magnolia.ui.framework.app.embedded.EmbeddedPageSubAppDescriptor
Change the value of the
subAppClass
property toinfo.magnolia.ui.framework.app.embedded.EmbeddedPageSubApp
If you don't want that page to be visible restrict its access within 'superuser' group / role so that only administrators can use it.
This binds that with an iframe. You should choose a blank template since the navigation elements of the embedded page are visible within the app.
这篇关于如何在Magnolia应用程序中使用FreeMarker模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!