Several references to JavaScript files (e.g. manipulate-input.js used in the ContentCenter to urlize the name of ContentItem) did not work when CCM is not running in the ROOT context. This is now fixed.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2712 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-06-21 16:58:42 +00:00
parent beb861d78c
commit f09f59b750
18 changed files with 361 additions and 343 deletions

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.contenttypes.ui.mparticle; package com.arsdigita.cms.contenttypes.ui.mparticle;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
@ -49,13 +48,13 @@ import com.arsdigita.cms.contenttypes.util.MPArticleGlobalizationUtil;
import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import java.util.Date; import java.util.Date;
/** /**
* A form for editing MultiPartArticle and subclasses. * A form for editing MultiPartArticle and subclasses.
* *
@ -78,12 +77,12 @@ public abstract class MultiPartArticleForm extends FormSection
private static final Logger s_log = Logger.getLogger(MultiPartArticleForm.class); private static final Logger s_log = Logger.getLogger(MultiPartArticleForm.class);
public MultiPartArticleForm ( String formName, ItemSelectionModel itemModel ) { public MultiPartArticleForm(String formName, ItemSelectionModel itemModel) {
super(new ColumnPanel(2)); super(new ColumnPanel(2));
m_itemModel = itemModel; m_itemModel = itemModel;
ColumnPanel panel = (ColumnPanel)getPanel(); ColumnPanel panel = (ColumnPanel) getPanel();
panel.setBorder(false); panel.setBorder(false);
panel.setPadColor("#FFFFFF"); panel.setPadColor("#FFFFFF");
panel.setColumnWidth(1, "20%"); panel.setColumnWidth(1, "20%");
@ -99,33 +98,30 @@ public abstract class MultiPartArticleForm extends FormSection
addValidationListener(this); addValidationListener(this);
} }
public void addSaveCancelSection() {
public void addSaveCancelSection () {
m_saveCancelSection = new SaveCancelSection(); m_saveCancelSection = new SaveCancelSection();
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
} }
public SaveCancelSection getSaveCancelSection() {
public SaveCancelSection getSaveCancelSection () {
return m_saveCancelSection; return m_saveCancelSection;
} }
private Label m_script = new Label(String.format(
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false);
private Label m_script = new Label("<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", false); protected void addWidgets() {
protected void addWidgets () {
add(new Label(GlobalizationUtil add(new Label(GlobalizationUtil
.globalize("cms.contenttypes.ui.title"))); .globalize("cms.contenttypes.ui.title")));
TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE)); TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE));
titleWidget.addValidationListener(new NotNullValidationListener()); titleWidget.addValidationListener(new NotNullValidationListener());
titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " + titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { "
" defaulting = true; this.form." + NAME + + " defaulting = true; this.form." + NAME
".value = urlize(this.value); }"); + ".value = urlize(this.value); }");
titleWidget.setOnKeyUp( titleWidget.setOnKeyUp(
"if (defaulting) { this.form." + NAME + "if (defaulting) { this.form." + NAME + ".value = urlize(this.value) }"
".value = urlize(this.value) }"
); );
add(titleWidget); add(titleWidget);
@ -136,9 +132,8 @@ public abstract class MultiPartArticleForm extends FormSection
nameWidget.addValidationListener(new URLTokenValidationListener()); nameWidget.addValidationListener(new URLTokenValidationListener());
nameWidget.setOnFocus("defaulting = false"); nameWidget.setOnFocus("defaulting = false");
nameWidget.setOnBlur( nameWidget.setOnBlur(
"if (this.value == '') " + "if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + TITLE
"{ defaulting = true; this.value = urlize(this.form." + TITLE + + ".value) }"
".value) }"
); );
add(nameWidget); add(nameWidget);
@ -149,7 +144,9 @@ public abstract class MultiPartArticleForm extends FormSection
com.arsdigita.bebop.form.Date launchDate com.arsdigita.bebop.form.Date launchDate
= new com.arsdigita.bebop.form.Date(launchDateParam); = new com.arsdigita.bebop.form.Date(launchDateParam);
if (ContentSection.getConfig().getRequireLaunchDate()) { if (ContentSection.getConfig().getRequireLaunchDate()) {
launchDate.addValidationListener(new NotNullValidationListener(MPArticleGlobalizationUtil.globalize("cms.contenttypes.ui.mparticle.no_launch_date"))); launchDate.addValidationListener(new NotNullValidationListener(
MPArticleGlobalizationUtil.globalize(
"cms.contenttypes.ui.mparticle.no_launch_date")));
// if launch date is required, help user by suggesting today's date // if launch date is required, help user by suggesting today's date
launchDateParam.setDefaultValue(new Date()); launchDateParam.setDefaultValue(new Date());
} }
@ -161,8 +158,7 @@ public abstract class MultiPartArticleForm extends FormSection
TextArea summaryWidget = new TextArea(new TrimmedStringParameter(SUMMARY)); TextArea summaryWidget = new TextArea(new TrimmedStringParameter(SUMMARY));
if (ContentSection.getConfig().mandatoryDescriptions()) { if (ContentSection.getConfig().mandatoryDescriptions()) {
summaryWidget summaryWidget
.addValidationListener(new .addValidationListener(new NotEmptyValidationListener(GlobalizationUtil
NotEmptyValidationListener(GlobalizationUtil
.globalize("cms.contenttypes.ui.description_missing"))); .globalize("cms.contenttypes.ui.description_missing")));
} }
summaryWidget.setRows(5); summaryWidget.setRows(5);
@ -172,21 +168,23 @@ public abstract class MultiPartArticleForm extends FormSection
add(summaryWidget); add(summaryWidget);
} }
public abstract void init ( FormSectionEvent e ) throws FormProcessException; public abstract void init(FormSectionEvent e) throws FormProcessException;
public abstract void process ( FormSectionEvent e ) throws FormProcessException;
public abstract void validate ( FormSectionEvent e ) throws FormProcessException;
public abstract void process(FormSectionEvent e) throws FormProcessException;
/** Utility method to initialize the name/title/summary widgets */ public abstract void validate(FormSectionEvent e) throws FormProcessException;
public MultiPartArticle initBasicWidgets ( FormSectionEvent e ) {
/**
* Utility method to initialize the name/title/summary widgets
*/
public MultiPartArticle initBasicWidgets(FormSectionEvent e) {
Assert.exists(m_itemModel, ItemSelectionModel.class); Assert.exists(m_itemModel, ItemSelectionModel.class);
FormData data = e.getFormData(); FormData data = e.getFormData();
PageState state = e.getPageState(); PageState state = e.getPageState();
MultiPartArticle article = MultiPartArticle article = (MultiPartArticle) m_itemModel.getSelectedObject(state);
(MultiPartArticle)m_itemModel.getSelectedObject(state);
if ( article != null ) { if (article != null) {
data.put(NAME, article.getName()); data.put(NAME, article.getName());
data.put(TITLE, article.getTitle()); data.put(TITLE, article.getTitle());
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
@ -198,23 +196,23 @@ public abstract class MultiPartArticleForm extends FormSection
return article; return article;
} }
/**
* Utility method to process the name/title/summary widgets
/** Utility method to process the name/title/summary widgets */ */
public MultiPartArticle processBasicWidgets ( FormSectionEvent e ) { public MultiPartArticle processBasicWidgets(FormSectionEvent e) {
Assert.exists(m_itemModel, ItemSelectionModel.class); Assert.exists(m_itemModel, ItemSelectionModel.class);
FormData data = e.getFormData(); FormData data = e.getFormData();
PageState state = e.getPageState(); PageState state = e.getPageState();
MultiPartArticle article = (MultiPartArticle)m_itemModel.getSelectedObject(state); MultiPartArticle article = (MultiPartArticle) m_itemModel.getSelectedObject(state);
if ( article != null ) { if (article != null) {
article.setName((String)data.get(NAME)); article.setName((String) data.get(NAME));
article.setTitle((String)data.get(TITLE)); article.setTitle((String) data.get(TITLE));
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
article.setLaunchDate((Date)data.get(LAUNCH_DATE)); article.setLaunchDate((Date) data.get(LAUNCH_DATE));
} }
article.setSummary((String)data.get(SUMMARY)); article.setSummary((String) data.get(SUMMARY));
} }
return article; return article;
@ -224,16 +222,16 @@ public abstract class MultiPartArticleForm extends FormSection
* Ensure that the name of an item is unique within a folder. * Ensure that the name of an item is unique within a folder.
* *
* @param folder the folder in which to check * @param folder the folder in which to check
* @param event the FormSectionEvent which was passed to the * @param event the FormSectionEvent which was passed to the validation listener
* validation listener *
* @return true if the name is not null and unique, false otherwise * @return true if the name is not null and unique, false otherwise
*/ */
public boolean validateNameUniqueness ( Folder folder, FormSectionEvent event) { public boolean validateNameUniqueness(Folder folder, FormSectionEvent event) {
FormData data = event.getFormData(); FormData data = event.getFormData();
String name = (String)data.get(NAME); String name = (String) data.get(NAME);
if ( name != null ) { if (name != null) {
final String query = "com.arsdigita.cms.validateUniqueItemName"; final String query = "com.arsdigita.cms.validateUniqueItemName";
DataQuery dq = SessionManager.getSession().retrieveQuery(query); DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("parentId", folder.getID()); dq.setParameter("parentId", folder.getID());
@ -246,33 +244,29 @@ public abstract class MultiPartArticleForm extends FormSection
return false; return false;
} }
/** /**
* Utility method to create a new MultiPartArticle and update the * Utility method to create a new MultiPartArticle and update the selected model. This can be
* selected model. This can be called in the process method of a * called in the process method of a ProcessListener.
* ProcessListener.
* *
* @param state the current page state * @param state the current page state
*
* @return the new content item (or a proper subclass) * @return the new content item (or a proper subclass)
*/ */
public MultiPartArticle createArticle ( PageState state ) public MultiPartArticle createArticle(PageState state)
throws FormProcessException throws FormProcessException {
{
Assert.exists(m_itemModel, ItemSelectionModel.class); Assert.exists(m_itemModel, ItemSelectionModel.class);
MultiPartArticle article = null; MultiPartArticle article = null;
try { try {
article = (MultiPartArticle)m_itemModel.createItem(); article = (MultiPartArticle) m_itemModel.createItem();
} catch(ServletException e) { } catch (ServletException e) {
s_log.error("Servlet Exception: " + e.getMessage(), e); s_log.error("Servlet Exception: " + e.getMessage(), e);
throw new FormProcessException(e.getMessage(), e); throw new FormProcessException(e.getMessage(), e);
} }
if (m_itemModel.getSelectedKey(state) == null) {
if ( m_itemModel.getSelectedKey(state) == null ) {
m_itemModel.setSelectedObject(state, article); m_itemModel.setSelectedObject(state, article);
} }
@ -284,6 +278,4 @@ public abstract class MultiPartArticleForm extends FormSection
super.generateXML(ps, parent); super.generateXML(ps, parent);
} }
} }

View File

@ -24,6 +24,7 @@ import com.arsdigita.portal.JSRPortlet;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import javax.portlet.PortletException; import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest; import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse; import javax.portlet.RenderResponse;
@ -57,9 +58,11 @@ public class ContentItemJSRPortlet extends JSRPortlet {
@Override @Override
protected void doEdit(RenderRequest request, RenderResponse response) protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException { throws PortletException, IOException {
response.setContentType("text/html"); //response.setContentType("text/html");
PrintWriter writer = new PrintWriter(response.getWriter()); //PrintWriter writer = new PrintWriter(response.getWriter());
writer.println("You're now in Edit mode."); //writer.println("You're now in Edit mode.");
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/templates/portlets/ContentItemJSRPortletAdmin.jsp");
dispatcher.include(request, response);
} }
/** /**

View File

@ -46,6 +46,7 @@ import static com.arsdigita.cms.util.GlobalizationUtil.globalize;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -145,8 +146,9 @@ public abstract class BasicItemForm extends FormSection
/** /**
* Currently, to insert javascript code the Label Widget is "abused". * Currently, to insert javascript code the Label Widget is "abused".
*/ */
private final Label m_script = new Label( private final Label m_script = new Label(String.format(
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", "<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false); false);
/** /**

View File

@ -34,6 +34,7 @@ import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.categorization.CategoryCollection;
import com.arsdigita.cms.ui.BaseForm; import com.arsdigita.cms.ui.BaseForm;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -57,8 +58,9 @@ class BaseCategoryForm extends BaseForm {
final RadioGroup m_isAbstract; final RadioGroup m_isAbstract;
final RadioGroup m_isVisible; final RadioGroup m_isVisible;
final RadioGroup m_isEnabled; final RadioGroup m_isEnabled;
private Label m_script = new Label( private Label m_script = new Label(String.format(
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", "<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false); false);
private final static String NAME = "name"; private final static String NAME = "name";
private final static String DESCRIPTION = "description"; private final static String DESCRIPTION = "description";

View File

@ -40,13 +40,14 @@ import com.arsdigita.categorization.CategoryCollection;
import com.arsdigita.cms.ui.BaseForm; import com.arsdigita.cms.ui.BaseForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
/** /**
* Base class for CategoryLocalizationAddForm and CategoryLocalizationEditForm. * Base class for CategoryLocalizationAddForm and CategoryLocalizationEditForm.
* *
* This class is part of the admin GUI of CCM and extends the standard form * This class is part of the admin GUI of CCM and extends the standard form in order to present
* in order to present forms for managing the multi-language categories. * forms for managing the multi-language categories.
* *
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
* @version $Id: $ * @version $Id: $
@ -59,9 +60,10 @@ public class CategoryLocalizationForm extends BaseForm {
final TextArea m_description; final TextArea m_description;
final TextField m_url; final TextField m_url;
final RadioGroup m_isEnabled; final RadioGroup m_isEnabled;
private Label m_script = new Label( private Label m_script = new Label(String.format(
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\">"+ "<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\">" + "</script>",
"</script>", false); Web.getWebappContextPath()),
false);
private final static String LOCALE = "locale"; private final static String LOCALE = "locale";
private final static String NAME = "name"; private final static String NAME = "name";
@ -92,13 +94,14 @@ public class CategoryLocalizationForm extends BaseForm {
// the --select one-- option is not allowed // the --select one-- option is not allowed
ParameterData data = e.getParameterData(); ParameterData data = e.getParameterData();
String code = (String) data.getValue() ; String code = (String) data.getValue();
if (code == null || code.length() == 0) { if (code == null || code.length() == 0) {
data.addError( data.addError(
(String)GlobalizationUtil.globalize( (String) GlobalizationUtil.globalize(
"cms.ui.category.localization_error_locale").localize()); "cms.ui.category.localization_error_locale").localize());
} }
} }
}); });
addField(gz("cms.ui.category.localization_locale"), m_locale); addField(gz("cms.ui.category.localization_locale"), m_locale);
@ -109,20 +112,18 @@ public class CategoryLocalizationForm extends BaseForm {
m_name.setSize(30); m_name.setSize(30);
m_name.setMaxLength(200); m_name.setMaxLength(200);
m_name.addValidationListener(new NotNullValidationListener()); m_name.addValidationListener(new NotNullValidationListener());
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " + m_name.setOnFocus("if (this.form." + URL + ".value == '') { "
" defaulting = true; this.form." + URL + + " defaulting = true; this.form." + URL
".value = urlize(this.value); }"); + ".value = urlize(this.value); }");
m_name.setOnKeyUp("if (defaulting) { this.form." + URL + m_name.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }");
".value = urlize(this.value) }");
// is enabled? // is enabled?
m_isEnabled = new RadioGroup(IS_ENABLED); m_isEnabled = new RadioGroup(IS_ENABLED);
m_isEnabled.addOption(new Option("no", new Label(gz("cms.ui.no")))); m_isEnabled.addOption(new Option("no", new Label(gz("cms.ui.no"))));
m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes")))); m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_enabled"),m_isEnabled); addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
m_description = new TextArea m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
(new TrimmedStringParameter(DESCRIPTION));
addField(gz("cms.ui.description"), m_description); addField(gz("cms.ui.description"), m_description);
m_description.setWrap(TextArea.SOFT); m_description.setWrap(TextArea.SOFT);
@ -146,11 +147,10 @@ public class CategoryLocalizationForm extends BaseForm {
m_url.setMaxLength(200); m_url.setMaxLength(200);
m_url.addValidationListener(new NotNullValidationListener()); m_url.addValidationListener(new NotNullValidationListener());
m_url.setOnFocus("defaulting = false"); m_url.setOnFocus("defaulting = false");
m_url.setOnBlur("if (this.value == '') " + m_url.setOnBlur("if (this.value == '') "
"{ defaulting = true; this.value = urlize(this.form." + NAME + + "{ defaulting = true; this.value = urlize(this.form." + NAME
".value) } " + + ".value) } " + "else { this.value = urlize(this.value); }");
"else { this.value = urlize(this.value); }"); addField(gz("cms.ui.category.url"), m_url);
addField(gz("cms.ui.category.url"),m_url);
addAction(new Finish()); addAction(new Finish());
addAction(new Cancel()); addAction(new Cancel());
@ -165,10 +165,11 @@ public class CategoryLocalizationForm extends BaseForm {
/** /**
* Purpose: * Purpose:
* *
* XXXToDo: Should be extended with the function: * XXXToDo: Should be extended with the function: Names have to be unambiguous in the selected
* Names have to be unambiguous in the selected language * language
*/ */
class NameUniqueListener implements ParameterListener { class NameUniqueListener implements ParameterListener {
private final CategoryRequestLocal m_category; private final CategoryRequestLocal m_category;
private final Widget m_widget; private final Widget m_widget;
private final int m_type; private final int m_type;
@ -176,8 +177,9 @@ public class CategoryLocalizationForm extends BaseForm {
public final static int URL_FIELD = 2; public final static int URL_FIELD = 2;
NameUniqueListener(final CategoryRequestLocal category) { NameUniqueListener(final CategoryRequestLocal category) {
this(category,m_name,NAME_FIELD); this(category, m_name, NAME_FIELD);
} }
NameUniqueListener(final CategoryRequestLocal category, NameUniqueListener(final CategoryRequestLocal category,
Widget widget, int type) { Widget widget, int type) {
m_category = category; m_category = category;
@ -185,13 +187,13 @@ public class CategoryLocalizationForm extends BaseForm {
m_type = type; m_type = type;
} }
/** /**
* Purpose: * Purpose:
* *
* XXX provisional, has to be adapted * XXX provisional, has to be adapted
* *
* @param e * @param e
*
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
public final void validate(final ParameterEvent e) public final void validate(final ParameterEvent e)
@ -205,15 +207,15 @@ public class CategoryLocalizationForm extends BaseForm {
while (children.next()) { while (children.next()) {
final Category child = children.getCategory(); final Category child = children.getCategory();
String compField = String compField = (m_type == URL_FIELD) ? child.getURL() : child.getName();
(m_type == URL_FIELD) ? child.getURL() : child.getName();
if (compField.equalsIgnoreCase(title) if (compField.equalsIgnoreCase(title)
&& (m_category == null && (m_category == null
|| !m_category.getCategory(state).equals(child))) { || !m_category.getCategory(state).equals(child))) {
throw new FormProcessException throw new FormProcessException(lz("cms.ui.category.name_not_unique"));
(lz("cms.ui.category.name_not_unique"));
} }
} }
} }
} }
} }

View File

@ -30,11 +30,11 @@ import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ui.CMSForm; import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.web.Web;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Class FolderForm implements the basic form for creating or renaming * Class FolderForm implements the basic form for creating or renaming folders.
* folders.
* *
* @author Jon Orris &lt;jorris@redhat.com&gt; * @author Jon Orris &lt;jorris@redhat.com&gt;
* @version $Id: FolderBaseForm.java 1951 2009-06-30 04:35:04Z terry $ * @version $Id: FolderBaseForm.java 1951 2009-06-30 04:35:04Z terry $
@ -46,29 +46,26 @@ abstract class FolderBaseForm extends CMSForm {
public static final String NAME = ContentItem.NAME; public static final String NAME = ContentItem.NAME;
public static final String TITLE = ContentPage.TITLE; public static final String TITLE = ContentPage.TITLE;
private static final String TITLE_ON_FOCUS = private static final String TITLE_ON_FOCUS = "if (this.form." + NAME + ".value == '') {"
"if (this.form." + NAME + ".value == '') {" + + " defaulting = true;" + " this.form."
" defaulting = true;" + + NAME + ".value = urlize(this.value);" + "}";
" this.form." + NAME + ".value = urlize(this.value);" +
"}";
private static final String TITLE_ON_KEY_UP = private static final String TITLE_ON_KEY_UP = "if (defaulting) {" + " this.form." + NAME
"if (defaulting) {" + + ".value = urlize(this.value)" + "}";
" this.form." + NAME + ".value = urlize(this.value)" +
"}";
private static final String FRAGMENT_ON_FOCUS = "defaulting = false"; private static final String FRAGMENT_ON_FOCUS = "defaulting = false";
private static final String FRAGMENT_ON_BLUR = private static final String FRAGMENT_ON_BLUR = "if (this.value == '') {"
"if (this.value == '') {" + + " defaulting = true;"
" defaulting = true;" + + " this.value = urlize(this.form." + TITLE
" this.value = urlize(this.form." + TITLE + ".value)" + + ".value)" + "} else {"
"} else {" + + " this.value = urlize(this.value);" + "}";
" this.value = urlize(this.value);" +
"}";
private Label m_script = new Label("<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", false);
private Label m_script = new Label(
String.format(
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false);
final TextField m_title; final TextField m_title;
final TextField m_fragment; final TextField m_fragment;
@ -80,7 +77,6 @@ abstract class FolderBaseForm extends CMSForm {
add(m_script, GridPanel.FULL_WIDTH); add(m_script, GridPanel.FULL_WIDTH);
// Title // Title
add(new Label(gz("cms.ui.folder.name"))); add(new Label(gz("cms.ui.folder.name")));
m_title = new TextField(new TrimmedStringParameter(TITLE)); m_title = new TextField(new TrimmedStringParameter(TITLE));
@ -93,7 +89,6 @@ abstract class FolderBaseForm extends CMSForm {
m_title.setOnKeyUp(TITLE_ON_KEY_UP); m_title.setOnKeyUp(TITLE_ON_KEY_UP);
// Fragment // Fragment
add(new Label(gz("cms.ui.folder.fragment"))); add(new Label(gz("cms.ui.folder.fragment")));
m_fragment = new TextField(new TrimmedStringParameter(NAME)); m_fragment = new TextField(new TrimmedStringParameter(NAME));
@ -119,4 +114,5 @@ abstract class FolderBaseForm extends CMSForm {
private static String lz(final String key) { private static String lz(final String key) {
return (String) gz(key).localize(); return (String) gz(key).localize();
} }
} }

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.formbuilder.ui; package com.arsdigita.formbuilder.ui;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
@ -40,7 +39,7 @@ import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.formbuilder.PersistentFormSection; import com.arsdigita.formbuilder.PersistentFormSection;
import com.arsdigita.formbuilder.PersistentProcessListener; import com.arsdigita.formbuilder.PersistentProcessListener;
import com.arsdigita.formbuilder.util.FormBuilderUtil; import com.arsdigita.formbuilder.util.FormBuilderUtil;
import com.arsdigita.formbuilder.util.GlobalizationUtil ; import com.arsdigita.formbuilder.util.GlobalizationUtil;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.RedirectSignal; import com.arsdigita.web.RedirectSignal;
@ -49,10 +48,9 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* This class provides a pluggable widget for editing the persistent process * This class provides a pluggable widget for editing the persistent process listeners for a
* listeners for a persistent form. * persistent form. It is designed to be used without requiring any significant infrastructure on a
* It is designed to be used without requiring any significant * page.
* infrastructure on a page.
*/ */
public class ProcessListenerEditor extends SimpleContainer { public class ProcessListenerEditor extends SimpleContainer {
@ -64,9 +62,8 @@ public class ProcessListenerEditor extends SimpleContainer {
protected ProcessListenerProperties m_edit_action; protected ProcessListenerProperties m_edit_action;
/** /**
* Constructor, creates a new control editor widget for editing the form * Constructor, creates a new control editor widget for editing the form specified in the single
* specified in the single selection model. The key returned by the single * selection model. The key returned by the single selection model should be an instance of the
* selection model should be an instance of the
* {@link java.math.BigDecimal} class. * {@link java.math.BigDecimal} class.
* *
* @param form the form to edit * @param form the form to edit
@ -78,30 +75,30 @@ public class ProcessListenerEditor extends SimpleContainer {
// Help system is currently not workable // Help system is currently not workable
String helpURL = FormBuilderUtil.getConfig().getActionsHelpLink(); String helpURL = FormBuilderUtil.getConfig().getActionsHelpLink();
if (helpURL != null) { if (helpURL != null) {
add(new Link(new Label(GlobalizationUtil.globalize add(new Link(new Label(GlobalizationUtil.globalize("formbuilder.ui.help")), helpURL));
("formbuilder.ui.help")), helpURL));
} }
m_newAction = new NewAction(app); m_newAction = new NewAction(app);
Table t = new Table(new ProcessListenerTableModelBuilder(m_form), Table table = new Table(new ProcessListenerTableModelBuilder(m_form),
new String[] { "Form action", "", "" }); new String[]{"Form action", "", ""});
m_action = new DecimalSingleSelectionModel(t.getRowSelectionModel()); m_action = new DecimalSingleSelectionModel(table .getRowSelectionModel());
t.setDefaultCellRenderer(new TableCellRenderer() { table .setDefaultCellRenderer(new TableCellRenderer() {
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, boolean isSelected, Object key,
int row, int column) { int row, int column) {
PersistentProcessListener l = (PersistentProcessListener)value; PersistentProcessListener l = (PersistentProcessListener) value;
if (column == 0) { if (column == 0) {
return new Label(l.getDescription()); return new Label(l.getDescription());
} else if (column == 1) { } else if (column == 1) {
ControlLink lk = new ControlLink( new Label(GlobalizationUtil ControlLink lk = new ControlLink(new Label(GlobalizationUtil
.globalize("formbuilder.ui.edit") )); .globalize("formbuilder.ui.edit")));
return lk; return lk;
} else if (column == 2) { } else if (column == 2) {
ControlLink lk = new ControlLink( new Label(GlobalizationUtil ControlLink lk = new ControlLink(new Label(GlobalizationUtil
.globalize("formbuilder.ui.delete") )); .globalize("formbuilder.ui.delete")));
lk.setConfirmation(GlobalizationUtil.globalize( lk.setConfirmation(GlobalizationUtil.globalize(
"formbuilder.ui.form_action.delete_confirm")); "formbuilder.ui.form_action.delete_confirm"));
return lk; return lk;
@ -109,8 +106,9 @@ public class ProcessListenerEditor extends SimpleContainer {
return null; return null;
} }
}); });
t.addTableActionListener(new FormItemActionListener()); table .addTableActionListener(new FormItemActionListener());
m_list_actions = new BoxPanel(BoxPanel.VERTICAL); m_list_actions = new BoxPanel(BoxPanel.VERTICAL);
m_edit_action = new ProcessListenerProperties(m_form, m_edit_action = new ProcessListenerProperties(m_form,
@ -124,7 +122,7 @@ public class ProcessListenerEditor extends SimpleContainer {
m_edit_action)); m_edit_action));
m_list_actions.add(m_newAction); m_list_actions.add(m_newAction);
m_list_actions.add(t); m_list_actions.add(table );
addComponents(); addComponents();
@ -132,7 +130,8 @@ public class ProcessListenerEditor extends SimpleContainer {
add(m_edit_action); add(m_edit_action);
} }
protected void addComponents() { } protected void addComponents() {
}
public void register(Page page) { public void register(Page page) {
super.register(page); super.register(page);
@ -145,6 +144,7 @@ public class ProcessListenerEditor extends SimpleContainer {
} }
private class FormItemProcessListener implements FormProcessListener { private class FormItemProcessListener implements FormProcessListener {
Component m_show; Component m_show;
Component m_hide; Component m_hide;
@ -160,9 +160,11 @@ public class ProcessListenerEditor extends SimpleContainer {
m_show.setVisible(e.getPageState(), true); m_show.setVisible(e.getPageState(), true);
m_hide.setVisible(e.getPageState(), false); m_hide.setVisible(e.getPageState(), false);
} }
} }
private class FormItemCompletionListener implements FormCompletionListener { private class FormItemCompletionListener implements FormCompletionListener {
Component m_show; Component m_show;
Component m_hide; Component m_hide;
@ -178,11 +180,13 @@ public class ProcessListenerEditor extends SimpleContainer {
m_show.setVisible(e.getPageState(), true); m_show.setVisible(e.getPageState(), true);
m_hide.setVisible(e.getPageState(), false); m_hide.setVisible(e.getPageState(), false);
} }
} }
private class FormItemActionListener implements TableActionListener { private class FormItemActionListener implements TableActionListener {
public void headSelected(TableActionEvent e) {} public void headSelected(TableActionEvent e) {
}
public void cellSelected(TableActionEvent e) { public void cellSelected(TableActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
@ -193,20 +197,18 @@ public class ProcessListenerEditor extends SimpleContainer {
m_edit_action.setVisible(state, true); m_edit_action.setVisible(state, true);
m_list_actions.setVisible(state, false); m_list_actions.setVisible(state, false);
} else { } else {
BigDecimal action_id = (BigDecimal)m_action.getSelectedKey(state); BigDecimal action_id = (BigDecimal) m_action.getSelectedKey(state);
try { try {
BigDecimal formID = (BigDecimal) BigDecimal formID = (BigDecimal) m_form.getSelectedKey(state);
m_form.getSelectedKey( state ); PersistentFormSection form = new PersistentFormSection(formID);
PersistentFormSection form =
new PersistentFormSection( formID );
PersistentProcessListener l = (PersistentProcessListener) PersistentProcessListener l = (PersistentProcessListener) DomainObjectFactory
DomainObjectFactory.newInstance( .newInstance(
new OID(PersistentProcessListener.BASE_DATA_OBJECT_TYPE, new OID(PersistentProcessListener.BASE_DATA_OBJECT_TYPE,
action_id)); action_id));
//l.delete(); //l.delete();
form.removeProcessListener( l ); form.removeProcessListener(l);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("cannot find listener", ex); throw new UncheckedWrapperException("cannot find listener", ex);
} }
@ -214,11 +216,12 @@ public class ProcessListenerEditor extends SimpleContainer {
state.clearControlEvent(); state.clearControlEvent();
try { try {
throw new RedirectSignal( state.stateAsURL(), true ); throw new RedirectSignal(state.stateAsURL(), true);
} catch( IOException ex ) { } catch (IOException ex) {
throw new UncheckedWrapperException( ex ); throw new UncheckedWrapperException(ex);
}
} }
} }
}
} }

View File

@ -16,14 +16,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.formbuilder.ui.editors; package com.arsdigita.formbuilder.ui.editors;
import com.arsdigita.formbuilder.PersistentWidget; import com.arsdigita.formbuilder.PersistentWidget;
import com.arsdigita.formbuilder.PersistentFormSection; import com.arsdigita.formbuilder.PersistentFormSection;
import com.arsdigita.formbuilder.parameters.PersistentParameterListener; import com.arsdigita.formbuilder.parameters.PersistentParameterListener;
import com.arsdigita.formbuilder.ui.PropertiesForm; import com.arsdigita.formbuilder.ui.PropertiesForm;
import com.arsdigita.formbuilder.util.GlobalizationUtil ; import com.arsdigita.formbuilder.util.GlobalizationUtil;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
@ -50,6 +49,7 @@ import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.URLTokenValidationListener; import com.arsdigita.bebop.parameters.URLTokenValidationListener;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -57,7 +57,8 @@ import java.math.BigDecimal;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
public abstract class WidgetForm extends PropertiesForm { public abstract class WidgetForm extends PropertiesForm {
private static final Logger s_log = Logger.getLogger( WidgetForm.class );
private static final Logger s_log = Logger.getLogger(WidgetForm.class);
private SingleSelectionModel m_form; private SingleSelectionModel m_form;
private SingleSelectionModel m_action; private SingleSelectionModel m_action;
@ -71,8 +72,10 @@ public abstract class WidgetForm extends PropertiesForm {
private RequestLocal m_widget = new RequestLocal(); private RequestLocal m_widget = new RequestLocal();
private Label m_script = new Label("<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", false); private Label m_script = new Label(String.format(
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false);
public WidgetForm(String name, public WidgetForm(String name,
SingleSelectionModel form, SingleSelectionModel form,
@ -86,8 +89,6 @@ public abstract class WidgetForm extends PropertiesForm {
addProcessListener(new WidgetFormProcessListener()); addProcessListener(new WidgetFormProcessListener());
} }
public SingleSelectionModel getSelection() { public SingleSelectionModel getSelection() {
return m_form; return m_form;
} }
@ -99,7 +100,7 @@ public abstract class WidgetForm extends PropertiesForm {
protected PersistentWidget getWidget(PageState state) { protected PersistentWidget getWidget(PageState state) {
if (m_widget.get(state) == null) { if (m_widget.get(state) == null) {
BigDecimal action = (BigDecimal)m_action.getSelectedKey(state); BigDecimal action = (BigDecimal) m_action.getSelectedKey(state);
PersistentWidget widget = null; PersistentWidget widget = null;
if (action == null) { if (action == null) {
@ -109,25 +110,31 @@ public abstract class WidgetForm extends PropertiesForm {
try { try {
widget = getWidget(action); widget = getWidget(action);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new com.arsdigita.util.UncheckedWrapperException("cannot find persistent widget " + action, ex); throw new com.arsdigita.util.UncheckedWrapperException(
"cannot find persistent widget " + action, ex);
} }
} }
m_widget.set(state, widget); m_widget.set(state, widget);
} }
return (PersistentWidget)m_widget.get(state); return (PersistentWidget) m_widget.get(state);
} }
protected void addWidgets(FormSection section) { protected void addWidgets(FormSection section) {
super.addWidgets(section); super.addWidgets(section);
if (showName()) addName(section); if (showName()) {
if (showDescription()) addDescription(section); addName(section);
if (includeRequiredRadioGroup()) addRequiredRadioGroup(section); }
if (showDescription()) {
addDescription(section);
}
if (includeRequiredRadioGroup()) {
addRequiredRadioGroup(section);
}
} }
/** /**
* Add the name field to the form. Override this method to alter the * Add the name field to the form. Override this method to alter the creation of the name field.
* creation of the name field.
*/ */
protected void addName(FormSection section) { protected void addName(FormSection section) {
TextField name = new TextField(new StringParameter(NAME)); TextField name = new TextField(new StringParameter(NAME));
@ -143,8 +150,7 @@ public abstract class WidgetForm extends PropertiesForm {
} }
/** /**
* Add the name field to the form. Override this method to alter the * Add the name field to the form. Override this method to alter the creation of the name field.
* creation of the name field.
*/ */
protected void addDescription(FormSection section) { protected void addDescription(FormSection section) {
TextArea description = new TextArea(new StringParameter(DESCRIPTION)); TextArea description = new TextArea(new StringParameter(DESCRIPTION));
@ -160,7 +166,7 @@ public abstract class WidgetForm extends PropertiesForm {
} }
protected void addRequiredRadioGroup(FormSection section) { protected void addRequiredRadioGroup(FormSection section) {
m_required = new RadioGroup( new BooleanParameter( "required" ) ); m_required = new RadioGroup(new BooleanParameter("required"));
section.add(new Label(GlobalizationUtil.globalize( section.add(new Label(GlobalizationUtil.globalize(
"formbuilder.ui.editors.answer_required")), "formbuilder.ui.editors.answer_required")),
ColumnPanel.RIGHT); ColumnPanel.RIGHT);
@ -172,19 +178,14 @@ public abstract class WidgetForm extends PropertiesForm {
} }
/** /**
* If this is called then the value of the widget that is used for * If this is called then the value of the widget that is used for the passed in model is used
* the passed in model is used to auto-generate the value of the * to auto-generate the value of the "name" value. For instance, if you want the label to
* "name" value. For instance, if you want the label to dictate * dictate the "name" then you would pass in the label ParameterModel and add the following to
* the "name" then you would pass in the label ParameterModel * the labelWidget:
* and add the following to the labelWidget:
* *
* labelWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " + * labelWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " + " defaulting = true;
* " defaulting = true; this.form." + NAME + * this.form." + NAME + ".value = urlize(this.value); }"); labelWidget.setOnKeyUp( "if
* ".value = urlize(this.value); }"); * (defaulting) { this.form." + NAME + ".value = urlize(this.value) }" );
* labelWidget.setOnKeyUp(
* "if (defaulting) { this.form." + NAME +
* ".value = urlize(this.value) }"
* );
* *
* *
* This can only be called after calling addWidgets() * This can only be called after calling addWidgets()
@ -193,36 +194,31 @@ public abstract class WidgetForm extends PropertiesForm {
Assert.exists(m_name); Assert.exists(m_name);
m_name.setOnFocus("defaulting = false"); m_name.setOnFocus("defaulting = false");
m_name.setOnBlur( m_name.setOnBlur(
"if (this.value == '') " + "if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + model
"{ defaulting = true; this.value = urlize(this.form." + .getName() + ".value) }"
model.getName() + ".value) }"
); );
} }
/** /**
* This determines whether or not the "required value" radio group * This determines whether or not the "required value" radio group is part of the form. This
* is part of the form. This returns true and should be overridden * returns true and should be overridden by fields where it does not make sense to ask. For
* by fields where it does not make sense to ask. For instance, * instance, when the widget is a hidden field then asking if it is required or not does not
* when the widget is a hidden field then asking if it is required * make any logical sense so those widgets should return false.
* or not does not make any logical sense so those widgets should
* return false.
* *
* This will always return the same value for a given widget no matter * This will always return the same value for a given widget no matter what state the widget is
* what state the widget is in. * in.
*/ */
protected boolean includeRequiredRadioGroup() { protected boolean includeRequiredRadioGroup() {
return true; return true;
} }
public void generateXML(PageState ps, Element parent) { public void generateXML(PageState ps, Element parent) {
m_script.generateXML(ps, parent); m_script.generateXML(ps, parent);
super.generateXML(ps, parent); super.generateXML(ps, parent);
} }
/** /**
* Should the HTML name be on the form? Can be overridden * Should the HTML name be on the form? Can be overridden by sub classes.
* by sub classes.
*/ */
protected boolean showName() { protected boolean showName() {
@ -230,8 +226,7 @@ public abstract class WidgetForm extends PropertiesForm {
} }
/** /**
* Should the description be on the form? Can be overridden * Should the description be on the form? Can be overridden by sub classes.
* by sub classes.
*/ */
protected boolean showDescription() { protected boolean showDescription() {
@ -261,7 +256,7 @@ public abstract class WidgetForm extends PropertiesForm {
m_description.setValue(state, widget.getDescription()); m_description.setValue(state, widget.getDescription());
} }
/* /*
Leaving this around just in case it turns out it does something useful Leaving this around just in case it turns out it does something useful
//Get the associated listeners and set the value for the radio button accordingly //Get the associated listeners and set the value for the radio button accordingly
@ -281,13 +276,13 @@ public abstract class WidgetForm extends PropertiesForm {
} }
} }
} }
*/ */
//m_name.setVisible(state, false); //m_name.setVisible(state, false);
if(includeRequiredRadioGroup()) if (includeRequiredRadioGroup()) {
m_required.setValue(state, new Boolean(widget.isRequired())); m_required.setValue(state, new Boolean(widget.isRequired()));
} }
} }
}
protected void processWidgets(FormSectionEvent e, protected void processWidgets(FormSectionEvent e,
PersistentWidget widget) PersistentWidget widget)
@ -300,7 +295,7 @@ public abstract class WidgetForm extends PropertiesForm {
widget.setParameterName(name); widget.setParameterName(name);
if (showDescription()) { if (showDescription()) {
String description = (String)data.get(DESCRIPTION); String description = (String) data.get(DESCRIPTION);
widget.setDescription(description); widget.setDescription(description);
} }
@ -310,15 +305,15 @@ public abstract class WidgetForm extends PropertiesForm {
} }
if (includeRequiredRadioGroup()) { if (includeRequiredRadioGroup()) {
boolean required = ( (Boolean) m_required.getValue( pageState ) ).booleanValue(); boolean required = ((Boolean) m_required.getValue(pageState)).booleanValue();
widget.setRequired( required ); widget.setRequired(required);
if( required ) { if (required) {
// Answer is required // Answer is required
String listenerClassName = String listenerClassName
"com.arsdigita.bebop.parameters.NotEmptyValidationListener"; = "com.arsdigita.bebop.parameters.NotEmptyValidationListener";
PersistentParameterListener listener = PersistentParameterListener listener = new PersistentParameterListener(
new PersistentParameterListener(listenerClassName); listenerClassName);
widget.addValidationListener(listener); widget.addValidationListener(listener);
} else { } else {
// Answer is not required // Answer is not required
@ -328,14 +323,14 @@ public abstract class WidgetForm extends PropertiesForm {
} }
protected String getName(PageState pageState, FormData formData) { protected String getName(PageState pageState, FormData formData) {
return (String)formData.get(NAME); return (String) formData.get(NAME);
} }
protected void addToForm(FormSectionEvent e, protected void addToForm(FormSectionEvent e,
PersistentWidget widget) PersistentWidget widget)
throws FormProcessException { throws FormProcessException {
BigDecimal form_id = (BigDecimal)m_form.getSelectedKey(e.getPageState()); BigDecimal form_id = (BigDecimal) m_form.getSelectedKey(e.getPageState());
PersistentFormSection form = null; PersistentFormSection form = null;
try { try {
@ -348,14 +343,14 @@ public abstract class WidgetForm extends PropertiesForm {
form.save(); form.save();
} }
private class WidgetFormInitListener implements FormInitListener { private class WidgetFormInitListener implements FormInitListener {
public void init(FormSectionEvent e) public void init(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
BigDecimal action = (BigDecimal)m_action.getSelectedKey(state); BigDecimal action = (BigDecimal) m_action.getSelectedKey(state);
if (action == null) { if (action == null) {
initWidgets(e, null); initWidgets(e, null);
@ -370,26 +365,32 @@ public abstract class WidgetForm extends PropertiesForm {
initWidgets(e, widget); initWidgets(e, widget);
} }
} }
} }
private class WidgetFormProcessListener implements FormProcessListener { private class WidgetFormProcessListener implements FormProcessListener {
public void process(FormSectionEvent e) public void process(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
if (isCancelled(state)) if (isCancelled(state)) {
return; return;
}
BigDecimal action = (BigDecimal)m_action.getSelectedKey(state); BigDecimal action = (BigDecimal) m_action.getSelectedKey(state);
PersistentWidget widget = getWidget(state); PersistentWidget widget = getWidget(state);
processWidgets(e, widget); processWidgets(e, widget);
widget.save(); widget.save();
if (action == null) if (action == null) {
addToForm(e, widget); addToForm(e, widget);
} }
} }
}
} }

View File

@ -18,7 +18,7 @@
<portlet-mode>HELP</portlet-mode> <portlet-mode>HELP</portlet-mode>
</supports> </supports>
<portlet-info> <portlet-info>
<title>Hello, Pluto at last!</title> <title>Hello, Pluto from LibreCCM!</title>
</portlet-info> </portlet-info>
</portlet> </portlet>
</portlet-app> </portlet-app>

View File

@ -35,7 +35,7 @@
<xsl:template match="theme:folder|theme:file" name="themeFolder"> <xsl:template match="theme:folder|theme:file" name="themeFolder">
<tr> <tr>
<td align="left"> <td align="left">
<img src="/assets/pix.gif"><xsl:attribute name="width"><xsl:value-of select="@depth"/></xsl:attribute></img> <img src="{$context-prefix}/assets/pix.gif"><xsl:attribute name="width"><xsl:value-of select="@depth"/></xsl:attribute></img>
</td> </td>
<xsl:if test="name()='theme:folder'"> <xsl:if test="name()='theme:folder'">

View File

@ -161,7 +161,7 @@
<!-- EN Show categories to select --> <!-- EN Show categories to select -->
<xsl:template match="cms:categoryWidget"> <xsl:template match="cms:categoryWidget">
<!-- <script type="text/javascript" src="/assets/prototype.js"/> --> <!-- <script type="text/javascript" src="/assets/prototype.js"/> -->
<script type="text/javascript" src="/assets/jquery.js"/> <script type="text/javascript" src="{$context-prefix}/assets/jquery.js"/>
<script type="text/javascript" src="{$theme-prefix}/includes/cms/category-step.js"/> <script type="text/javascript" src="{$theme-prefix}/includes/cms/category-step.js"/>
<xsl:choose> <xsl:choose>
<xsl:when test="@mode='javascript'"> <xsl:when test="@mode='javascript'">

View File

@ -161,7 +161,7 @@
<!-- DE Zeige die Kategorien zum Hinzufügen an --> <!-- DE Zeige die Kategorien zum Hinzufügen an -->
<!-- EN Show categories to select --> <!-- EN Show categories to select -->
<xsl:template match="forum:categoryWidget"> <xsl:template match="forum:categoryWidget">
<script type="text/javascript" src="/assets/prototype.js"/> <script type="text/javascript" src="{$context-prefix}/assets/prototype.js"/>
<script type="text/javascript" src="{$theme-prefix}/includes/cms/category-step.js"/> <script type="text/javascript" src="{$theme-prefix}/includes/cms/category-step.js"/>
<xsl:choose> <xsl:choose>
<xsl:when test="@mode='javascript'"> <xsl:when test="@mode='javascript'">

View File

@ -51,22 +51,34 @@
<!--script type="text/javascript" src="/assets/fancybox/jquery.easing.pack.js"/--> <!--script type="text/javascript" src="/assets/fancybox/jquery.easing.pack.js"/-->
<!-- Add mousewheel plugin (this is optional) --> <!-- Add mousewheel plugin (this is optional) -->
<script type="text/javascript" src="/assets/fancybox2/lib/jquery.mousewheel-3.0.6.pack.js"/> <script type="text/javascript"
src="{$context-prefix}/assets/fancybox2/lib/jquery.mousewheel-3.0.6.pack.js"/>
<!-- Add fancyBox main JS and CSS files --> <!-- Add fancyBox main JS and CSS files -->
<script type="text/javascript" src="/assets/fancybox2/source/jquery.fancybox.js"></script> <script type="text/javascript"
<link rel="stylesheet" href="/assets/fancybox2/source/jquery.fancybox.css" type="text/css" media="screen"/> src="{$context-prefix}/assets/fancybox2/source/jquery.fancybox.js"/>
<link rel="stylesheet"
href="{$context-prefix}/assets/fancybox2/source/jquery.fancybox.css"
type="text/css"
media="screen"/>
<!-- Add Button helper (this is optional) --> <!-- Add Button helper (this is optional) -->
<link rel="stylesheet" type="text/css" href="/assets/fancybox2/source/helpers/jquery.fancybox-buttons.css" /> <link rel="stylesheet"
<script type="text/javascript" src="/assets/fancybox2/source/helpers/jquery.fancybox-buttons.js"></script> type="text/css"
href="{$context-prefix}/assets/fancybox2/source/helpers/jquery.fancybox-buttons.css" />
<script type="text/javascript"
src="{$context-prefix}/assets/fancybox2/source/helpers/jquery.fancybox-buttons.js"/>
<!-- Add Thumbnail helper (this is optional) --> <!-- Add Thumbnail helper (this is optional) -->
<link rel="stylesheet" type="text/css" href="/assets/fancybox2/source/helpers/jquery.fancybox-thumbs.css" /> <link rel="stylesheet"
<script type="text/javascript" src="/assets/fancybox2/source/helpers/jquery.fancybox-thumbs.js"></script> type="text/css"
href="{$context-prefix}/assets/fancybox2/source/helpers/jquery.fancybox-thumbs.css" />
<script type="text/javascript"
src="{$context-prefix}/assets/fancybox2/source/helpers/jquery.fancybox-thumbs.js"/>
<!-- Add Media helper (this is optional) --> <!-- Add Media helper (this is optional) -->
<script type="text/javascript" src="/assets/fancybox2/source/helpers/jquery.fancybox-media.js"></script> <script type="text/javascript"
src="{$context-prefix}/assets/fancybox2/source/helpers/jquery.fancybox-media.js"/>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {

View File

@ -196,23 +196,27 @@
</xsl:template> </xsl:template>
<xsl:template match="useJQuery"> <xsl:template match="useJQuery">
<script type="text/javascript" src="/assets/jquery.js"/> <script type="text/javascript" src="{$context-prefix}/assets/jquery.js"/>
</xsl:template> </xsl:template>
<xsl:template match="useJQueryUI"> <xsl:template match="useJQueryUI">
<script type="text/javascript" src="/assets/jquery-ui.min.js"/> <script type="text/javascript" src="{$context-prefix}/assets/jquery-ui.min.js"/>
</xsl:template> </xsl:template>
<xsl:template match="useMathJax"> <xsl:template match="useMathJax">
<script type="text/javascript" src="/assets/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML"/> <script type="text/javascript"
src="{$context-prefix}/assets/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML"/>
</xsl:template> </xsl:template>
<xsl:template match="useHTML5shiv"> <xsl:template match="useHTML5shiv">
<xsl:text disable-output-escaping="yes"> <xsl:value-of disable-output-escaping="yes" select="concat('
&lt;!--[if lt IE 9]&gt; &lt;!--
&lt;script src="/assets/html5shiv.js"/&gt; &lt;!-[if lt IE 9]&gt;
&lt;![endif]--&gt; &lt;script src=&quot;', $context-prefix, '/assets/html5shiv.js&quot;/&gt;
</xsl:text> &lt;![endif]
--&gt;')"/>
</xsl:template> </xsl:template>
<!-- DE Setze den lokalisierten Seitentitel --> <!-- DE Setze den lokalisierten Seitentitel -->

View File

@ -423,7 +423,7 @@ Setting up global templates like getStaticText and getSetting
</xsl:attribute> </xsl:attribute>
<img> <img>
<xsl:attribute name="src"> <xsl:attribute name="src">
<xsl:value-of select="'/assets/gray-triangle-up.gif'"/> <xsl:value-of select="concat($context-prefix, '/assets/gray-triangle-up.gif')"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="title"> <xsl:attribute name="title">
<xsl:value-of select="'moveUp'"/> <xsl:value-of select="'moveUp'"/>
@ -443,7 +443,7 @@ Setting up global templates like getStaticText and getSetting
</xsl:attribute> </xsl:attribute>
<img> <img>
<xsl:attribute name="src"> <xsl:attribute name="src">
<xsl:value-of select="'/assets/gray-triangle-down.gif'"/> <xsl:value-of select="concat($context-prefix, '/assets/gray-triangle-down.gif')"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="title"> <xsl:attribute name="title">
<xsl:value-of select="'moveDown'"/> <xsl:value-of select="'moveDown'"/>

View File

@ -68,12 +68,12 @@
<a href="{terms:action[@name='delete']/@url}"><img src="/__ccm__/static/cms/admin/action-group/action-delete.png" width="14" height="14" border="0"/></a> <a href="{terms:action[@name='delete']/@url}"><img src="/__ccm__/static/cms/admin/action-group/action-delete.png" width="14" height="14" border="0"/></a>
<a href="{terms:action[@name='delete']/@url}">Delete</a> <a href="{terms:action[@name='delete']/@url}">Delete</a>
<xsl:text>&nbsp;</xsl:text> <xsl:text>&nbsp;</xsl:text>
<a href="{terms:action[@name='train']/@url}"><img src="/assets/action-generic.png" width="14" height="14" border="0"/></a> <a href="{terms:action[@name='train']/@url}"><img src="{$context-prefix}/assets/action-generic.png" width="14" height="14" border="0"/></a>
<xsl:choose> <xsl:choose>
<xsl:when test="terms:indexer"> <xsl:when test="terms:indexer">
<a href="{terms:action[@name='train']/@url}">Retrain indexer</a> <a href="{terms:action[@name='train']/@url}">Retrain indexer</a>
<xsl:text>&nbsp;</xsl:text> <xsl:text>&nbsp;</xsl:text>
<a href="{terms:action[@name='untrain']/@url}"><img src="/assets/action-delete.png" width="14" height="14" border="0"/></a> <a href="{terms:action[@name='untrain']/@url}"><img src="{$context-prefix}/assets/action-delete.png" width="14" height="14" border="0"/></a>
<a href="{terms:action[@name='untrain']/@url}">Delete indexer</a> <a href="{terms:action[@name='untrain']/@url}">Delete indexer</a>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>

View File

@ -35,10 +35,10 @@
<tr> <tr>
<td></td> <td></td>
<td> <td>
<a href="{terms:action[@name='edit']/@url}"><img src="/assets/images/action-generic.png" width="14" height="14" border="0"/></a> <a href="{terms:action[@name='edit']/@url}"><img src="{$context-prefix}/assets/images/action-generic.png" width="14" height="14" border="0"/></a>
<a href="{terms:action[@name='edit']/@url}">Edit</a> <a href="{terms:action[@name='edit']/@url}">Edit</a>
<xsl:text>&#160;</xsl:text> <xsl:text>&#160;</xsl:text>
<a href="{terms:action[@name='delete']/@url}"><img src="/assets/images/action-delete.png" width="14" height="14" border="0"/></a> <a href="{terms:action[@name='delete']/@url}"><img src="{$context-prefix}/assets/images/action-delete.png" width="14" height="14" border="0"/></a>
<a href="{terms:action[@name='delete']/@url}">Delete</a> <a href="{terms:action[@name='delete']/@url}">Delete</a>
<xsl:text>&#160;</xsl:text> <xsl:text>&#160;</xsl:text>
</td> </td>

View File

@ -32,6 +32,7 @@
<useJQuery/> <useJQuery/>
<useFancybox/> <useFancybox/>
<useMathJax/> <useMathJax/>
<useHTML5shiv/>
</head> </head>
<body> <body>