PDA

View Full Version : onModuleLoad() do not run during portlet first load on liferay 6



javafreshman
13 Oct 2011, 12:55 AM
I would like to write a protlet using GXT and Spring portlet MVC and deploy to liferay portal 6. I can succcessfully install my portlet in liferay, but the onModuleLoad() in GXT seems had not run when the portlet first display on liferay. I must press F5 to refreh the protal page so make onModuleLoad() run.

Does anyone know what's wrong with my code? Please advise. Thanks a lot~

Here is my code and config:
EntryPoint:
public class Searchcar implements EntryPoint {
private Button clickMeButton;
public void onModuleLoad() {
Window.alert("onModuleLoad! -- 1"); // DEBUG_MSG

RootPanel rootPanel = RootPanel.get("portlet-container");
clickMeButton = new Button();
clickMeButton.setText("Click me!");
clickMeButton.setSize("80px", "30px");

rootPanel.add(clickMeButton);
rootPanel.setWidgetPosition(clickMeButton, 5, 5);


/*
clickMeButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
Window.alert("Hello, GWT World!");
}
});
*/
}
}

JSP to display on portlet:
<html>

<head>
<link rel="stylesheet" type="text/css" href="/carportlet/ExtGWT/css/gxt-all.css" >
<link rel="stylesheet" type="text/css" href="/carportlet/search_car_.css" >
</head>

<body>
<div id="portlet-container"></div>
<script type="text/javascript" language="javascript" src="/carportlet/searchcar/searchcar.nocache.js"></script>
</body>

</html>

gxt.xml:
<module rename-to='searchcar'>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>

<!-- Inherit Ext GWT (GXT) modules to access GXT components -->
<inherits name="com.extjs.gxt.ui.GXT"/>

<!-- Inherit HTTP modules to make asynchronous HTTP request -->
<inherits name="com.google.gwt.http.HTTP" />

<!-- Inherit JSON modules to access JSONP tools -->
<inherits name='com.google.gwt.json.JSON'/>
<inherits name='com.google.gwt.jsonp.Jsonp'/>

<!-- Fix GWT Designer cannot find css path during parse Java view to Designer view -->
<!-- <stylesheet src="ExtGWT/css/gxt-all.css"/> -->
<stylesheet src="/carportlet/ExtGWT/css/gxt-all.css"/>

<entry-point class="gxt.search_car_.client.Searchcar"/>
</module>

bean difinition:
<bean id="porletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap">
<map>
<entry key="view" value-ref="searchController" />
</map>
</property>
</bean>

<!-- Define Controller Bean -->
<bean id="searchController" class="spring.controller.GxtSearchController">
<property name="formView" value="gxt_json_search_view" />
<property name="successView" value="gxt_json_search_view" />
<property name="service" ref="search_car_service" />
</bean>
<bean id="gxt_json_search_view" class="org.springframework.web.servlet.view.JstlView">
<property name="url" value="/gxt_json_search_car_.jsp" />
</bean>

javafreshman
17 Oct 2011, 9:50 PM
The problem is fixed by adding the following line in *.gwt,xml

<add-linker name="xsiframe" />

but what is this line of code for?