如何在“提交"按钮的onclick上调用MVCPortlet类内的action方法 [英] How can I call the action method inside the MVCPortlet class onclick of the Submit button

查看:105
本文介绍了如何在“提交"按钮的onclick上调用MVCPortlet类内的action方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Liferay 6进行开发.

I am using Liferay 6 for development.

我已经通过liferay-portlet.xml文件

<header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</header-portlet-javascript>
         <header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js</header-portlet-javascript>

现在我有一个带有用户名和密码的表单,如下所示:

Now I have a form with Username and password as shown below:

  <form>
    <div>
        <input class="default-value" type="text" name="Name" value="Name" />
        <input class="default-value" type="text" name="Password" value="Password" />
    </div>
    </form>

<div class="fieldgroup">
 <input type="submit" value="Register" class="submit">
</div>

<liferay-portlet:actionURL name="registerUser" var="registerUserURL"></liferay-portlet:actionURL>

我有一个CustomPortlet,如下所示,并将其添加到portlet.xml文件中,如图所示

I have a CustomPortlet as shown below , and added this inside the portlet.xml file as shown

 <portlet>
    <portlet-name>Second</portlet-name>
    <display-name>Second</display-name>
    <portlet-class>com.SecondPort</portlet-class>


public class SecondPort extends MVCPortlet {

public void registerUser(ActionRequest request, ActionResponse response) 
{
// Some code here with respect to the registerUser .
}
}

现在,请单击"JSP"页面上的提交"按钮告诉我,如何调用此registerUser方法?

Now please tell me on click of the Submit Button on the JSP Page, how can I call this registerUser method??

 <input type="submit" value="Register" class="submit">

请让我知道,谢谢.

推荐答案

对于您的jsp,您将关闭.需要使用actionURL和portlet的命名空间进行一些重新排序.警告-在stackoverflow答案窗口中键入,实际上并未编译/运行:

For your jsp you're close. Needs a bit of reordering, using the actionURL and the portlet's namespace. Warning - typed in stackoverflow answer window, didn't actually compile/run:

<liferay-portlet:actionURL name="registerUser" var="registerUserURL"></liferay-portlet:actionURL>
<form action="<%=registerUserURL%>">
    <div>
        <input class="default-value" type="text" name="<portlet:namespace/>Name" value="Name" />
        <input class="default-value" type="text" name="<portlet:namespace/>Password" value="Password" />
    </div>
</form>

<div class="fieldgroup">
 <input type="submit" value="Register" class="submit">
</div>

在扩展Liferay的MVC portlet时,portlet一侧看起来不错-只需在其中使用request.getParameter("Name");.

As you extend Liferay's MVC portlet the portlet side looks ok - just use request.getParameter("Name"); there.

这根本与jQuery不相关,对吧?

This is not related to jQuery at all, right?

这篇关于如何在“提交"按钮的onclick上调用MVCPortlet类内的action方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆