Finished admin UI for the ContentItemJSRPortlet
git-svn-id: https://svn.libreccm.org/ccm/trunk@2736 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
7cdf763aff
commit
40f71ce13f
|
|
@ -20,19 +20,26 @@ package com.arsdigita.cms.portlet;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentBundle;
|
import com.arsdigita.cms.ContentBundle;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ContentSectionCollection;
|
import com.arsdigita.cms.ContentSectionCollection;
|
||||||
import com.arsdigita.cms.ItemCollection;
|
import com.arsdigita.cms.ItemCollection;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.portal.JSRPortlet;
|
import com.arsdigita.portal.JSRPortlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import javax.portlet.ActionRequest;
|
import javax.portlet.ActionRequest;
|
||||||
import javax.portlet.ActionResponse;
|
import javax.portlet.ActionResponse;
|
||||||
import javax.portlet.PortletException;
|
import javax.portlet.PortletException;
|
||||||
|
import javax.portlet.PortletPreferences;
|
||||||
import javax.portlet.PortletRequestDispatcher;
|
import javax.portlet.PortletRequestDispatcher;
|
||||||
import javax.portlet.RenderRequest;
|
import javax.portlet.RenderRequest;
|
||||||
import javax.portlet.RenderResponse;
|
import javax.portlet.RenderResponse;
|
||||||
|
|
@ -54,8 +61,15 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
||||||
* /WEB-INF/conf/log4j.properties int the runtime environment and set
|
* /WEB-INF/conf/log4j.properties int the runtime environment and set
|
||||||
* com.arsdigita.portal.JSRPortlet=DEBUG by uncommenting or adding the line.
|
* com.arsdigita.portal.JSRPortlet=DEBUG by uncommenting or adding the line.
|
||||||
*/
|
*/
|
||||||
private static final Logger s_log = Logger.getLogger(ContentItemJSRPortlet.class);
|
private static final Logger LOGGER = Logger.getLogger(ContentItemJSRPortlet.class);
|
||||||
private static final String BACKING_BEAN = "comArsdigitaCMSContentItemJSRPortletAdmin";
|
private static final String PREFS_SELECTED_ITEM = ".selectedContentItem";
|
||||||
|
private static final String SELECTED_ITEM = "selectedItem";
|
||||||
|
private static final String ACTION = "action";
|
||||||
|
private static final String SELECT_ITEM = "selectItem";
|
||||||
|
private static final String CONTENT_ITEM_SEARCH_STRING = "contentItemSearchString";
|
||||||
|
private static final String CONTENT_SECTION_SELECT = "contentSectionSelect";
|
||||||
|
|
||||||
|
private final List<String> errors = new ArrayList<String>();
|
||||||
private String selectedContentSection;
|
private String selectedContentSection;
|
||||||
private String search;
|
private String search;
|
||||||
|
|
||||||
|
|
@ -83,7 +97,7 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
||||||
|
|
||||||
request.setAttribute("contentSections", sections);
|
request.setAttribute("contentSections", sections);
|
||||||
request.setAttribute("selectedContentSection", selectedContentSection);
|
request.setAttribute("selectedContentSection", selectedContentSection);
|
||||||
request.setAttribute("contentItemSearchString", search);
|
request.setAttribute(CONTENT_ITEM_SEARCH_STRING, search);
|
||||||
|
|
||||||
if ((selectedContentSection != null)) {
|
if ((selectedContentSection != null)) {
|
||||||
final ContentSection selectedSection = new ContentSection(OID.valueOf(
|
final ContentSection selectedSection = new ContentSection(OID.valueOf(
|
||||||
|
|
@ -102,8 +116,53 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
||||||
request.setAttribute("matchingItems", matchingItems);
|
request.setAttribute("matchingItems", matchingItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.setAttribute("helloworld", "Hello World Attribute");
|
request.setAttribute("errors", errors);
|
||||||
|
|
||||||
|
final String itemOID = request.getPreferences().getValue(response.getNamespace().concat(
|
||||||
|
PREFS_SELECTED_ITEM), "");
|
||||||
|
if (!itemOID.isEmpty()) {
|
||||||
|
try {
|
||||||
|
final OID oid = OID.valueOf(itemOID);
|
||||||
|
ContentItem item = (ContentItem) DomainObjectFactory.newInstance(oid);
|
||||||
|
if (item instanceof ContentBundle) {
|
||||||
|
final ContentBundle bundle = (ContentBundle) item;
|
||||||
|
if (bundle.hasInstance(request.getLocale().getLanguage())) {
|
||||||
|
item = bundle.getInstance(request.getLocale().getLanguage());
|
||||||
|
} else {
|
||||||
|
item = bundle.getPrimaryInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.setAttribute("selectedItemOID", item.getOID().toString());
|
||||||
|
request.setAttribute("selectedItemPath", item.getPath());
|
||||||
|
request.setAttribute("selectedItemTitle", item.getDisplayName());
|
||||||
|
request.setAttribute("selectedItemType", item.getContentType().getName());
|
||||||
|
|
||||||
|
if (item.getPublicVersion() == null) {
|
||||||
|
request.setAttribute("selectedItemStatus", "unpublished");
|
||||||
|
} else {
|
||||||
|
request.setAttribute("selectedItemStatus", "published");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
//errors.add(String.format("The OID '%s' set in the preferences is invalid.",
|
||||||
|
// itemOID));
|
||||||
|
errors.add(MessageFormat.format(getResourceBundle(request.getLocale()).getString(
|
||||||
|
"contentItemJSRPortlet.errors.perferences.illegal_oid"),
|
||||||
|
itemOID));
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
//errors.add(String.format("The item identified by the OID '%s' does not exist.",
|
||||||
|
// itemOID));
|
||||||
|
errors.add(MessageFormat.format(
|
||||||
|
getResourceBundle(request.getLocale()).getString(
|
||||||
|
"contentItemJSRPortlet.errors.perferences.item_does_not_exist"),
|
||||||
|
itemOID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.setAttribute("namespace", response.getNamespace());
|
||||||
|
|
||||||
|
//request.setAttribute("helloworld", "Hello World Attribute");
|
||||||
final PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(
|
final PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(
|
||||||
"/templates/portlets/ContentItemJSRPortletAdmin.jsp");
|
"/templates/portlets/ContentItemJSRPortletAdmin.jsp");
|
||||||
dispatcher.include(request, response);
|
dispatcher.include(request, response);
|
||||||
|
|
@ -118,10 +177,10 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doHelp(RenderRequest request, RenderResponse response)
|
protected void doHelp(final RenderRequest request, final RenderResponse response)
|
||||||
throws PortletException, IOException {
|
throws PortletException, IOException {
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
PrintWriter writer = new PrintWriter(response.getWriter());
|
final PrintWriter writer = new PrintWriter(response.getWriter());
|
||||||
writer.println("You're now in Help mode.");
|
writer.println("You're now in Help mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,10 +193,10 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doView(RenderRequest request, RenderResponse response)
|
protected void doView(final RenderRequest request, final RenderResponse response)
|
||||||
throws PortletException, IOException {
|
throws PortletException, IOException {
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
PrintWriter writer = new PrintWriter(response.getWriter());
|
final PrintWriter writer = new PrintWriter(response.getWriter());
|
||||||
writer.println("Hello world! You're in View mode.");
|
writer.println("Hello world! You're in View mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,9 +204,44 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
||||||
public void processAction(final ActionRequest actionRequest,
|
public void processAction(final ActionRequest actionRequest,
|
||||||
final ActionResponse actionResponse) throws PortletException,
|
final ActionResponse actionResponse) throws PortletException,
|
||||||
IOException {
|
IOException {
|
||||||
if (actionRequest.getParameter("contentSectionSelect") != null) {
|
if (actionRequest.getParameter(CONTENT_SECTION_SELECT) != null) {
|
||||||
selectedContentSection = actionRequest.getParameter("contentSectionSelect");
|
selectedContentSection = actionRequest.getParameter(CONTENT_SECTION_SELECT);
|
||||||
search = actionRequest.getParameter("contentItemSearchString");
|
search = actionRequest.getParameter(CONTENT_ITEM_SEARCH_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SELECT_ITEM.equals(actionRequest.getParameter(ACTION))) {
|
||||||
|
final String itemOID = actionRequest.getParameter(SELECTED_ITEM);
|
||||||
|
|
||||||
|
if ((itemOID == null) || itemOID.isEmpty()) {
|
||||||
|
errors.add("OID is null");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
OID oid = OID.valueOf(itemOID);
|
||||||
|
final ContentItem item = new ContentItem(oid);
|
||||||
|
|
||||||
|
final ContentItem draftItem = item.getDraftVersion();
|
||||||
|
if (draftItem instanceof ContentPage) {
|
||||||
|
final ContentPage page = (ContentPage) draftItem;
|
||||||
|
final ContentBundle bundle = page.getContentBundle();
|
||||||
|
oid = bundle.getOID();
|
||||||
|
}
|
||||||
|
|
||||||
|
final PortletPreferences preferences = actionRequest.getPreferences();
|
||||||
|
preferences.setValue(actionResponse.getNamespace().concat(PREFS_SELECTED_ITEM),
|
||||||
|
oid.toString());
|
||||||
|
preferences.store();
|
||||||
|
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
errors.add(MessageFormat.format(getResourceBundle(actionRequest.getLocale()).
|
||||||
|
getString("contentItemJSRPortlet.errors.parameters.illegal_oid"),
|
||||||
|
itemOID));
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
errors.add(MessageFormat.format(getResourceBundle(actionRequest.getLocale())
|
||||||
|
.getString(
|
||||||
|
"contentItemJSRPortlet.errors.parameters.item_does_not_exist"),
|
||||||
|
itemOID));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,12 @@
|
||||||
javax.portlet.title=CCM Single Content Item
|
javax.portlet.title=CCM Single Content Item
|
||||||
javax.portlet.short-title=Single Content Item
|
javax.portlet.short-title=Single Content Item
|
||||||
|
|
||||||
|
contentItemJSRPortlet.errors.perferences.illegal_oid=The OID '{0}' set in the preferences is malformed.
|
||||||
|
contentItemJSRPortlet.errors.perferences.item_does_not_exist=The item identified by the OID {0} which is set in the preferences does not exist.
|
||||||
|
contentItemJSRPortlet.errors.parameters.illegal_oid=The OID '{0}' which as provided as parameter is invalid.
|
||||||
|
contentItemJSRPortlet.errors.parameters.item_does_not_exist=There is no item with the OID '{0}'.
|
||||||
|
|
||||||
|
contentItemJSRPortlet.edit.contentSectionSelect.label=Content section
|
||||||
|
contentitemJSRPortlet.edit.search.label=Title of the content item
|
||||||
|
|
||||||
|
contentItemJSRPortlet.edit.fieldset.label=Please choose the content item to display
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,9 @@
|
||||||
javax.portlet.title=Ein CCM Dokument
|
javax.portlet.title=Ein CCM Dokument
|
||||||
javax.portlet.short-title=Einzeldokument
|
javax.portlet.short-title=Einzeldokument
|
||||||
|
contentItemJSRPortlet.errors.perferences.illegal_oid=Die in den Einstellungen gespeicherte OID '{0}' ist fehlerhaft.
|
||||||
|
contentItemJSRPortlet.errors.perferences.item_does_not_exist=Es existiert kein ContentItem mit der konfigurierten OID '{0}'.
|
||||||
|
contentItemJSRPortlet.errors.parameters.illegal_oid=Die als Parameter \u00fcbergebene OID '{0}' ist fehlerhaft.
|
||||||
|
contentItemJSRPortlet.errors.parameters.item_does_not_exist=Es gibt kein Item mit der OID '{0}'.
|
||||||
|
contentItemJSRPortlet.edit.contentSectionSelect.label=Content Section
|
||||||
|
contentitemJSRPortlet.edit.search.label=Titel des Content Items
|
||||||
|
contentItemJSRPortlet.edit.fieldset.label=Bitte w\u00e4hlen Sie das anzuzeigende Content Item
|
||||||
|
|
|
||||||
|
|
@ -6,26 +6,62 @@
|
||||||
|
|
||||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
|
||||||
prefix="c" %>
|
prefix="c" %>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
|
||||||
|
prefix="fmt" %>
|
||||||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<div>
|
<div>
|
||||||
|
<fmt:setBundle basename="com.arsdigita.cms.portlet.ContentItemJSRPortletResources"/>
|
||||||
|
|
||||||
<h1>Hello World from ContentItemJSRPortletAdmin.jsp</h1>
|
<h1>Hello World from ContentItemJSRPortletAdmin.jsp</h1>
|
||||||
|
|
||||||
|
<ul class="errors">
|
||||||
|
<c:forEach var="error"
|
||||||
|
items="${errors}">
|
||||||
|
<li>${error}</li>
|
||||||
|
</c:forEach>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h2>Currently selected item</h2>
|
||||||
|
<c:if test="${selectedItemOID != null}">
|
||||||
|
<dl>
|
||||||
|
<dt>OID</dt>
|
||||||
|
<dd>${selectedItemOID}</dd>
|
||||||
|
|
||||||
|
<dt>Path</dt>
|
||||||
|
<dd>${selectedItemPath}</dd>
|
||||||
|
|
||||||
|
<dt>Title</dt>
|
||||||
|
<dd>${selectedItemTitle}</dd>
|
||||||
|
|
||||||
|
<dt>Type</dt>
|
||||||
|
<dd>${selectedItemType}</dd>
|
||||||
|
|
||||||
|
<dt>Status</dt>
|
||||||
|
<dd>${selectedItemStatus}</dd>
|
||||||
|
</dl>
|
||||||
|
</c:if>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form action='<portlet:actionURL/>' method="post">
|
<form action='<portlet:actionURL/>' method="post">
|
||||||
|
<fieldset>
|
||||||
|
<legend><fmt:message key="contentItemJSRPortlet.edit.fieldset.label"/></legend>
|
||||||
<label for="contentSectionSelect">
|
<label for="contentSectionSelect">
|
||||||
Content Section
|
<!--Content Section-->
|
||||||
</label>
|
<fmt:message key="contentItemJSRPortlet.edit.contentSectionSelect.label"/>
|
||||||
|
</label>
|
||||||
<select id="contentSectionSelect" name="contentSectionSelect">
|
<select id="contentSectionSelect" name="contentSectionSelect">
|
||||||
<c:forEach var="section"
|
<c:forEach var="section"
|
||||||
items="${contentSections}">
|
items="${contentSections}">
|
||||||
<option value="${section.specificOID}" ${section.specificOID == selectedContentSection ? 'selected="selected"' : ''}>${section.displayName}</option>
|
<option value="${section.specificOID}" ${section.specificOID == selectedContentSection ? 'selected="selected"' : ''}>${section.displayName}</option>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<label for="contentItemSearchString">
|
<label for="contentItemSearchString">
|
||||||
Search string
|
<fmt:message key="contentitemJSRPortlet.edit.search.label"/>
|
||||||
</label>
|
</label>
|
||||||
<input id="contentSearchString"
|
<input id="contentSearchString"
|
||||||
name="contentItemSearchString"
|
name="contentItemSearchString"
|
||||||
|
|
@ -33,10 +69,11 @@
|
||||||
maxlength="1000"
|
maxlength="1000"
|
||||||
size="40"
|
size="40"
|
||||||
value="${contentItemSearchString}"/>
|
value="${contentItemSearchString}"/>
|
||||||
|
|
||||||
<input type="submit" value="Find"/>
|
<input type="submit" value="Find"/>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<c:if test="${matchingItems != null}">
|
<c:if test="${matchingItems != null}">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|
@ -48,14 +85,19 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<c:forEach var="matchingItem" items="${matchingItems}">
|
<c:forEach var="matchingItem" items="${matchingItems}">
|
||||||
<tr>
|
<tr>
|
||||||
<td>${matchingItem.path}</td>
|
<td>${matchingItem.path}</td>
|
||||||
<td>${matchingItem.displayName}</td>
|
<td>${matchingItem.displayName}</td>
|
||||||
<td>
|
<td>
|
||||||
<!--This will be the select link for ${matchingItem.OID}-->
|
<portlet:actionURL portletMode="edit"
|
||||||
<a href="<portlet:actionURL/>?selectedItem=${matchingItem.OID}">Select</a>
|
var="selectURL">
|
||||||
</td>
|
<portlet:param name="action" value="selectItem"/>
|
||||||
</tr>
|
<portlet:param name="selectedItem" value="${matchingItem.OID}"/>
|
||||||
|
</portlet:actionURL>
|
||||||
|
<!--This will be the select link for ${matchingItem.OID}-->
|
||||||
|
<a href="${selectURL}">Select</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@ abstract public class DescriptiveComponent extends SimpleComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the labej for the component. It is specifically meant for
|
* Retrieve the label for the component. It is specifically meant for
|
||||||
* client classes which have to generate the xml on their own and can not
|
* client classes which have to generate the XML on their own and can not
|
||||||
* use the generateDescriptionXML method provided.
|
* use the generateDescriptionXML method provided.
|
||||||
*
|
*
|
||||||
* @return popup hint message for the component
|
* @return popup hint message for the component
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue