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
How to pass formInstanceId parameter into embed web form portlet?
Hi there!
Currently I'm using Liferay Portal CE 7.1 GA2 for my new project and I need to embed the web form portlet with preselected formInstanceId passed as a configurational parameter. I need to do this into a web content template. Do you think that it is possible?
I tried something like that:
Any help or advice will be much appreciated!
Thanks in advance,
Eli
Currently I'm using Liferay Portal CE 7.1 GA2 for my new project and I need to embed the web form portlet with preselected formInstanceId passed as a configurational parameter. I need to do this into a web content template. Do you think that it is possible?
I tried something like that:
<#assign preferencesMap = { "formInstanceId": "333" } />
<@liferay_portlet["runtime"]
portletName="com_liferay_dynamic_data_mapping_form_web_portlet_DDMFormPortlet"
defaultPreferences=freeMarkerPortletPreferences.getPreferences(preferencesMap)
instanceId="123"
/>
but unfortunately the desired form is not loaded inside the embed portlet.Any help or advice will be much appreciated!
Thanks in advance,
Eli
Hi Eli,
Yes, it should be possible. I have a few questions --1. Do you get an error at all when you try this?2. Have you checked to make sure that this is in fact the preference key?3. Are there maybe any other preferences that you need to add as well?Normally when I need to do something like this I start by dropping the runtime in with no auto configuration. I then configure it manually on the page. At that point, when I see that it is rendering properly, I go to the database and look up the preferences XML string in the PortletPreferences table and go back to the template and build the preferences map. Remember though, embedded preferences are not updated automatically when you make changes to them later. You need to remove delete the preferences for that item from the DB to have them reset (and don't forget to clear the DB cache before you reinitialize the portlet by reloading the page)
Yes, it should be possible. I have a few questions --1. Do you get an error at all when you try this?2. Have you checked to make sure that this is in fact the preference key?3. Are there maybe any other preferences that you need to add as well?Normally when I need to do something like this I start by dropping the runtime in with no auto configuration. I then configure it manually on the page. At that point, when I see that it is rendering properly, I go to the database and look up the preferences XML string in the PortletPreferences table and go back to the template and build the preferences map. Remember though, embedded preferences are not updated automatically when you make changes to them later. You need to remove delete the preferences for that item from the DB to have them reset (and don't forget to clear the DB cache before you reinitialize the portlet by reloading the page)
Hi Andrew and thanks for the fast reply!Your post made me recheck and fix my code. And yes, formInstanceId is a default portlet preference indeed. I want an auto configuration of the embed web form because like that it will be more efficient for the site editors to manage one specific type of web articles that I'm currently implementing . However, it seems that the code above does not set formInstanceId in a proper way. So I changed it with this working one ( of course resetting portlet preferences for each instance as you reminded me ).
<#assign VOID = freeMarkerPortletPreferences.setValue("formInstanceId", "333") />
<@liferay_portlet["runtime"]
portletName="com_liferay_dynamic_data_mapping_form_web_portlet_DDMFormPortlet"
defaultPreferences="${freeMarkerPortletPreferences}"
instanceId="${.vars['reserved-article-id'].data}"
/>
<#assign VOID = freeMarkerPortletPreferences.reset() />
Hi Elena,Very interesting -- I am curious, if you have a minute to try it, try using your original solution, but putting the map inline in the defaultPreferences attribute. I use that approach often and it has always worked for me.
Hi, Andrew!I tested your solution and it is working too. Thank you!Greetings
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™