- Beispiel für ContentGenerator für PublicPersonalProfile
- Verbesserungen an der Admin-Oberfläche für PublicPersonalProfile git-svn-id: https://svn.libreccm.org/ccm/trunk@1085 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
7d0d88359d
commit
2d4708a679
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.arsdigita.cms.publicpersonalprofile;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An example implementation of the {@link ContentGenerator} interface.
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ExampleGenerator implements ContentGenerator {
|
||||||
|
|
||||||
|
public void generateContent(final Element parent,
|
||||||
|
final GenericPerson person) {
|
||||||
|
Element message = parent.newChildElement("message");
|
||||||
|
|
||||||
|
message.setText("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,6 +22,7 @@ import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
||||||
import com.arsdigita.cms.publicpersonalprofile.ui.PublicPersonalProfileNavItemsAddForm;
|
import com.arsdigita.cms.publicpersonalprofile.ui.PublicPersonalProfileNavItemsAddForm;
|
||||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.Session;
|
import com.arsdigita.persistence.Session;
|
||||||
|
|
@ -39,7 +40,6 @@ import java.math.BigDecimal;
|
||||||
import java.rmi.ServerException;
|
import java.rmi.ServerException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
@ -60,6 +60,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
private static final String PREVIEW = "preview";
|
private static final String PREVIEW = "preview";
|
||||||
private static final String PPP_NS =
|
private static final String PPP_NS =
|
||||||
"http://www.arsdigita.com/PublicPersonalProfile/1.0";
|
"http://www.arsdigita.com/PublicPersonalProfile/1.0";
|
||||||
|
public static final String SELECTED_NAV_ITEM = "selectedNavItem";
|
||||||
private final PublicPersonalProfileConfig config = PublicPersonalProfiles.
|
private final PublicPersonalProfileConfig config = PublicPersonalProfiles.
|
||||||
getConfig();
|
getConfig();
|
||||||
|
|
||||||
|
|
@ -218,7 +219,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
newInstance();
|
newInstance();
|
||||||
|
|
||||||
if (generatorObj instanceof ContentGenerator) {
|
if (generatorObj instanceof ContentGenerator) {
|
||||||
final ContentGenerator generator = (ContentGenerator) generatorObj;
|
final ContentGenerator generator =
|
||||||
|
(ContentGenerator) generatorObj;
|
||||||
|
|
||||||
generator.generateContent(root, owner);
|
generator.generateContent(root, owner);
|
||||||
|
|
||||||
|
|
@ -520,19 +522,19 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
page.setClassAttr("adminPage");
|
page.setClassAttr("adminPage");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final BoxPanel box = new BoxPanel(BoxPanel.VERTICAL);
|
final BoxPanel box = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
final FormSection tableSection = new FormSection(box);
|
final FormSection tableSection = new FormSection(box);
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemsAddForm addForm =
|
||||||
|
new PublicPersonalProfileNavItemsAddForm();
|
||||||
final PublicPersonalProfileNavItemsTable table =
|
final PublicPersonalProfileNavItemsTable table =
|
||||||
new PublicPersonalProfileNavItemsTable();
|
new PublicPersonalProfileNavItemsTable(
|
||||||
|
addForm);
|
||||||
|
|
||||||
box.add(table);
|
box.add(table);
|
||||||
form.add(tableSection);
|
form.add(tableSection);
|
||||||
|
|
||||||
box.add(new PublicPersonalProfileNavItemsAddForm());
|
box.add(addForm);
|
||||||
|
|
||||||
page.add(form);
|
page.add(form);
|
||||||
page.lock();
|
page.lock();
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.arsdigita.bebop.SaveCancelSection;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.event.FormValidationListener;
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
import com.arsdigita.bebop.form.Option;
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
|
@ -38,13 +39,16 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
extends FormSection
|
extends FormSection
|
||||||
implements FormInitListener,
|
implements FormInitListener,
|
||||||
FormProcessListener,
|
FormProcessListener,
|
||||||
FormValidationListener {
|
FormValidationListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
private final FormSection widgetSection;
|
private final FormSection widgetSection;
|
||||||
private final SaveCancelSection saveCancelSection;
|
private final SaveCancelSection saveCancelSection;
|
||||||
|
private PublicPersonalProfileNavItem selected;
|
||||||
|
|
||||||
public PublicPersonalProfileNavItemsAddForm() {
|
public PublicPersonalProfileNavItemsAddForm() {
|
||||||
super(new ColumnPanel(2));
|
super(new ColumnPanel(2));
|
||||||
|
|
||||||
widgetSection = new FormSection(new ColumnPanel(2, true));
|
widgetSection = new FormSection(new ColumnPanel(2, true));
|
||||||
super.add(widgetSection, ColumnPanel.INSERT);
|
super.add(widgetSection, ColumnPanel.INSERT);
|
||||||
|
|
||||||
|
|
@ -94,6 +98,15 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
labelField.addValidationListener(new NotEmptyValidationListener());
|
labelField.addValidationListener(new NotEmptyValidationListener());
|
||||||
panel.add(labelField);
|
panel.add(labelField);
|
||||||
|
|
||||||
|
panel.add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.generatorclass")));
|
||||||
|
final ParameterModel generatorParam =
|
||||||
|
new StringParameter(
|
||||||
|
PublicPersonalProfileNavItem.GENERATOR_CLASS);
|
||||||
|
final TextField generatorField = new TextField(generatorParam);
|
||||||
|
generatorField.setMaxLength(512);
|
||||||
|
panel.add(generatorField);
|
||||||
|
|
||||||
saveCancelSection = new SaveCancelSection();
|
saveCancelSection = new SaveCancelSection();
|
||||||
super.add(saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
super.add(saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
|
||||||
|
|
@ -104,11 +117,24 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||||
FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
|
|
||||||
data.put(PublicPersonalProfileNavItem.KEY, "");
|
if (selected == null) {
|
||||||
data.put(PublicPersonalProfileNavItem.LANG, "");
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
||||||
|
} else {
|
||||||
|
data.put(PublicPersonalProfileNavItem.KEY,
|
||||||
|
selected.getKey());
|
||||||
|
data.put(PublicPersonalProfileNavItem.LANG,
|
||||||
|
selected.getLang());
|
||||||
|
data.put(PublicPersonalProfileNavItem.LABEL,
|
||||||
|
selected.getLabel());
|
||||||
|
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS,
|
||||||
|
selected.getGeneratorClass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(final FormSectionEvent fse)
|
public void process(final FormSectionEvent fse)
|
||||||
|
|
@ -116,39 +142,74 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
PublicPersonalProfileNavItemCollection navItems =
|
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||||
new PublicPersonalProfileNavItemCollection();
|
PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
|
||||||
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
||||||
new HashMap<String, PublicPersonalProfileNavItem>();
|
new HashMap<String, PublicPersonalProfileNavItem>();
|
||||||
while (navItems.next()) {
|
while (navItems.next()) {
|
||||||
navItemMap.put(navItems.getNavItem().getKey(), navItems.getNavItem());
|
navItemMap.put(navItems.getNavItem().getKey(), navItems.
|
||||||
}
|
getNavItem());
|
||||||
final int numberOfKeys = navItemMap.size();
|
}
|
||||||
|
final int numberOfKeys = navItemMap.size();
|
||||||
|
|
||||||
PublicPersonalProfileNavItem item = new PublicPersonalProfileNavItem();
|
PublicPersonalProfileNavItem item;
|
||||||
|
if (selected == null) {
|
||||||
|
item = new PublicPersonalProfileNavItem();
|
||||||
|
item.setId(new BigDecimal(navItems.size() + 1));
|
||||||
|
} else {
|
||||||
|
item = selected;
|
||||||
|
}
|
||||||
|
|
||||||
item.setId(new BigDecimal(navItems.size() + 1));
|
item.setKey((String) data.get(PublicPersonalProfileNavItem.KEY));
|
||||||
item.setKey((String) data.get(PublicPersonalProfileNavItem.KEY));
|
item.setLang((String) data.get(PublicPersonalProfileNavItem.LANG));
|
||||||
item.setLang((String) data.get(PublicPersonalProfileNavItem.LANG));
|
item.setLabel((String) data.get(PublicPersonalProfileNavItem.LABEL));
|
||||||
item.setLabel((String) data.get(PublicPersonalProfileNavItem.LABEL));
|
if (data.get(PublicPersonalProfileNavItem.GENERATOR_CLASS) != null) {
|
||||||
final PublicPersonalProfileNavItem navItem =
|
item.setGeneratorClass((String) data.get(
|
||||||
navItemMap.get((String) data.get(
|
PublicPersonalProfileNavItem.GENERATOR_CLASS));
|
||||||
PublicPersonalProfileNavItem.KEY));
|
}
|
||||||
if (navItem == null) {
|
final PublicPersonalProfileNavItem navItem =
|
||||||
item.setOrder(numberOfKeys + 1);
|
navItemMap.get((String) data.get(
|
||||||
} else {
|
PublicPersonalProfileNavItem.KEY));
|
||||||
item.setOrder(navItem.getOrder());
|
if (navItem == null) {
|
||||||
|
item.setOrder(numberOfKeys + 1);
|
||||||
|
} else {
|
||||||
|
item.setOrder(navItem.getOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
item.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
item.save();
|
this.selected = null;
|
||||||
|
|
||||||
data.put(PublicPersonalProfileNavItem.KEY, "");
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LANG, "");
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(final FormSectionEvent fse)
|
public void validate(final FormSectionEvent fse)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submitted(final FormSectionEvent fse)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
||||||
|
this.selected = null;
|
||||||
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSelectedNavItem(
|
||||||
|
final PublicPersonalProfileNavItem selected) {
|
||||||
|
this.selected = selected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,8 @@ import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
||||||
import com.arsdigita.cms.contenttypes.ui.PublicPersonalProfileGlobalizationUtil;
|
import com.arsdigita.cms.contenttypes.ui.PublicPersonalProfileGlobalizationUtil;
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
@ -34,9 +32,14 @@ public class PublicPersonalProfileNavItemsTable
|
||||||
private final static String TABLE_COL_UP = "table_col_up";
|
private final static String TABLE_COL_UP = "table_col_up";
|
||||||
private final static String TABLE_COL_DOWN = "table_col_down";
|
private final static String TABLE_COL_DOWN = "table_col_down";
|
||||||
private final static String TABLE_COL_DELETE = "table_col_delete";
|
private final static String TABLE_COL_DELETE = "table_col_delete";
|
||||||
private final static String TABLE_COL_EDIT = "table_col_delete";
|
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final PublicPersonalProfileNavItemsAddForm addForm;
|
||||||
|
|
||||||
|
public PublicPersonalProfileNavItemsTable(
|
||||||
|
final PublicPersonalProfileNavItemsAddForm addForm) {
|
||||||
|
|
||||||
|
this.addForm = addForm;
|
||||||
|
|
||||||
public PublicPersonalProfileNavItemsTable() {
|
|
||||||
setEmptyView(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
setEmptyView(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
"publicpersonalprofile.ui.no_nav_items")));
|
"publicpersonalprofile.ui.no_nav_items")));
|
||||||
|
|
||||||
|
|
@ -121,9 +124,10 @@ public class PublicPersonalProfileNavItemsTable
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
final PublicPersonalProfileNavItemCollection items = new PublicPersonalProfileNavItemCollection();
|
final PublicPersonalProfileNavItemCollection items =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
final Set<String> keys = new HashSet<String>();
|
final Set<String> keys = new HashSet<String>();
|
||||||
while(items.next()) {
|
while (items.next()) {
|
||||||
keys.add(items.getNavItem().getKey());
|
keys.add(items.getNavItem().getKey());
|
||||||
}
|
}
|
||||||
numberOfKeys = keys.size();
|
numberOfKeys = keys.size();
|
||||||
|
|
@ -290,7 +294,9 @@ public class PublicPersonalProfileNavItemsTable
|
||||||
intValue());
|
intValue());
|
||||||
|
|
||||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||||
|
addForm.setSelectedNavItem(navItem);
|
||||||
} else if (TABLE_COL_DELETE.equals(column.getHeaderKey().toString())) {
|
} else if (TABLE_COL_DELETE.equals(column.getHeaderKey().toString())) {
|
||||||
|
navItem.delete();
|
||||||
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
||||||
navItems.swapWithPrevious(navItem);
|
navItems.swapWithPrevious(navItem);
|
||||||
} else if (TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
|
} else if (TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue