RE: Edit Article in custom portlet

Shruti Mishra, modified 6 Years ago. New Member Posts: 22 Join Date: 4/24/15 Recent Posts
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
Fernando Fernandez, modified 6 Years ago. Expert Posts: 401 Join Date: 8/22/07 Recent Posts
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
Shruti Mishra, modified 6 Years ago. New Member Posts: 22 Join Date: 4/24/15 Recent Posts
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?