Monday, September 26, 2016

Use of Structure in Custom Portlet

Today we will discuss how to use Structure in Custom Portlet. The benefit of this approach is we easily create structure by just drag and drop and simply use this structure in our form. Before reading this blog you must know how to create Structure in Liferay.So lets start this step by step:-


Step 1:-Create Structure 
First you Create Structure and get the structureId . Here i am creating a structure that contain 3 fields Name(String),Age(Double) and Doc for uploading documents like images:-



And Click on save. Here my StructureId is 11821




Step 2:-Create Portlet
Create your portlet and Change the view.jsp as:-

view.jsp


Explanation:-
Here we are using structureId to get the fields and than by using <liferay-ddm:html> tag we get the structure. And finally on click of submit button we submit the form.




Now Change the Controller as:-

Demo.java


Explanation:-
In Demo.java we first get the DDMStructure by structureId and then get the fields and finally display on console.






Step 3:-Check the Output
Deploy your portlet and check the output:-








Hope this will Help....

You can Download Source code from  Structure in Custom Portlet. 

Related Post:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!