动态数据列表显示模板

时间:2014-06-30 14:34:29

标签: liferay-6

我尝试添加一个链接,用于删除与tutorial1tutorial2相对应的数据列表条目,但我遗漏了一些内容。

   <h1>Task Summary</h1>

Hallo "${reserved_record_set_name}".

<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
<#assign groupService = serviceLocator.findService("com.liferay.portal.service.GroupLocalService")>
<#assign layoutService = serviceLocator.findService("com.liferay.portal.service.LayoutLocalService")>

<#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)>

<ul>
<#if records?has_content>
        <#list records as cur_record>
                <li><em>${cur_record.getFieldValue("Author", locale)}</em> will help with 
                <a href="${ddmUtil.getDisplayFieldValue(themeDisplay, cur_record.getFieldValue("DataSet", locale), cur_record.getFieldType("DataSet"))}">${languageUtil.format(locale, "download-x", "Data Set")}</a>




                <#assign controlPanelGroup = groupService.getGroup(portalUtil.getDefaultCompanyId(), "Control Panel")>
                <#assign controlPanelPlid = layoutService.getDefaultPlid(controlPanelGroup.getGroupId(), true)>

                <#assign portletActionURL = portletURLFactory.create(request,"167",controlPanelPlid,"ACTION_PHASE")>

                ${portletActionURL.setParameter("recordId", "${cur_record.getRecordId()}")}
                ${portletActionURL.setParameter("cmd", "delete")}
                ${portletActionURL.setParameter("struts_action", "/dynamic_data_lists/edit_record")}
                ${portletActionURL.setParameter("redirect", "${themeDisplay.getPortalURL()}${themeDisplay.getURLCurrent()}")}

                <#if permissionChecker.hasPermission(scopeGroupId, "com.liferay.portlet.dynamicdatalists.model.DDLRecordSet", "${reserved_record_set_id}", "DELETE")>                
                    <form action="${portletActionURL}" method="POST">
                        <input type="submit" value="Delete">
                    </form>
                </#if>
               </li>
        </#list>
</#if>

这就是视图的样子 view

点击删除按钮后,我收到错误error

1 个答案:

答案 0 :(得分:2)

这是一个非常有趣的案例,我花了一些时间才弄明白。此代码适用于我(在6.2 CE GA2上):

<#assign controlPanelGroup = groupService.getGroup(portalUtil.getDefaultCompanyId(), "Control Panel")>
<#assign controlPanelPlid = layoutService.getDefaultPlid(controlPanelGroup.getGroupId(), true)>

<#assign portletActionURL = portletURLFactory.create(request,"167",controlPanelPlid,"ACTION_PHASE")>
${portletActionURL.setParameter("recordId", "${cur_record.getRecordId()}")}
${portletActionURL.setParameter("cmd", "delete")}
${portletActionURL.setParameter("struts_action", "/dynamic_data_lists/edit_record")}
${portletActionURL.setParameter("redirect", "${themeDisplay.getPortalURL()}${themeDisplay.getURLCurrent()}")}

<#if permissionChecker.hasPermission(scopeGroupId, "com.liferay.portlet.dynamicdatalists.model.DDLRecordSet", "${reserved_record_set_id}", "DELETE")>                
    <form action="${portletActionURL}" method="POST">
        <input type="submit" value="Delete">
    </form>
</#if>

请求必须通过POST,否则Liferay会将This URL can only be invoked using POST打印到日志中。这就是为什么它是一个表单(但你可以自然地通过链接提交表单)。