Dynamic Data Lists Display Template

最后都变了- 提交于 2020-01-06 18:45:07

问题


I tried to add a link for delete an entry of my data lists respective to tutorial1 and tutorial2 but I missed something.

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

This is how the view looks like

and after I click the delete button I get a error


回答1:


That's quite an interesting case, it took me some time to figure it out. This code works for me (on 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>

The request has to go via POST, otherwise Liferay will print This URL can only be invoked using POST to the logs. That's why it is a form (but you can naturally submit form with the link).



来源:https://stackoverflow.com/questions/24492606/dynamic-data-lists-display-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!