Author: thomas.heute(a)jboss.com
Date: 2007-04-27 08:28:37 -0400 (Fri, 27 Apr 2007)
New Revision: 7102
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
Log:
Select a CMS content in 2 steps, clicking on a file displays the title and description.
Clicking on the select link, adds it to the region
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-04-27
09:42:02 UTC (rev 7101)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-04-27
12:28:37 UTC (rev 7102)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.List;
+import java.util.Locale;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
@@ -36,6 +37,8 @@
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
/**
@@ -60,12 +63,7 @@
{
if (req.getPortletMode().equals(EDIT_CONTENT))
{
- String uri = req.getParameter("content.uri");
String path = req.getParameter("path");
- if (uri != null)
- {
- resp.setRenderParameter("content.uri", uri);
- }
if (path != null)
{
resp.setRenderParameter("path", path);
@@ -90,6 +88,7 @@
resp.setContentType("text/html");
String sPath = req.getParameter("path");
+ String contentUri = req.getParameter("content.uri");
if (sPath == null)
{
sPath = "/";
@@ -104,8 +103,21 @@
req.setAttribute("folders", folders);
req.setAttribute("files", files);
req.setAttribute("currpath", sPath);
+ req.setAttribute("content.uri", contentUri);
-
+ if (contentUri != null)
+ {
+ Command getContentCMD =
cmsService.getCommandFactory().createContentGetCommand(contentUri, null,
req.getLocale());
+ Content content = (Content)cmsService.execute(getContentCMD);
+
+ if (content == null)
+ {
+ getContentCMD =
cmsService.getCommandFactory().createFileGetCommand(contentUri, new
Locale(cmsService.getDefaultLocale()));
+ content = (Content)cmsService.execute(getContentCMD);
+ }
+ req.setAttribute("content" , content);
+ }
+
javax.portlet.PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMSEditorConstants.CMS_EDITOR_JSP_PATH +
"/main.jsp");
prd.include(req, resp);
}
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-04-27
09:42:02 UTC (rev 7101)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-04-27
12:28:37 UTC (rev 7102)
@@ -1,5 +1,6 @@
<%@ page import="org.jboss.portal.cms.model.File" %>
<%@ page import="org.jboss.portal.cms.model.Folder" %>
+<%@ page import="org.jboss.portal.cms.model.Content" %>
<%@ page import="org.jboss.portal.core.cms.ui.admin.CMSAdminConstants"
%>
<%@ page import="java.text.Format" %>
<%@ page import="java.text.SimpleDateFormat" %>
@@ -39,9 +40,9 @@
<a href="<%= url %>"><%= sPathChunk
%>
</a>
<%
-}
-else
-{
+ }
+ else
+ {
%>
<%= sPathChunk %>
<%
@@ -89,10 +90,9 @@
{
File file = (File)files.get(j);
- PortletURL metaURL = renderResponse.createActionURL();
+ PortletURL metaURL = renderResponse.createRenderURL();
metaURL.setParameter("content.uri", file.getBasePath());
metaURL.setParameter("path", sCurrPath);
- metaURL.setParameter("content.action.select", "select");
if ((uri!=null) && (uri.equals(file.getBasePath())))
{
@@ -103,7 +103,6 @@
out.println("<tr
onmouseover=\"this.className='portlet-section-alternate';\"
onmouseout=\"this.className='portlet-section-body';\">");
}
%>
-<tr>
<td><img src="<%= renderRequest.getContextPath() +
CMSAdminConstants.DEFAULT_IMAGES_PATH%>/file.gif"
alt="${n:i18n("CMS_FILE")}"
border="0"> <a href="<%= metaURL
%>"><%=
@@ -117,7 +116,30 @@
%>
</table>
<%
-
- }
-
+if (uri != null)
+{
+ Content content = (Content)renderRequest.getAttribute("content");
%>
+ <p class="portlet-font">
+ Selected file: <%= uri %><br />
+<%
+ if (content.getTitle() != null)
+ {
+ out.println("File title: " + content.getTitle() + "<br
/>");
+ }
+ if (content.getDescription() != null)
+ {
+ out.println("File description: " + content.getDescription() +
"<br />");
+ }
+%>
+ </p>
+<%
+ PortletURL submitURL = renderResponse.createActionURL();
+ submitURL.setParameter("content.uri", uri);
+ submitURL.setParameter("content.action.select", "select");
+%>
+<a href="<%= submitURL.toString() %>">Confirm</a>
+<%
+}
+}
+%>