Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Edit Article in custom portlet
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> ?
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> ?
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:
HTH
Fernando
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,
(LiferayPortletResponse) res,
WindowStateFactory.getWindowState("pop_up"),
redirectURL);
HTH
Fernando
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?
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?
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™