In my jsp I have the following code:
<portlet:actionURL name="addDetails" var="addDetailsURL" />
<aui:form name="addDetails" action="<%=addDetailsURL.toString() %>" method="post" >
<aui:input type="text" label="name:" name="name" value="" />
<aui:input type="text" label="surname:" name="surname" value="" />
<aui:input type="text" label="age:" name="age" value="" />
<aui:button type="submit" value="addDetails" />
</aui:form>
I am using liferay. I want to submit this data which will be processed in a java class. my java class has few functions. how should I specify in the above jsp that it should access the particular function in java after submitting the form?
Just for the record, you can also use annotations. For example, you have this jsp:
And this Java method in your
MVCPortlet
:Paste this in your controller class
or you can use it as
If you want to handle only one action:
Portlet
JSP
If you want more than one action method:
JSP
But you probably would do:
Portlet
JSP
JavaScript
If you are not using MVCPortlet but rather something like GenericPortlet, add a param to the actionURL like this:
Then in your processAction method, handle checking the method type this way:
If your java class is extending MVCPortlet then just the method name should match actionURL name i.e. addDetails . If the class is extending GenericPortlet you will have to specify annotaion for the same on top of your method like @ProcessAction(name="addDetails").IOn this case the name of your method can be different.
If your portlet inherits
MVCPortlet
, simply create a public method with the same "name" as your actionURL, that takes anActionRequest
andActionResponse
argument: