Are <form/> name clash risks real with Liferay? -


i followed liferay helloword tutorial: https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/writing-your-first-liferay-application#creating-a-form

it says forms in liferay application form should have contain portlet basename name, not clash form name of portlet.

<aui:form action="<%= addentryurl %>" name="<portlet:namespace />fm"> </aui:form> 

why precaution not necessary buttons unnamed button rows?

<aui:button-row cssclass="guestbook-buttons">     <portlet:renderurl var="addentryurl">         <portlet:param name="mvcpath" value="/html/guestbook/edit_entry.jsp"></portlet:param>     </portlet:renderurl>     <aui:button onclick="<%= addentryurl.tostring() %>" value="add entry">     </aui:button> </aui:button-row> 

i mean, portlet have page nammed "/html/guestbook/edit_entry.jsp", right?

plus, tried remove precaution form , duplicate portlet, , did not have name clash problem. how useful?

using liferay 6.2.

about namespacing

your portlet's namespace automatically prefixed name of aui tags in 6.2 portal. these 2 equivalent in name

<form name="<portlet:namespace />fm"</form> <aui:form name="fm"></aui:form> 

as side not both have id attribute copy of name attribute. if @ liferay source code see forms given name "fm". convention used convenient , conflicts not occur because of namespace prefix.

your example

i think example bit off though. in case of unnamed button row, go current portlets edit_entry.jsp because of path specification unless otherwise specified. if have same portlet instantiated twice on same page wouldn't make different. don't see of issue unnamed button rows.

conflicts can occur

what make difference if had same portlet instantiated twice on same page. let's assume instance have "pitch" portlet , "catch" portlet. both of them have class "portlet" extends mvcportlet. both of them have fm forms no namespace. when posted form goes triggers action url goes portlet , subtracts point. in case there possibly conflict , point subtracted wrong portlet.

testing out

to witness conflict can stage following example.

  1. create 2 liferay plugin portlets different names.
  2. in both portlets create portlet.java file extends mvcportlet (see below). make sure qualified class name portlet (ie: don't create packages)
  3. in view.jsp file create form , action url (see below).
  4. in liferay-portlet.xml file add code below.

portlet.java

public class dashboardrequestportlet extends mvcportlet {     public void testaction(actionrequest actionrequest, actionrequest actionresponse) {     system.out.println("test");     } } 

view.jsp

<portlet:actionurl name="testaction" var="testactionurl" /> <form id="fm" name="fm" action="<%= testactionurl.tostring() %>" method="post"></form> 

liferay-portlet.xml

<requires-namespaced-parameters>false</requires-namespaced-parameters> 

put breakpoints in testaction method on both portlets. drag both portlets onto same page. start submitting...


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -