掲示板

jsp form submitting to wrong Portlet class

9年前 に Suyesh Amatya によって更新されました。

jsp form submitting to wrong Portlet class

Junior Member 投稿: 61 参加年月日: 14/08/22 最新の投稿
I am trying to submit the jsp form to a portlet class BiobankAttributeListsPortlet.java. The form is listed below

<%@ include file="/html/init.jsp" %>

<%
	Biobank biobank = null;

	long biobankId = ParamUtil.getLong(request, "biobankId");

	biobank = BiobankLocalServiceUtil.getBiobank(biobankId);
	
	BiobankAttributeLists biobankAttributeLists = null;

	String redirect = ParamUtil.getString(request, "redirect");
	
	List left = new ArrayList(), right = new ArrayList(), l = new ArrayList();
	left.add(new KeyValuePair("1key", "item1value"));
	left.add(new KeyValuePair("4key", "item4value"));
	left.add(new KeyValuePair("3key", "item3value"));
	right.add(new KeyValuePair("2key", "item2value"));
%>

<aui:model-context bean="<%= biobankAttributeLists %>" model="<%= BiobankAttributeLists.class %>" />
<portlet:renderurl var="viewBiobankAttributeListsURL" />
<portlet:actionurl name="addBiobankAttributeLists" var="editBiobankAttributeListsURL" windowState="normal" />

<liferay-ui:header backURL="<%= viewBiobankAttributeListsURL %>" title="<%= (biobank != null) ? biobank.getName() : &quot;new-biobank&quot; %>" />

<aui:form action="<%= editBiobankAttributeListsURL %>" method="POST" name="fm">
	<aui:fieldset>
		<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
		<aui:input name="biobankId" type="hidden" value="<%= biobank == null ? &quot;&quot; : biobank.getBiobankId() %>" />
		<liferay-ui:input-move-boxes leftBoxName="leftb" leftTitle="Left box" leftList="<%=left %>" rightBoxName="right" rightTitle="Right box" rightList="<%=right %>" />
		
		
		
	</aui:fieldset>

	<aui:button-row>
		<aui:button type="submit" />

		<aui:button onClick="<%= viewBiobankAttributeListsURL %>" type="cancel" />
	</aui:button-row>
</aui:form>


The portlet:actionURL and form action seem all correct but the form is being submitted to the BiobankPortlet.java class and hence I get the java.lang.NoSuchMethodException: com.bcnet.portlet.biobank.BiobankPortlet.addBiobankAttributeLists(javax.portlet.ActionRequest, javax.portlet.ActionResponse). Of course there is no such method in BiobankPortlet but I have the method in BiobankAttributeListsPortlet.java which is where I think the form should have been submitted.

Or is it because the form is triggered by the search-container where I have
<liferay-ui:search-container-row
className="com.bcnet.portlet.biobank.model.Biobank"
keyProperty="biobankId"
modelVar="biobank" escapedModel="<%= true %>"
>

and hence it is trying to find the method in the BiobankPortlet and not in BiobankAttributeListsPortlet? I am trying to figure out is my understanding correct or not.
thumbnail
9年前 に Jitendra Rajput によって更新されました。

RE: jsp form submitting to wrong Portlet class

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
Check portletClass entry in portlet.xml . You might have defined incorrect portlet class .
9年前 に Suyesh Amatya によって更新されました。

RE: jsp form submitting to wrong Portlet class

Junior Member 投稿: 61 参加年月日: 14/08/22 最新の投稿
The portlet class entry is correct
<portlet-class>
com.bcnet.portlet.biobank.BiobankAttributeListsPortlet
</portlet-class>
thumbnail
9年前 に Jitendra Rajput によって更新されました。

RE: jsp form submitting to wrong Portlet class (回答)

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
Are you trying to call action method of some other portlet class ? If so then you can construct URL using PortletURLFactoryUtil and pass portlet id and other required details.
9年前 に Suyesh Amatya によって更新されました。

RE: jsp form submitting to wrong Portlet class

Junior Member 投稿: 61 参加年月日: 14/08/22 最新の投稿
I add a portlet PortletA to the page. In the view.jsp I have Action button which has three options. Two of them are regular edit and delete which calls the appropriate methods in PortletA. The third is the one from where the supposed form is triggered. From this form if I submit the values normally, they are supposed to be retrieved in the PortletA class? What I mean is all the three actions initiated from Actions button here is relevant to the PortletA class? Or can they be retrieved in any other Portlet class provided that the portlet class has the method being called? I have PortletB class where the supposed method is defined but seems like it is trying to find the method in PortletA where it is not present and I get the method not found exception.
thumbnail
9年前 に Andew Jardine によって更新されました。

RE: jsp form submitting to wrong Portlet class (回答)

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
If you are using the <portlet:actionURL/> or liferay equivalent to generate the action urls, then it will post back to the portlet in question and be passed to the portlet that is configured in the portlet.xml file as Jitendra has mentioned. There are a couple of options assuming I understand your post.

You basically have Portlet A with an action URL that you want a separate portlet to handle. Is that right?

If that is the case, the two options that come to mind --

ONE:
Define a server resource method in your BioBankAttributListPortlet and instead of using an action URL in your BioBankPortlet, make an AJAX call to the other portlet.

TWO:
Define an action method in Portlet A and either programatically call PortletB with the details, or move the logic from PortletB to a shared class that both A and B can instantiate and invoke.
9年前 に Suyesh Amatya によって更新されました。

RE: jsp form submitting to wrong Portlet class

Junior Member 投稿: 61 参加年月日: 14/08/22 最新の投稿
When you initiate some action from PortletA, by default it will call the action method of PortletA class. The form which is supposed to call the method resides inside the folder of other portlet class, i.e html/portletB/editform.jsp. So I wrongly thought this form will call the action method of PortletB class which is clearly not the case as I found out. So there was this mentioned NoSuchMethod Exception. If the method is defined in the PortletA class it works fine as it should. Turns out I was trying to call the method in wrong Portlet class without the required details. Thanks for the answers.