RE: Edit Article in custom portlet

6年前 に Shruti Mishra によって更新されました。 New Member 投稿: 22 参加年月日: 15/04/24 最新の投稿
Hi,
Liferay-DXP
I have a requirement in which , I create journal articles programmatically by giving structure selection to users. This I have done .
Now I also want to give Edit, functionality to Users for the journal articles created by them.
I just want to show the Structure fields with pre-filled values and update the article on save.

JSP:
<%
String articleId = (String)request.getAttribute("articleId");
ServiceContext serviceContext = ServiceContextFactory.getInstance(JournalArticle.class.getName(), request);
DDMStructure ddmstructure = article.getDDMStructure();

Fields fields = DDMUtil.getFields(ddmstructure.getStructureId(), serviceContext);

FieldsToDDMFormValuesConverter fl = new FieldsToDDMFormValuesConverterImpl();
DDMFormValues ddmFormValues = fl.convert(ddmstructure, fields);

%>

<div>
<liferay-ddm:html
classNameId="<%= PortalUtil.getClassNameId(DDMStructure.class)%>"
classPK="<%= ddmstructure.getStructureId() %>"
fields="<%= fields %>"
ddmFormValues="<%=ddmFormValues %>"
/>
</div>


How can I have values from article in the structure fields opened using <liferay-ddm:html> ?
thumbnail
6年前 に Fernando Fernandez によって更新されました。 Expert 投稿: 401 参加年月日: 07/08/22 最新の投稿
Hi Shruti,

Not sure if this is what you want but, if you have an articleId you can call the default liferay editor with an editUrl like this:

Long resourcePrimKey = JournalArticleLocalServiceUtil.fetchArticle(groupId, articleId).getResourcePrimKey();
assetEntry = AssetEntryLocalServiceUtil.getEntry("com.liferay.journal.model.JournalArticle",resourcePrimKey);
AssetRenderer<!--?--> assetRenderer = assetEntry.getAssetRenderer();
PortletURL redirectURL = res.createRenderURL();
PortletURL editPortletURL = assetRenderer.getURLEdit((LiferayPortletRequest) req,
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; (LiferayPortletResponse) res,&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; WindowStateFactory.getWindowState("pop_up"),&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; redirectURL);


HTH

Fernando
6年前 に Shruti Mishra によって更新されました。 New Member 投稿: 22 参加年月日: 15/04/24 最新の投稿
Hi Fernando,
Thanks for the reply.
I did checked this way of doing it. But this opens whole article in Edit mode.
Which have Title, Summary and also Other Info to Edit (Structure, template, Metadata, Related Assets etc).
I dont want to open all these for Normal Users. So, just want the structure fields and its data Editable for Users.
Any way to just show Structure and Articles's data in it?