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
submitting a single form among multiple forms
Hi team,
I' Mdeveloping simple jsp-jdbc portlet.
In the View.jsp I'm having various forms. like,
But whenever I click on submit button of any of the above form, the processAction() method will be invoking.
But how to invoke a particular form.
My idea was, getting the form name in processAction() method and, based on that we need to perform the actions (using if,else).
Is it a right way? If yes, Can anyone suggest me how to get the form name in procesAction() method of my Portlet ?
If the above process is completely wrong, Please suggest me the right wat to achieve this.
Thanks in advance.
Regards,
Giri
I' Mdeveloping simple jsp-jdbc portlet.
In the View.jsp I'm having various forms. like,
<form method="POST" action="<portlet:actionURL/>" name="form1"> </form>
<form method="POST" action="<portlet:actionURL/>" name="form2"> </form>
<form method="POST" action="<portlet:actionURL/>" name="form3"> </form>
But whenever I click on submit button of any of the above form, the processAction() method will be invoking.
But how to invoke a particular form.
My idea was, getting the form name in processAction() method and, based on that we need to perform the actions (using if,else).
Is it a right way? If yes, Can anyone suggest me how to get the form name in procesAction() method of my Portlet ?
If the above process is completely wrong, Please suggest me the right wat to achieve this.
Thanks in advance.
Regards,
Giri
hi team,
Please respond. It is a bit urgent.
Please respond. It is a bit urgent.
You could probably use a hidden input.
Rather than having many forms we tupically have a hidden form field:
then in the html if we have several different operations, these are typically invoked by different buttons calling some javascript method which changes the value of "cmd":
the javascript functions look something like this:
Now later in the processAction method:
Simple enough?
<input name="<portlet:namespace/>cmd" type="hidden" value="<%= (entity != null ? "update" : "add") %>">then in the html if we have several different operations, these are typically invoked by different buttons calling some javascript method which changes the value of "cmd":
<input type="submit" value="<liferay-ui:message key=" save">" />
<input type="button" value="<liferay-ui:message key=" expire">" onClick="<portlet:namespace />expire();" />
<input type="button" value="<liferay-ui:message key=" download">" onClick="<portlet:namespace />downloadContent();" />
the javascript functions look something like this:
function <portlet:namespace />expire() {
document.<portlet:namespace />fm1.<portlet:namespace />cmd.value = "expire";
submitForm(document.<portlet:namespace />fm1);
}
Now later in the processAction method:
String cmd = ParamUtil.getString(actionRequest, "cmd");
if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
article = updateArticle(actionRequest);
}
...Simple enough?
hi Ray Augé / Samuel Kong,
Thanks for your support. This working great.
Special thanks to Ray, for providing such a useful code snippet.
now, everything working great.
Regards,
giri
Thanks for your support. This working great.
Special thanks to Ray, for providing such a useful code snippet.
now, everything working great.
Regards,
giri