Hello There,
Couple of days ago I was working with MVC portlet and I had to integrate comment [<Liferay-ui:discussion ….> tag] functionality with it in Liferay [6.1 GA2]. I thought it would be cake walk for me but no it was not L, cause simple way this is working very well but not with search-container or I guess not within for loop.
I tried to get ans. from various place but could not get it.
Problem description:
Step 1) Create MVC portlet.
Step 2) view.jsp which contains search container.
Step 3) In each row of search container I kept below code.
<portlet:actionURL var="discussionURL" name="invokeTaglibDiscussion"></portlet:actionURL>
<liferay-ui:discussion
className="<%=objEntry.class.getName() %>"
classPK="<%= obj.getEntryId() %>"
formAction="<%= discussionURL %>"
formName="fm2"
ratingsEnabled="<%= false %>"
redirect="<%= currentURL %>"
subject="<%= obj.getTitle() %>"
userId="<%= obj.getUserId() %>"
/>
Step 4) Deploy portlet and check js console of browser I was getting two errors as describe below
Step 2) view.jsp which contains search container.
Step 3) In each row of search container I kept below code.
<portlet:actionURL var="discussionURL" name="invokeTaglibDiscussion"></portlet:actionURL>
<liferay-ui:discussion
className="<%=objEntry.class.getName() %>"
classPK="<%= obj.getEntryId() %>"
formAction="<%= discussionURL %>"
formName="fm2"
ratingsEnabled="<%= false %>"
redirect="<%= currentURL %>"
subject="<%= obj.getTitle() %>"
userId="<%= obj.getUserId() %>"
/>
Step 4) Deploy portlet and check js console of browser I was getting two errors as describe below
Java script Error 1)
“TypeError: document.****************_parentMessageId0 is undefined”
Resolution:
Java script Error 2)
“TypeError : d.one(…) null” [Please find screen shot for same.]
Resolution:
- After even applying patch I was facing error-2,so debug further and
Found following solution
Reason:
While you are using <Liferay-ui:discussion…/> tag inside the for loop or inside the search container that time "formName" always remain same in mine case its always "fm2" that the issue.
Solution:
Try to keep “formName” element unique with primary key of that object,
Following code worked for me in mine case, you can use the same.
Following code worked for me in mine case, you can use the same.
<portlet:actionURL var="discussionURL" name="invokeTaglibDiscussion"></portlet:actionURL>
<liferay-ui:discussion
className="<%=objEntry.class.getName() %>"
classPK="<%= obj.getEntryId() %>"
formAction="<%= discussionURL %>"
formName="<%= primaryKeyOfMyObj %>"
ratingsEnabled="<%= false %>"
redirect="<%= currentURL %>"
subject="<%= obj.getTitle() %>"
userId="<%= obj.getUserId() %>"
/>
<liferay-ui:discussion
className="<%=objEntry.class.getName() %>"
classPK="<%= obj.getEntryId() %>"
formAction="<%= discussionURL %>"
formName="<%= primaryKeyOfMyObj %>"
ratingsEnabled="<%= false %>"
redirect="<%= currentURL %>"
subject="<%= obj.getTitle() %>"
userId="<%= obj.getUserId() %>"
/>
Hope this helps.
For more information you can contact on sagar.vyas.blogspot@gmail.com
Thanks,
Sagar Vyas
No comments:
Post a Comment