如何在Magnolia应用程序中使用FreeMarker模板? [英] How to use a FreeMarker template in a Magnolia App?

查看:135
本文介绍了如何在Magnolia应用程序中使用FreeMarker模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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»方法>»


  1. 在导航中的某个位置创建常规页面。


  2. 打开配置应用程序,转到 / modules /< APP_NAME> / apps /< APP_NAME> / subApps / main 并将url属性添加到mainSubApp


  3. 更改类属性 / modules /< APP_NAME> / apps /的值< APP_NAME> / s ubApps / main info.magnolia.ui.framework.app.embedded.EmbeddedPageSubAppDescriptor


  4. subAppClass 属性的值更改为 info.magnolia.ui.framework.app.embedded.EmbeddedPageSubApp


  5. 如果您不希望该页面可见将其访问限制在超级用户组/角色中,以便只有管理员才能使用它。


这会将其与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»

  1. Create a regular page somewhere in your navigation.

  2. 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.

  3. Change value of the class property /modules/<APP_NAME>/apps/<APP_NAME>/subApps/main to info.magnolia.ui.framework.app.embedded.EmbeddedPageSubAppDescriptor

  4. Change the value of the subAppClass property to info.magnolia.ui.framework.app.embedded.EmbeddedPageSubApp

  5. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆