フォーラム

ホーム » Liferay Portal » English » x. Miscellaneous

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Sujay Kumar Paul
SPRING PORTLET in liferay
2012/10/29 0:11
答え

Sujay Kumar Paul

ランク: Regular Member

投稿: 165

参加年月日: 2011/10/28

最近の投稿

Hi All,
I need to know how to create SPRING PORTLET in liferay.
Could anyone help me to know how it can be done and Please explain every steps from starting.
Muthukumar Thangavinayagam
RE: SPRING PORTLET in liferay
2012/10/29 1:44
答え

Muthukumar Thangavinayagam

ランク: New Member

投稿: 21

参加年月日: 2010/12/16

最近の投稿

sujay paul:
Hi All,
I need to know how to create SPRING PORTLET in liferay.
Could anyone help me to know how it can be done and Please explain every steps from starting.



Hi Sujay,

Please find attached sample springMVC portlet . and follow steps to create SpringPortlet in Liferay 6.x

Liferay 6 HelloWorld Spring Portlet


Step 1.web.xml

Configure ViewRendererServlet in web.xml file
<servlet>
<servlet-name>view-servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>view-servlet</servlet-name>
<url-pattern>/WEB-INF/servlet/view</url-pattern>
</servlet-mapping>


Step 2.Create configurationf xml under WEB-INF folder

WEB-INF/config/springhelloworld.xml and update spring configuration details . here example for springMVC using annotation

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="com.cignex.sample.portlet" />

<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>content.Language</value>
</list>
</property>
</bean>

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="cache" value="true" />
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsps/springsample/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>

Step 3.portlet.xml

update portlet-class and configure springhelloworld.xml file in your custom portlet

<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/config/springhelloworld.xml</value>
</init-param>



Step 4.Create SpringHelloWorld.java file under com.cignex.sample.portlet.controller .

continue with step2 . sprinhelloworld.xml file <context:component-scan/> base-path it mention com.cignex.sample.portlet . The component-scan will take care all the Controller classes.

SpringHelloWorld.java
@Controller("springHelloWorldController")
@RequestMapping(value = "VIEW")
public class SpringHelloWorldAction {

private static Log logger = LogFactoryUtil.getLog(SpringHelloWorldAction.class);

@RenderMapping
public String showViewPage(RenderRequest renderRequest,RenderResponse renderResponse) {

logger.info(" SpringHelloWorld Under Render method ");

return "viewResult";
}


}

Step 5 : .create viewResult.jsp file under /WEB-INF/jsps/springsample
continue with step2 . sprinhelloworld.xml file viewResolver configuration in springhelloworld.xml see step 2.

update viewResult.jsp file :
<div>
Welcome to Liferay Spring HelloWorld Portlet
</div

Best Regards,
Muthukumar Thangavinayagam
添付ファイル: SpringHelloWorld-portlet.rar (2,866.2k)
Hitoshi Ozawa
RE: SPRING PORTLET in liferay
2013/03/02 3:12
答え

Hitoshi Ozawa

ランク: Liferay Legend

投稿: 7954

参加年月日: 2010/03/23

最近の投稿

There's a sample Spring portlet in liferay's github directory.

https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-spring-portlet
Nilang I Patel
RE: SPRING PORTLET in liferay
2013/03/17 4:03
答え

Nilang I Patel

ランク: New Member

投稿: 12

参加年月日: 2011/07/25

最近の投稿

Hi,

Here is the blog written on the same which can be useful to you.

Regards
Nilang
karthik reddy
RE: SPRING PORTLET in liferay
2013/10/25 2:44
答え

karthik reddy

ランク: Junior Member

投稿: 38

参加年月日: 2013/04/08

最近の投稿

http://www.opensource-techblog.com/2012/09/spring-mvc-portlet-in-liferay.html