Java liferay 7.1 b3在片段中嵌入portlet

Java liferay 7.1 b3在片段中嵌入portlet,java,liferay,portlet,liferay-7,Java,Liferay,Portlet,Liferay 7,我正在尝试,我想在页面片段中嵌入一个portlet。我已经查看了最新的可用文档,其中指出为了在页面片段中嵌入portlet小部件,我所要做的就是添加 "com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet" 属性,在本例中,别名(mycustomportlet)是我将用于在片段中包含portlet的别名 然后在我的自定义页面片段中,我必须包含lfr小部件标记,其后缀由com.liferay.fragment.e

我正在尝试,我想在页面片段中嵌入一个portlet。我已经查看了最新的可用文档,其中指出为了在页面片段中嵌入portlet小部件,我所要做的就是添加

"com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet"
属性,在本例中,别名(
mycustomportlet
)是我将用于在片段中包含portlet的别名

然后在我的自定义页面片段中,我必须包含
lfr小部件
标记,其后缀由
com.liferay.fragment.entry.processor.portlet.alias
属性定义。所以在我的例子中,它应该是

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

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


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

我解决了它。有两件事要考虑。< /P> 首先,我使用Eclipse生成了MVCPortlet,它将旧版本的内核依赖项放在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的
@组件
注释中,我添加了:

"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 {
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"
}
build.gradle
文件如下所示

@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 {
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"
}

我遇到了完全相同的问题,解决方案是避免portlet名称中出现破折号!我花了很长时间才弄明白,所以我想如果有人遇到同样的问题,我会把它贴在这里。
因此,不要使用
“javax.portlet.name=myCustomPortlet”
而是编写
“javax.portlet.name=myCustomPortlet”


Fragment属性仍然可以包含任何破折号:
“com.liferay.Fragment.entry.processor.portlet.alias=my custom portlet”

幸运的是,我不再使用liferay portlet了,但我很高兴您找到了一个有效的答案。希望它能帮助别人,它比我发布的解决方案简单得多。