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.ContentItem;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentSectionCollection;
|
||||
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.portal.JSRPortlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletPreferences;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
|
@ -54,8 +61,15 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
* /WEB-INF/conf/log4j.properties int the runtime environment and set
|
||||
* com.arsdigita.portal.JSRPortlet=DEBUG by uncommenting or adding the line.
|
||||
*/
|
||||
private static final Logger s_log = Logger.getLogger(ContentItemJSRPortlet.class);
|
||||
private static final String BACKING_BEAN = "comArsdigitaCMSContentItemJSRPortletAdmin";
|
||||
private static final Logger LOGGER = Logger.getLogger(ContentItemJSRPortlet.class);
|
||||
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 search;
|
||||
|
||||
|
|
@ -83,7 +97,7 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
|
||||
request.setAttribute("contentSections", sections);
|
||||
request.setAttribute("selectedContentSection", selectedContentSection);
|
||||
request.setAttribute("contentItemSearchString", search);
|
||||
request.setAttribute(CONTENT_ITEM_SEARCH_STRING, search);
|
||||
|
||||
if ((selectedContentSection != null)) {
|
||||
final ContentSection selectedSection = new ContentSection(OID.valueOf(
|
||||
|
|
@ -102,8 +116,53 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
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(
|
||||
"/templates/portlets/ContentItemJSRPortletAdmin.jsp");
|
||||
dispatcher.include(request, response);
|
||||
|
|
@ -118,10 +177,10 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
protected void doHelp(RenderRequest request, RenderResponse response)
|
||||
protected void doHelp(final RenderRequest request, final RenderResponse response)
|
||||
throws PortletException, IOException {
|
||||
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.");
|
||||
}
|
||||
|
||||
|
|
@ -134,10 +193,10 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
protected void doView(RenderRequest request, RenderResponse response)
|
||||
protected void doView(final RenderRequest request, final RenderResponse response)
|
||||
throws PortletException, IOException {
|
||||
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.");
|
||||
}
|
||||
|
||||
|
|
@ -145,9 +204,44 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
public void processAction(final ActionRequest actionRequest,
|
||||
final ActionResponse actionResponse) throws PortletException,
|
||||
IOException {
|
||||
if (actionRequest.getParameter("contentSectionSelect") != null) {
|
||||
selectedContentSection = actionRequest.getParameter("contentSectionSelect");
|
||||
search = actionRequest.getParameter("contentItemSearchString");
|
||||
if (actionRequest.getParameter(CONTENT_SECTION_SELECT) != null) {
|
||||
selectedContentSection = actionRequest.getParameter(CONTENT_SECTION_SELECT);
|
||||
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.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.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"%>
|
||||
<%@ 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"%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<div>
|
||||
<fmt:setBundle basename="com.arsdigita.cms.portlet.ContentItemJSRPortletResources"/>
|
||||
|
||||
<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">
|
||||
<fieldset>
|
||||
<legend><fmt:message key="contentItemJSRPortlet.edit.fieldset.label"/></legend>
|
||||
<label for="contentSectionSelect">
|
||||
Content Section
|
||||
</label>
|
||||
<!--Content Section-->
|
||||
<fmt:message key="contentItemJSRPortlet.edit.contentSectionSelect.label"/>
|
||||
</label>
|
||||
<select id="contentSectionSelect" name="contentSectionSelect">
|
||||
<c:forEach var="section"
|
||||
items="${contentSections}">
|
||||
<option value="${section.specificOID}" ${section.specificOID == selectedContentSection ? 'selected="selected"' : ''}>${section.displayName}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
|
||||
|
||||
<label for="contentItemSearchString">
|
||||
Search string
|
||||
<fmt:message key="contentitemJSRPortlet.edit.search.label"/>
|
||||
</label>
|
||||
<input id="contentSearchString"
|
||||
name="contentItemSearchString"
|
||||
|
|
@ -33,10 +69,11 @@
|
|||
maxlength="1000"
|
||||
size="40"
|
||||
value="${contentItemSearchString}"/>
|
||||
|
||||
|
||||
<input type="submit" value="Find"/>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
<c:if test="${matchingItems != null}">
|
||||
<table>
|
||||
<thead>
|
||||
|
|
@ -48,14 +85,19 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="matchingItem" items="${matchingItems}">
|
||||
<tr>
|
||||
<td>${matchingItem.path}</td>
|
||||
<td>${matchingItem.displayName}</td>
|
||||
<td>
|
||||
<!--This will be the select link for ${matchingItem.OID}-->
|
||||
<a href="<portlet:actionURL/>?selectedItem=${matchingItem.OID}">Select</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>${matchingItem.path}</td>
|
||||
<td>${matchingItem.displayName}</td>
|
||||
<td>
|
||||
<portlet:actionURL portletMode="edit"
|
||||
var="selectURL">
|
||||
<portlet:param name="action" value="selectItem"/>
|
||||
<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>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ abstract public class DescriptiveComponent extends SimpleComponent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve the labej for the component. It is specifically meant for
|
||||
* client classes which have to generate the xml on their own and can not
|
||||
* 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
|
||||
* use the generateDescriptionXML method provided.
|
||||
*
|
||||
* @return popup hint message for the component
|
||||
|
|
|
|||
Loading…
Reference in New Issue