论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
harish chandra maurya
how to use then one java class as a portlet-class
2013年1月28日 下午10:58
答复

harish chandra maurya

等级: New Member

帖子: 2

加入日期: 2012年10月24日

最近的帖子

Hi

I am new to liferay developement .I am trying to creating MVC portlet , with more then one jsp, now i want to use per java class for per jsp for action and render , how can i use . for portlet.xml i can move to and jsp Example view.jsp ... and from there i can save thing to database using portlet-class, after that i want to move to other jsp that can be done by using render action now for 2nd jsp i want to save other values to database.... now i want to use another java class or portlet-class how i do the mapping .

Can any one help me on that

Thanks
附件

附件: Q.JPG (26.0k)
Jignesh Vachhani
RE: how to use then one java class as a portlet-class
2013年1月28日 下午11:56
答复

Jignesh Vachhani

等级: Liferay Master

帖子: 780

加入日期: 2008年3月10日

最近的帖子

Harish,

Ideally controller will be unique for MVC structure i think. So you can definitely call different methods from different classes in controller class it self and can achieve your requirement.
Or else you can use struts portlet which can call different action classes as per the struts action URL.
Gnaniyar Zubair
RE: how to use then one java class as a portlet-class
2013年1月29日 上午12:03
答复

Gnaniyar Zubair

等级: Liferay Master

帖子: 602

加入日期: 2007年12月19日

最近的帖子

A portlet can have only one portlet class which you have configured in portlet.xml. Based on your RENDER or ACTION URL, you process or render action will be triggered .

ACTIONURL
=========
 1<liferay-portlet:actionURL name="addMethod"></liferay-portlet:actionURL> , this url will trigger you action method from your portlet class....
 2
 3public class TestPortlet extends MVCPortlet {
 4
 5public void addMethod(ActionRequest actionRequest,
 6            ActionResponse actionResponse) throws IOException, PortletException {
 7      // logic goes here
 8}
 9}

Like that, you can have "N" number action method in your portlet class.

RENDERURL:
===========

1<liferay-portlet:renderURL var="testRenderURL">
2    <liferay-portlet:param name="jspPage" value="/html/portlet/test/test.jsp"/>
3</liferay-portlet:renderURL>
4
5<a href="<%=testRenderURL.toString()%>" /> Go to test page </a>


if you mention "jspPage" parameter with your render URL, it will directly go to that particular jsp file through doView/render method of your portlet class.

if you dont mention "jspPage" parameter with renderURL, then you have to redirect to jsp file from doView/render method .

HTH

- Gnaniyar Zubair
harish chandra maurya
RE: how to use then one java class as a portlet-class
2013年1月29日 上午1:35
答复

harish chandra maurya

等级: New Member

帖子: 2

加入日期: 2012年10月24日

最近的帖子

Thanks,for the fruit full answer
Seeya S Kudtarker
RE: how to use then one java class as a portlet-class
2013年4月4日 上午2:02
答复

Seeya S Kudtarker

等级: Regular Member

帖子: 187

加入日期: 2013年1月15日

最近的帖子

Sorry for interupting the post.
I have a similar query.

I have my portlet class in package com.test.portal. I have included two more classes in it, say a.java and b.java just to make my code clean by including similar functions in one class.

How should I access the functions from a.java or b.java since whenver we specify action in form, it goes to the Action class?