Search code examples
javaliferaycheckboxlistliferay-7

How to handle dynamic list of CheckBoxes in Liferay MVC Portlet


I'm creating mvc portlet to collect some data and have some trouble with implementing dynamic checkboxlist. Is there any standard control for liferay or example how to implement such a feature?

Ideally if the control would allow hierarchical data (treeview) and possibly dynamic loading of sub-trees...

Thanks for help,


Solution

  • If i get you correctly Robert, You want to get dynamically get your checkboxlist data right?

    There are no specific controls ( at least none that i know of) in Liferay for this. However, since it is an MVC portlet, it basically behaves like your traditional/conventional JSP(all permissible verisons) and as such your can design your protlet like you would any other JSP based application.

    So typically if you have a check box list you would use the <portlet:namespace/> tag to name the checkbox element and also define an actionURL for the form data.

    In the defined action use ParamUtil.getParameterValues(actionRequest,elementName,null) to retrieve an array of all checkbox list values.

    *Note: Use as is appropriate for Single or Multi-Select checkboxes

    For more information on how to handle form data in Liferay MVC portlet check out this url http://www.liferaysavvy.com/2014/05/liferay-mvc-portlet-form-submission.html

    Hope this helps!