【发布时间】:2012-04-10 02:52:47
【问题描述】:
我尝试在 Liferay5.2 - Jboss4.2 应用服务器下扩展 BaseFriendlyURLMapper... buildPath() 方法没有问题,但我无法理解 populateParams() 何时触发... 即使在调试模式下也没有
p>这是我的liferay-portlet.xml
<portlet>
<portlet-name>bookingInterface</portlet-name>
<configuration-action-class>my.package.MyConfiguration
</configuration-action-class>
<!-- -->
<instanceable>false</instanceable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<friendly-url-mapper-class>
my.package.MyFriendlyURLMapper
</friendly-url-mapper-class>
<use-default-template>true</use-default-template>
<restore-current-view>true</restore-current-view>
</portlet>
这是MyFriendlyURLMapper.java
public class MyFriendlyURLMapper extends BaseFriendlyURLMapper{
private static final String _PORTLET_ID="myPortlet_WAR_myPortlet";
private static final String _PORTLET_MAPPING = "myPortlet";
private static final String _LIFECYCLE_RENDER = "0";
private static final String _LIFECYCLE_ACTION = "1";
private static final String _LIFECYCLE_RESOURCE = "2";
public String getPortletId() {
return _PORTLET_ID;
}
public String getMapping() {
return _PORTLET_MAPPING;
}
public String buildPath(LiferayPortletURL portletURL) {
String friendlyURLPath = null;
String portletId = portletURL.getPortletId();
String action = GetterUtil.getString(portletURL.getParameter("action"));
if(action.equals("step1")){
System.out.println("step1" );
}
friendlyURLPath = StringPool.FORWARD_SLASH +getMapping()
+ StringPool.FORWARD_SLASH + action
;
if (Validator.isNotNull(friendlyURLPath)) {
//parametri da rimuovere dalla portleturl
portletURL.addParameterIncludedInPath("action");
portletURL.addParameterIncludedInPath("p_p_id");
portletURL.addParameterIncludedInPath("p_p_lifecycle");
portletURL.addParameterIncludedInPath("p_p_state");
portletURL.addParameterIncludedInPath("p_p_mode");
portletURL.addParameterIncludedInPath("p_p_col_id");
portletURL.addParameterIncludedInPath("p_p_col_count");
}
}
// return orignal unformatted url
return friendlyURLPath;
}
public void populateParams(String friendlyURLPath, Map<String, String[]> parameterMap) {
System.out.println(friendlyURLPath );
System.out.println(parameterMap.size() );
}
有什么提示吗?
【问题讨论】:
标签: liferay friendly-url