Foren

How to Create Structure programmatically in liferay DXP ?

thumbnail
Shahbaz Khan, geändert vor 6 Jahren.

How to Create Structure programmatically in liferay DXP ?

Junior Member Beiträge: 40 Beitrittsdatum: 18.11.14 Neueste Beiträge
Hi I want to add structure programmatically . I found a method in DDMStructure Utill class.

public static com.liferay.dynamic.data.mapping.model.DDMStructure addStructure(
		long userId, long groupId, java.lang.String parentStructureKey,
		long classNameId, java.lang.String structureKey,
		java.util.Map<java.util.locale, java.lang.string> nameMap,
		java.util.Map<java.util.locale, java.lang.string> descriptionMap,
		com.liferay.dynamic.data.mapping.model.DDMForm ddmForm,
		com.liferay.dynamic.data.mapping.model.DDMFormLayout ddmFormLayout,
		java.lang.String storageType, int type,
		com.liferay.portal.kernel.service.ServiceContext serviceContext)
		throws com.liferay.portal.kernel.exception.PortalException {
		return getService()
				   .addStructure(userId, groupId, parentStructureKey,
			classNameId, structureKey, nameMap, descriptionMap, ddmForm,
			ddmFormLayout, storageType, type, serviceContext);
	}</java.util.locale,></java.util.locale,>


But here are two parameter DDMForm and DDMFormLayout . How can i create or pass these two parameter. I don't find any way to create these two objects.

Please help me to create structure programmatically in Liferay 7(DXP)
thumbnail
Shahbaz Khan, geändert vor 6 Jahren.

RE: How to Create Structure programmatically in liferay DXP ? (Antwort)

Junior Member Beiträge: 40 Beitrittsdatum: 18.11.14 Neueste Beiträge
Hi

I found the solution. We have to add new dependency in Gradle. Add below dependency in build.gradle file
compileOnly group: "com.liferay", name: "com.liferay.dynamic.data.mapping.api", version: "3.3.0"


Then from DDMUtil class we can get object of DDMForm and DDMFormLayout like

DDMForm ddmForm=new DDMForm();
DDMFormLayout ddmFormLayout=new DDMFormLayout();
ddmForm=DDMUtil.getDDMForm(definition);
ddmFormLayout = DDMUtil.getDefaultDDMFormLayout(ddmForm);