Ich habe versucht, BaseFriendlyURLMapper unter Liferay5.2 - Jboss4.2 Anwendungsserver zu erweitern ... Kein Problem mit buildPath() -Methode, aber ich kann nicht verstehen, wenn populateParams() ausgelöst wird ... nicht einmal im Debug-ModusLiferay 5.2: Erweiterung BaseFriendlyURLMapper, PopulateParams() Methode nicht ausgelöst
das ist mein 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>
dies 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());
}
irgendein Tipp?
Hier ist auch eine gute Erklärung, wie freundliche URLs in Liferay 5 behandelt werden. Http://www.devatwork.nl/2010/04/seo-friendly-urls-for-limeray-portlets/ – semonte
Dies ist klar. .. das Problem, in meinem Portlet, ist, dass populateParams nicht ausgelöst wird, so dass PortletUrl im Friendly-Modus geschrieben und nie wieder (durch populateParams) auf Klick umgewandelt wird ... – zuk
Das ist in der Tat seltsam. Nur ein kurzer Versuch: Entfernen Sie die Zeilenumbrüche, wenn Sie den friendly mapper in liferay-portlet.xml angeben. Es wird möglicherweise überhaupt nicht registriert (Liferay sieht eine leere Zeichenfolge). Wenn nicht hilfreich, könnten Sie vielleicht die WAR-Datei posten? – semonte