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
RE: Multiple actions in edit mode
I am following the following example: https://github.com/liferay/liferay-blade-samples/blob/7.1/maven/apps/configuration-action/src/main/java/com/liferay/blade/samples/configurationaction/MessageDisplayConfigurationAction.java
I have multiple submit buttons in my form. I'd like to handle them in multiple methods. This is possible in Spring MVC Portlet. For example, you can do this: Attach an onlclick event of the button to a function that looks like this:
And in the code we can do like this:
How to do the same thing in Liferay MVC. I would like to use multiple methods. Right now, I can do only one method and switch based on the condition and identify the different clicks.
I have multiple submit buttons in my form. I'd like to handle them in multiple methods. This is possible in Spring MVC Portlet. For example, you can do this: Attach an onlclick event of the button to a function that looks like this:
function <portlet:namespace />addGroup(){
var url = "<portlet:actionurl portletmode="edit"><portlet:param name="action" value="addGroup" /></portlet:actionurl>";
submitForm(document.<portlet:namespace />fm, url);
}
And in the code we can do like this:
@RequestMapping("EDIT")
@ActionMapping(params = "action=addGroup")
public void handleAddGroup(ActionRequest actionRequest, ActionResponse response) throws ResearchLibraryException, Exception {
PortletPreferences preferences = actionRequest.getPreferences();
// Add something to preferences
preferences.store();
}
How to do the same thing in Liferay MVC. I would like to use multiple methods. Right now, I can do only one method and switch based on the condition and identify the different clicks.
I can think of a number of ways...
So first one includes a <portlet:actionUrl /> with mvc action default for the value. JS bound to the button sets the mvc action and submits the form. The action handler component is bound to the defined paths and routing just works.
Next uses a regular <portlet:actionUrl /> for the form to submit, but the buttons then are form field values. The action handler component extracts the value and routes to separate methods or components for the options.
Last assumes that buttons do not, in fact, need to be bound to form submission, and just need a key value to do their own thing (like an edit and delete button in a row of data only needs the id). In these cases, they have their own actionUrl guys w/ their own parameters and routing is just done as normal.
So first one includes a <portlet:actionUrl /> with mvc action default for the value. JS bound to the button sets the mvc action and submits the form. The action handler component is bound to the defined paths and routing just works.
Next uses a regular <portlet:actionUrl /> for the form to submit, but the buttons then are form field values. The action handler component extracts the value and routes to separate methods or components for the options.
Last assumes that buttons do not, in fact, need to be bound to form submission, and just need a key value to do their own thing (like an edit and delete button in a row of data only needs the id). In these cases, they have their own actionUrl guys w/ their own parameters and routing is just done as normal.
Sarath Chandra:
Please don't crosspost this in future or link your crossposts. A nice summary of the reasons is here.
I am following the following example...
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™