代码之家  ›  专栏  ›  技术社区  ›  geco17

Liferay 7.1 B3在片段中嵌入Portlet

  •  0
  • geco17  · 技术社区  · 7 年前

    我在尝试 liferay 7.1 b3 我想在页面片段中嵌入一个portlet。我看了一看最新的可用文档 here ,也就是说,为了在页面片段中嵌入portlet小部件,我所要做的就是添加

    "com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet"
    

    中的属性 @Component 属性,在本例中,别名( my-custom-portlet )是我将用于在片段中包含portlet的别名。

    然后在我的自定义页面片段中,我必须包括 lfr-widget 标记的后缀由 com.liferay.fragment.entry.processor.portlet.alias 性质。所以在我看来 <lfr-widget-my-custom-portlet /> .

    问题是我甚至不能用上面的代码创建页面片段。我得到以下错误:

    没有可用于alias my custom portlet的小部件。

    另一方面,如果我使用liferay portlet(例如 <lfr-widget-nav/> 在他们自己的示例中)nav portlet被正确显示。还有人试过吗?任何反馈都将不胜感激。

    1 回复  |  直到 7 年前
        1
  •  0
  •   geco17    7 年前

    我解决了。有两件事要考虑。

    首先,我用eclipse生成了mvc portlet,它将旧版本的内核依赖项放在build.gradle文件中。我把它们改成:

    compileOnly group: 'com.liferay.portal', name: 'com.liferay.portal.kernel', version: '3.0.1'
    compileOnly group: 'com.liferay.portal', name: 'com.liferay.util.taglib', version: '3.0.0'
    

    第二,在portlet的 @Component 中的批注 property { ... } 我添加的列表:

    "com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet",
    "com.liferay.portlet.application-type=widget",
    "com.liferay.portlet.application-type=full-page-application",
    "javax.portlet.name=my-custom-portlet",
    

    除了已经存在的东西。

    所以在我看来 @组件 看起来像

    @Component(
        immediate = true,
        property = {
            "com.liferay.portlet.display-category=category.sample",
            "com.liferay.portlet.instanceable=true",
            "javax.portlet.display-name=my-custom-portlet Portlet",
            "javax.portlet.init-param.template-path=/",
            "javax.portlet.init-param.view-template=/view.jsp",
            "javax.portlet.resource-bundle=content.Language",
            "javax.portlet.security-role-ref=power-user,user",
            "javax.portlet.name=my-custom-portlet",
            "com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet",
            "com.liferay.portlet.application-type=widget",
            "com.liferay.portlet.application-type=full-page-application",
            "com.liferay.portlet.add-default-resource=true"
        },
        service = Portlet.class
    )
    public class MyCustomPortlet extends MVCPortlet {
    

    以及 build.gradle 文件看起来像

    dependencies {
        compileOnly group: 'com.liferay.portal', name: 'com.liferay.portal.kernel', version: '3.0.1'
        compileOnly group: 'com.liferay.portal', name: 'com.liferay.util.taglib', version: '3.0.0'
    
        compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
        compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
        compileOnly group: "jstl", name: "jstl", version: "1.2"
        compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
    }