Update of
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets
In directory
james.mmbase.org:/tmp/cvs-serv9792/cmsc/portlets/src/java/com/finalist/cmsc/portlets
Modified Files:
Tag: b1_4
XsltPortlet.java
Log Message:
allow for fancy click on renderurl in do view
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets
Index: XsltPortlet.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/XsltPortlet.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -b -r1.3.2.1 -r1.3.2.2
--- XsltPortlet.java 1 Apr 2008 10:01:59 -0000 1.3.2.1
+++ XsltPortlet.java 1 Apr 2008 14:26:39 -0000 1.3.2.2
@@ -16,6 +16,8 @@
import java.util.*;
import javax.portlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
@@ -24,9 +26,12 @@
import org.apache.commons.lang.StringUtils;
import org.xml.sax.SAXException;
+import com.finalist.cmsc.beans.om.NavigationItem;
import com.finalist.cmsc.navigation.ServerUtil;
import com.finalist.cmsc.portalImpl.PortalConstants;
+import com.finalist.cmsc.services.sitemanagement.SiteManagement;
import com.finalist.cmsc.util.XsltUtil;
+import com.finalist.pluto.PortletURLImpl;
import com.finalist.pluto.portalImpl.core.CmscPortletMode;
public class XsltPortlet extends CmscPortlet {
@@ -37,6 +42,9 @@
public static final String SOURCE_ATTR_PARAM = "source";
private static final String VIEW = "view";
+ protected static final String PAGE = "page";
+ protected static final String WINDOW = "window";
+
/**
* @see
net.sf.mmapps.commons.portlets.CmscPortlet#processEditDefaults(javax.portlet.ActionRequest,
@@ -57,6 +65,8 @@
// get the values submitted with the form
setPortletParameter(portletId, SOURCE_ATTR_PARAM,
request.getParameter(SOURCE_ATTR_PARAM));
setPortletView(portletId, request.getParameter(VIEW));
+ setPortletNodeParameter(portletId, PAGE,
request.getParameter(PAGE));
+ setPortletParameter(portletId, WINDOW,
request.getParameter(WINDOW));
}
else {
getLogger().error("No portletId");
@@ -73,6 +83,28 @@
@Override
protected void doEditDefaults(RenderRequest req, RenderResponse res) throws
IOException, PortletException {
addViewInfo(req);
+
+ /**
+ * process clickon prefs
+ * NB this is a copy of the same functionality in AbstractContentPortlet.
+ */
+ PortletPreferences preferences = req.getPreferences();
+ String pageid = preferences.getValue(PAGE, null);
+ if (!StringUtil.isEmpty(pageid)) {
+
+ String pagepath = SiteManagement.getPath(Integer.valueOf(pageid),
true);
+
+ if (pagepath != null) {
+ setAttribute(req, "pagepath", pagepath);
+
+ Set<String> positions = SiteManagement.getPagePositions(pageid);
+ ArrayList<String> orderedPositions = new
ArrayList<String>(positions);
+ Collections.sort(orderedPositions);
+ setAttribute(req, "pagepositions", new
ArrayList<String>(orderedPositions));
+ }
+ }
+ /** END process clickon prefs */
+
super.doEditDefaults(req, res);
}
@@ -81,6 +113,8 @@
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
PortletPreferences preferences = request.getPreferences();
String template =
preferences.getValue(PortalConstants.CMSC_PORTLET_VIEW_TEMPLATE, null);
+ String page = preferences.getValue(PAGE, null);
+ String window = preferences.getValue(WINDOW, null);
String xsl = getTemplate("view", template, "xsl");
String xmlSource = preferences.getValue(SOURCE_ATTR_PARAM, null);
@@ -89,7 +123,24 @@
if (!StringUtil.isEmpty(xsl) && !StringUtil.isEmpty(xmlSource)) {
try {
HashMap<String, Object> xslParams = getXsltParams(preferences);
- xslParams.put("renderurl", response.createRenderURL());
+
+ /** get renderUrl */
+ PortletURL renderUrl = null;
+ if (page != null && window != null) {
+ String link = "";
+ NavigationItem item =
SiteManagement.convertToNavigationItem(page);
+ if (item != null) {
+ link = SiteManagement.getPath(item,
!ServerUtil.useServerName());
+ }
+ else {
+ link = page;
+ }
+ renderUrl = new PortletURLImpl(link, window,
(HttpServletRequest) request,
+ (HttpServletResponse) response, false);
+ } else {
+ renderUrl = response.createRenderURL();
+ }
+ xslParams.put("RENDERURL", renderUrl);
StringBuffer content = new StringBuffer(4096);
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs