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-94f89814c4dfmaster
parent
beb861d78c
commit
f09f59b750
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui.mparticle;
|
||||
|
||||
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
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.SessionManager;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* A form for editing MultiPartArticle and subclasses.
|
||||
*
|
||||
|
|
@ -63,27 +62,27 @@ import java.util.Date;
|
|||
* @version $id$
|
||||
*/
|
||||
public abstract class MultiPartArticleForm extends FormSection
|
||||
implements FormInitListener,
|
||||
FormProcessListener,
|
||||
FormValidationListener {
|
||||
implements FormInitListener,
|
||||
FormProcessListener,
|
||||
FormValidationListener {
|
||||
|
||||
protected ItemSelectionModel m_itemModel;
|
||||
protected SaveCancelSection m_saveCancelSection;
|
||||
protected SaveCancelSection m_saveCancelSection;
|
||||
|
||||
public static final String NAME = "name";
|
||||
public static final String TITLE = "title";
|
||||
public static final String NAME = "name";
|
||||
public static final String TITLE = "title";
|
||||
public static final String SUMMARY = "summary";
|
||||
public static final String LAUNCH_DATE = ContentPage.LAUNCH_DATE;
|
||||
public static final String LANGUAGE = ContentItem.LANGUAGE;
|
||||
|
||||
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));
|
||||
|
||||
m_itemModel = itemModel;
|
||||
|
||||
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||
ColumnPanel panel = (ColumnPanel) getPanel();
|
||||
panel.setBorder(false);
|
||||
panel.setPadColor("#FFFFFF");
|
||||
panel.setColumnWidth(1, "20%");
|
||||
|
|
@ -99,57 +98,55 @@ public abstract class MultiPartArticleForm extends FormSection
|
|||
addValidationListener(this);
|
||||
}
|
||||
|
||||
|
||||
public void addSaveCancelSection () {
|
||||
public void addSaveCancelSection() {
|
||||
m_saveCancelSection = new SaveCancelSection();
|
||||
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||
}
|
||||
|
||||
|
||||
public SaveCancelSection getSaveCancelSection () {
|
||||
public SaveCancelSection getSaveCancelSection() {
|
||||
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
|
||||
.globalize("cms.contenttypes.ui.title")));
|
||||
.globalize("cms.contenttypes.ui.title")));
|
||||
TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE));
|
||||
titleWidget.addValidationListener(new NotNullValidationListener());
|
||||
titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " +
|
||||
" defaulting = true; this.form." + NAME +
|
||||
".value = urlize(this.value); }");
|
||||
titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { "
|
||||
+ " defaulting = true; this.form." + NAME
|
||||
+ ".value = urlize(this.value); }");
|
||||
titleWidget.setOnKeyUp(
|
||||
"if (defaulting) { this.form." + NAME +
|
||||
".value = urlize(this.value) }"
|
||||
);
|
||||
"if (defaulting) { this.form." + NAME + ".value = urlize(this.value) }"
|
||||
);
|
||||
add(titleWidget);
|
||||
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.name")));
|
||||
.globalize("cms.contenttypes.ui.name")));
|
||||
TextField nameWidget = new TextField(new TrimmedStringParameter(NAME));
|
||||
nameWidget.addValidationListener(new NotNullValidationListener());
|
||||
nameWidget.addValidationListener(new URLTokenValidationListener());
|
||||
nameWidget.setOnFocus("defaulting = false");
|
||||
nameWidget.setOnBlur(
|
||||
"if (this.value == '') " +
|
||||
"{ defaulting = true; this.value = urlize(this.form." + TITLE +
|
||||
".value) }"
|
||||
);
|
||||
"if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + TITLE
|
||||
+ ".value) }"
|
||||
);
|
||||
add(nameWidget);
|
||||
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.ui.authoring.page_launch_date")));
|
||||
.globalize("cms.ui.authoring.page_launch_date")));
|
||||
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
|
||||
com.arsdigita.bebop.form.Date launchDate
|
||||
= new com.arsdigita.bebop.form.Date(launchDateParam);
|
||||
= new com.arsdigita.bebop.form.Date(launchDateParam);
|
||||
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
|
||||
launchDateParam.setDefaultValue(new Date());
|
||||
}
|
||||
|
|
@ -157,38 +154,39 @@ public abstract class MultiPartArticleForm extends FormSection
|
|||
}
|
||||
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.summary")));
|
||||
.globalize("cms.contenttypes.ui.summary")));
|
||||
TextArea summaryWidget = new TextArea(new TrimmedStringParameter(SUMMARY));
|
||||
if (ContentSection.getConfig().mandatoryDescriptions()) {
|
||||
summaryWidget
|
||||
.addValidationListener(new
|
||||
NotEmptyValidationListener(GlobalizationUtil
|
||||
.addValidationListener(new NotEmptyValidationListener(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.description_missing")));
|
||||
}
|
||||
}
|
||||
summaryWidget.setRows(5);
|
||||
summaryWidget.setCols(30);
|
||||
summaryWidget.setHint(GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.summary_hint"));
|
||||
"cms.contenttypes.ui.summary_hint"));
|
||||
add(summaryWidget);
|
||||
}
|
||||
|
||||
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 init(FormSectionEvent e) throws FormProcessException;
|
||||
|
||||
public abstract void process(FormSectionEvent e) throws FormProcessException;
|
||||
|
||||
/** Utility method to initialize the name/title/summary widgets */
|
||||
public MultiPartArticle initBasicWidgets ( FormSectionEvent e ) {
|
||||
public abstract void validate(FormSectionEvent e) throws FormProcessException;
|
||||
|
||||
/**
|
||||
* Utility method to initialize the name/title/summary widgets
|
||||
*/
|
||||
public MultiPartArticle initBasicWidgets(FormSectionEvent e) {
|
||||
Assert.exists(m_itemModel, ItemSelectionModel.class);
|
||||
|
||||
FormData data = e.getFormData();
|
||||
PageState state = e.getPageState();
|
||||
MultiPartArticle article =
|
||||
(MultiPartArticle)m_itemModel.getSelectedObject(state);
|
||||
FormData data = e.getFormData();
|
||||
PageState state = e.getPageState();
|
||||
MultiPartArticle article = (MultiPartArticle) m_itemModel.getSelectedObject(state);
|
||||
|
||||
if ( article != null ) {
|
||||
data.put(NAME, article.getName());
|
||||
data.put(TITLE, article.getTitle());
|
||||
if (article != null) {
|
||||
data.put(NAME, article.getName());
|
||||
data.put(TITLE, article.getTitle());
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
data.put(LAUNCH_DATE, article.getLaunchDate());
|
||||
}
|
||||
|
|
@ -198,23 +196,23 @@ public abstract class MultiPartArticleForm extends FormSection
|
|||
return article;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Utility method to process the name/title/summary widgets */
|
||||
public MultiPartArticle processBasicWidgets ( FormSectionEvent e ) {
|
||||
/**
|
||||
* Utility method to process the name/title/summary widgets
|
||||
*/
|
||||
public MultiPartArticle processBasicWidgets(FormSectionEvent e) {
|
||||
Assert.exists(m_itemModel, ItemSelectionModel.class);
|
||||
|
||||
FormData data = e.getFormData();
|
||||
PageState state = e.getPageState();
|
||||
MultiPartArticle article = (MultiPartArticle)m_itemModel.getSelectedObject(state);
|
||||
MultiPartArticle article = (MultiPartArticle) m_itemModel.getSelectedObject(state);
|
||||
|
||||
if ( article != null ) {
|
||||
article.setName((String)data.get(NAME));
|
||||
article.setTitle((String)data.get(TITLE));
|
||||
if (article != null) {
|
||||
article.setName((String) data.get(NAME));
|
||||
article.setTitle((String) data.get(TITLE));
|
||||
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;
|
||||
|
|
@ -224,16 +222,16 @@ public abstract class MultiPartArticleForm extends FormSection
|
|||
* Ensure that the name of an item is unique within a folder.
|
||||
*
|
||||
* @param folder the folder in which to check
|
||||
* @param event the FormSectionEvent which was passed to the
|
||||
* validation listener
|
||||
* @param event the FormSectionEvent which was passed to the validation listener
|
||||
*
|
||||
* @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();
|
||||
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";
|
||||
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
|
||||
dq.setParameter("parentId", folder.getID());
|
||||
|
|
@ -246,33 +244,29 @@ public abstract class MultiPartArticleForm extends FormSection
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Utility method to create a new MultiPartArticle and update the
|
||||
* selected model. This can be called in the process method of a
|
||||
* ProcessListener.
|
||||
* Utility method to create a new MultiPartArticle and update the selected model. This can be
|
||||
* called in the process method of a ProcessListener.
|
||||
*
|
||||
* @param state the current page state
|
||||
*
|
||||
* @return the new content item (or a proper subclass)
|
||||
*/
|
||||
public MultiPartArticle createArticle ( PageState state )
|
||||
throws FormProcessException
|
||||
{
|
||||
public MultiPartArticle createArticle(PageState state)
|
||||
throws FormProcessException {
|
||||
Assert.exists(m_itemModel, ItemSelectionModel.class);
|
||||
|
||||
MultiPartArticle article = null;
|
||||
|
||||
try {
|
||||
article = (MultiPartArticle)m_itemModel.createItem();
|
||||
} catch(ServletException e) {
|
||||
article = (MultiPartArticle) m_itemModel.createItem();
|
||||
} catch (ServletException e) {
|
||||
s_log.error("Servlet Exception: " + 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);
|
||||
}
|
||||
|
||||
|
|
@ -284,6 +278,4 @@ public abstract class MultiPartArticleForm extends FormSection
|
|||
super.generateXML(ps, parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.arsdigita.portal.JSRPortlet;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
|
|
@ -57,9 +58,11 @@ public class ContentItemJSRPortlet extends JSRPortlet {
|
|||
@Override
|
||||
protected void doEdit(RenderRequest request, RenderResponse response)
|
||||
throws PortletException, IOException {
|
||||
response.setContentType("text/html");
|
||||
PrintWriter writer = new PrintWriter(response.getWriter());
|
||||
writer.println("You're now in Edit mode.");
|
||||
//response.setContentType("text/html");
|
||||
//PrintWriter writer = new PrintWriter(response.getWriter());
|
||||
//writer.println("You're now in Edit mode.");
|
||||
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/templates/portlets/ContentItemJSRPortletAdmin.jsp");
|
||||
dispatcher.include(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import static com.arsdigita.cms.util.GlobalizationUtil.globalize;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
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".
|
||||
*/
|
||||
private final Label m_script = new Label(
|
||||
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>",
|
||||
private final Label m_script = new Label(String.format(
|
||||
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
|
||||
Web.getWebappContextPath()),
|
||||
false);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.arsdigita.categorization.Category;
|
|||
import com.arsdigita.categorization.CategoryCollection;
|
||||
import com.arsdigita.cms.ui.BaseForm;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -57,8 +58,9 @@ class BaseCategoryForm extends BaseForm {
|
|||
final RadioGroup m_isAbstract;
|
||||
final RadioGroup m_isVisible;
|
||||
final RadioGroup m_isEnabled;
|
||||
private Label m_script = new Label(
|
||||
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>",
|
||||
private Label m_script = new Label(String.format(
|
||||
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
|
||||
Web.getWebappContextPath()),
|
||||
false);
|
||||
private final static String NAME = "name";
|
||||
private final static String DESCRIPTION = "description";
|
||||
|
|
|
|||
|
|
@ -40,95 +40,96 @@ import com.arsdigita.categorization.CategoryCollection;
|
|||
import com.arsdigita.cms.ui.BaseForm;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
/**
|
||||
* Base class for CategoryLocalizationAddForm and CategoryLocalizationEditForm.
|
||||
*
|
||||
* This class is part of the admin GUI of CCM and extends the standard form
|
||||
* in order to present forms for managing the multi-language categories.
|
||||
* This class is part of the admin GUI of CCM and extends the standard form in order to present
|
||||
* forms for managing the multi-language categories.
|
||||
*
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class CategoryLocalizationForm extends BaseForm {
|
||||
|
||||
|
||||
final CategoryRequestLocal m_category;
|
||||
final SingleSelect m_locale;
|
||||
final TextField m_name;
|
||||
final TextArea m_description;
|
||||
final TextField m_url;
|
||||
final RadioGroup m_isEnabled;
|
||||
private Label m_script = new Label(
|
||||
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\">"+
|
||||
"</script>", false);
|
||||
|
||||
private final static String LOCALE = "locale";
|
||||
private final static String NAME = "name";
|
||||
private Label m_script = new Label(String.format(
|
||||
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\">" + "</script>",
|
||||
Web.getWebappContextPath()),
|
||||
false);
|
||||
|
||||
private final static String LOCALE = "locale";
|
||||
private final static String NAME = "name";
|
||||
private final static String DESCRIPTION = "description";
|
||||
private final static String URL = "url";
|
||||
private final static String IS_ENABLED = "isEnabled";
|
||||
|
||||
/**
|
||||
private final static String URL = "url";
|
||||
private final static String IS_ENABLED = "isEnabled";
|
||||
|
||||
/**
|
||||
* Creates a new instance of CategoryLocalizationForm.
|
||||
*
|
||||
*/
|
||||
public CategoryLocalizationForm(final String key,
|
||||
final GlobalizedMessage heading,
|
||||
final CategoryRequestLocal category) {
|
||||
|
||||
final GlobalizedMessage heading,
|
||||
final CategoryRequestLocal category) {
|
||||
|
||||
super(key, heading);
|
||||
|
||||
|
||||
m_category = category;
|
||||
|
||||
|
||||
// Parameter-Model for SingleSelect
|
||||
ParameterModel localeParam = new StringParameter(LOCALE);
|
||||
localeParam.addParameterListener(new StringInRangeValidationListener(0, 2));
|
||||
|
||||
m_locale = new SingleSelect(localeParam);
|
||||
|
||||
m_locale = new SingleSelect(localeParam);
|
||||
m_locale.addValidationListener(new ParameterListener() {
|
||||
|
||||
|
||||
public void validate(ParameterEvent e) throws FormProcessException {
|
||||
|
||||
|
||||
// the --select one-- option is not allowed
|
||||
ParameterData data = e.getParameterData();
|
||||
String code = (String) data.getValue() ;
|
||||
String code = (String) data.getValue();
|
||||
if (code == null || code.length() == 0) {
|
||||
data.addError(
|
||||
(String)GlobalizationUtil.globalize(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_error_locale").localize());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
addField(gz("cms.ui.category.localization_locale"), m_locale);
|
||||
|
||||
|
||||
m_name = new TextField(new TrimmedStringParameter(NAME));
|
||||
addField(gz("cms.ui.name"), m_name);
|
||||
|
||||
|
||||
m_name.setSize(30);
|
||||
m_name.setMaxLength(200);
|
||||
m_name.addValidationListener(new NotNullValidationListener());
|
||||
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " +
|
||||
" defaulting = true; this.form." + URL +
|
||||
".value = urlize(this.value); }");
|
||||
m_name.setOnKeyUp("if (defaulting) { this.form." + URL +
|
||||
".value = urlize(this.value) }");
|
||||
|
||||
m_name.setOnFocus("if (this.form." + URL + ".value == '') { "
|
||||
+ " defaulting = true; this.form." + URL
|
||||
+ ".value = urlize(this.value); }");
|
||||
m_name.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }");
|
||||
|
||||
// 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("yes", new Label(gz("cms.ui.yes"))));
|
||||
addField(gz("cms.ui.category.is_enabled"),m_isEnabled);
|
||||
|
||||
m_description = new TextArea
|
||||
(new TrimmedStringParameter(DESCRIPTION));
|
||||
addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
|
||||
|
||||
m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
|
||||
addField(gz("cms.ui.description"), m_description);
|
||||
|
||||
|
||||
m_description.setWrap(TextArea.SOFT);
|
||||
m_description.setRows(5);
|
||||
m_description.setCols(40);
|
||||
|
||||
|
||||
// URL
|
||||
// JavaScript auto-url generation is off by default.
|
||||
// It is turned on under the following circumstances
|
||||
|
|
@ -146,45 +147,45 @@ public class CategoryLocalizationForm extends BaseForm {
|
|||
m_url.setMaxLength(200);
|
||||
m_url.addValidationListener(new NotNullValidationListener());
|
||||
m_url.setOnFocus("defaulting = false");
|
||||
m_url.setOnBlur("if (this.value == '') " +
|
||||
"{ defaulting = true; this.value = urlize(this.form." + NAME +
|
||||
".value) } " +
|
||||
"else { this.value = urlize(this.value); }");
|
||||
addField(gz("cms.ui.category.url"),m_url);
|
||||
|
||||
m_url.setOnBlur("if (this.value == '') "
|
||||
+ "{ defaulting = true; this.value = urlize(this.form." + NAME
|
||||
+ ".value) } " + "else { this.value = urlize(this.value); }");
|
||||
addField(gz("cms.ui.category.url"), m_url);
|
||||
|
||||
addAction(new Finish());
|
||||
addAction(new Cancel());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void generateXML(PageState ps, Element parent) {
|
||||
m_script.generateXML(ps, parent);
|
||||
super.generateXML(ps, parent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Purpose:
|
||||
*
|
||||
* XXXToDo: Should be extended with the function:
|
||||
* Names have to be unambiguous in the selected language
|
||||
*
|
||||
* XXXToDo: Should be extended with the function: Names have to be unambiguous in the selected
|
||||
* language
|
||||
*/
|
||||
class NameUniqueListener implements ParameterListener {
|
||||
|
||||
private final CategoryRequestLocal m_category;
|
||||
private final Widget m_widget;
|
||||
private final int m_type;
|
||||
public final static int NAME_FIELD = 1;
|
||||
public final static int URL_FIELD = 2;
|
||||
|
||||
|
||||
NameUniqueListener(final CategoryRequestLocal category) {
|
||||
this(category,m_name,NAME_FIELD);
|
||||
this(category, m_name, NAME_FIELD);
|
||||
}
|
||||
|
||||
NameUniqueListener(final CategoryRequestLocal category,
|
||||
Widget widget, int type) {
|
||||
Widget widget, int type) {
|
||||
m_category = category;
|
||||
m_widget = widget;
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Purpose:
|
||||
|
|
@ -192,28 +193,29 @@ public class CategoryLocalizationForm extends BaseForm {
|
|||
* XXX provisional, has to be adapted
|
||||
*
|
||||
* @param e
|
||||
*
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
public final void validate(final ParameterEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
final PageState state = e.getPageState();
|
||||
final String title = (String) m_widget.getValue(state);
|
||||
|
||||
|
||||
final Category category = m_category.getCategory(state);
|
||||
|
||||
|
||||
final CategoryCollection children = category.getChildren();
|
||||
|
||||
|
||||
while (children.next()) {
|
||||
final Category child = children.getCategory();
|
||||
String compField =
|
||||
(m_type == URL_FIELD) ? child.getURL() : child.getName();
|
||||
String compField = (m_type == URL_FIELD) ? child.getURL() : child.getName();
|
||||
if (compField.equalsIgnoreCase(title)
|
||||
&& (m_category == null
|
||||
|| !m_category.getCategory(state).equals(child))) {
|
||||
throw new FormProcessException
|
||||
(lz("cms.ui.category.name_not_unique"));
|
||||
&& (m_category == null
|
||||
|| !m_category.getCategory(state).equals(child))) {
|
||||
throw new FormProcessException(lz("cms.ui.category.name_not_unique"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ import com.arsdigita.cms.ContentPage;
|
|||
import com.arsdigita.cms.ui.CMSForm;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.web.Web;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Class FolderForm implements the basic form for creating or renaming
|
||||
* folders.
|
||||
* Class FolderForm implements the basic form for creating or renaming folders.
|
||||
*
|
||||
* @author Jon Orris <jorris@redhat.com>
|
||||
* @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 TITLE = ContentPage.TITLE;
|
||||
|
||||
private static final String TITLE_ON_FOCUS =
|
||||
"if (this.form." + NAME + ".value == '') {" +
|
||||
" defaulting = true;" +
|
||||
" this.form." + NAME + ".value = urlize(this.value);" +
|
||||
"}";
|
||||
private static final String TITLE_ON_FOCUS = "if (this.form." + NAME + ".value == '') {"
|
||||
+ " defaulting = true;" + " this.form."
|
||||
+ NAME + ".value = urlize(this.value);" + "}";
|
||||
|
||||
private static final String TITLE_ON_KEY_UP =
|
||||
"if (defaulting) {" +
|
||||
" this.form." + NAME + ".value = urlize(this.value)" +
|
||||
"}";
|
||||
private static final String TITLE_ON_KEY_UP = "if (defaulting) {" + " this.form." + NAME
|
||||
+ ".value = urlize(this.value)" + "}";
|
||||
|
||||
private static final String FRAGMENT_ON_FOCUS = "defaulting = false";
|
||||
|
||||
private static final String FRAGMENT_ON_BLUR =
|
||||
"if (this.value == '') {" +
|
||||
" defaulting = true;" +
|
||||
" this.value = urlize(this.form." + TITLE + ".value)" +
|
||||
"} else {" +
|
||||
" this.value = urlize(this.value);" +
|
||||
"}";
|
||||
private static final String FRAGMENT_ON_BLUR = "if (this.value == '') {"
|
||||
+ " defaulting = true;"
|
||||
+ " this.value = urlize(this.form." + TITLE
|
||||
+ ".value)" + "} else {"
|
||||
+ " 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_fragment;
|
||||
|
|
@ -80,7 +77,6 @@ abstract class FolderBaseForm extends CMSForm {
|
|||
add(m_script, GridPanel.FULL_WIDTH);
|
||||
|
||||
// Title
|
||||
|
||||
add(new Label(gz("cms.ui.folder.name")));
|
||||
|
||||
m_title = new TextField(new TrimmedStringParameter(TITLE));
|
||||
|
|
@ -93,7 +89,6 @@ abstract class FolderBaseForm extends CMSForm {
|
|||
m_title.setOnKeyUp(TITLE_ON_KEY_UP);
|
||||
|
||||
// Fragment
|
||||
|
||||
add(new Label(gz("cms.ui.folder.fragment")));
|
||||
|
||||
m_fragment = new TextField(new TrimmedStringParameter(NAME));
|
||||
|
|
@ -119,4 +114,5 @@ abstract class FolderBaseForm extends CMSForm {
|
|||
private static String lz(final String key) {
|
||||
return (String) gz(key).localize();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.formbuilder.ui;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
|
|
@ -40,7 +39,7 @@ import com.arsdigita.domain.DomainObjectFactory;
|
|||
import com.arsdigita.formbuilder.PersistentFormSection;
|
||||
import com.arsdigita.formbuilder.PersistentProcessListener;
|
||||
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.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.RedirectSignal;
|
||||
|
|
@ -49,10 +48,9 @@ import java.io.IOException;
|
|||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* This class provides a pluggable widget for editing the persistent process
|
||||
* listeners for a persistent form.
|
||||
* It is designed to be used without requiring any significant
|
||||
* infrastructure on a page.
|
||||
* This class provides a pluggable widget for editing the persistent process listeners for a
|
||||
* persistent form. It is designed to be used without requiring any significant infrastructure on a
|
||||
* page.
|
||||
*/
|
||||
public class ProcessListenerEditor extends SimpleContainer {
|
||||
|
||||
|
|
@ -64,9 +62,8 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
protected ProcessListenerProperties m_edit_action;
|
||||
|
||||
/**
|
||||
* Constructor, creates a new control editor widget for editing the form
|
||||
* specified in the single selection model. The key returned by the single
|
||||
* selection model should be an instance of the
|
||||
* Constructor, creates a new control editor widget for editing the form specified in the single
|
||||
* selection model. The key returned by the single selection model should be an instance of the
|
||||
* {@link java.math.BigDecimal} class.
|
||||
*
|
||||
* @param form the form to edit
|
||||
|
|
@ -78,39 +75,40 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
// Help system is currently not workable
|
||||
String helpURL = FormBuilderUtil.getConfig().getActionsHelpLink();
|
||||
if (helpURL != null) {
|
||||
add(new Link(new Label(GlobalizationUtil.globalize
|
||||
("formbuilder.ui.help")), helpURL));
|
||||
add(new Link(new Label(GlobalizationUtil.globalize("formbuilder.ui.help")), helpURL));
|
||||
}
|
||||
|
||||
m_newAction = new NewAction(app);
|
||||
|
||||
Table t = new Table(new ProcessListenerTableModelBuilder(m_form),
|
||||
new String[] { "Form action", "", "" });
|
||||
m_action = new DecimalSingleSelectionModel(t.getRowSelectionModel());
|
||||
t.setDefaultCellRenderer(new TableCellRenderer() {
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
PersistentProcessListener l = (PersistentProcessListener)value;
|
||||
Table table = new Table(new ProcessListenerTableModelBuilder(m_form),
|
||||
new String[]{"Form action", "", ""});
|
||||
m_action = new DecimalSingleSelectionModel(table .getRowSelectionModel());
|
||||
table .setDefaultCellRenderer(new TableCellRenderer() {
|
||||
|
||||
if (column == 0) {
|
||||
return new Label(l.getDescription());
|
||||
} else if (column == 1) {
|
||||
ControlLink lk = new ControlLink( new Label(GlobalizationUtil
|
||||
.globalize("formbuilder.ui.edit") ));
|
||||
return lk;
|
||||
} else if (column == 2) {
|
||||
ControlLink lk = new ControlLink( new Label(GlobalizationUtil
|
||||
.globalize("formbuilder.ui.delete") ));
|
||||
lk.setConfirmation(GlobalizationUtil.globalize(
|
||||
"formbuilder.ui.form_action.delete_confirm"));
|
||||
return lk;
|
||||
}
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
PersistentProcessListener l = (PersistentProcessListener) value;
|
||||
|
||||
return null;
|
||||
if (column == 0) {
|
||||
return new Label(l.getDescription());
|
||||
} else if (column == 1) {
|
||||
ControlLink lk = new ControlLink(new Label(GlobalizationUtil
|
||||
.globalize("formbuilder.ui.edit")));
|
||||
return lk;
|
||||
} else if (column == 2) {
|
||||
ControlLink lk = new ControlLink(new Label(GlobalizationUtil
|
||||
.globalize("formbuilder.ui.delete")));
|
||||
lk.setConfirmation(GlobalizationUtil.globalize(
|
||||
"formbuilder.ui.form_action.delete_confirm"));
|
||||
return lk;
|
||||
}
|
||||
});
|
||||
t.addTableActionListener(new FormItemActionListener());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
table .addTableActionListener(new FormItemActionListener());
|
||||
|
||||
m_list_actions = new BoxPanel(BoxPanel.VERTICAL);
|
||||
m_edit_action = new ProcessListenerProperties(m_form,
|
||||
|
|
@ -119,20 +117,21 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
app);
|
||||
|
||||
m_newAction.addProcessListener(new FormItemProcessListener(m_edit_action,
|
||||
m_list_actions));
|
||||
m_list_actions));
|
||||
m_edit_action.addCompletionListener(new FormItemCompletionListener(m_list_actions,
|
||||
m_edit_action));
|
||||
|
||||
m_list_actions.add(m_newAction);
|
||||
m_list_actions.add(t);
|
||||
m_list_actions.add(table );
|
||||
|
||||
addComponents();
|
||||
|
||||
add(m_list_actions);
|
||||
add(m_edit_action);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addComponents() { }
|
||||
protected void addComponents() {
|
||||
}
|
||||
|
||||
public void register(Page page) {
|
||||
super.register(page);
|
||||
|
|
@ -145,6 +144,7 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
}
|
||||
|
||||
private class FormItemProcessListener implements FormProcessListener {
|
||||
|
||||
Component m_show;
|
||||
Component m_hide;
|
||||
|
||||
|
|
@ -160,9 +160,11 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
m_show.setVisible(e.getPageState(), true);
|
||||
m_hide.setVisible(e.getPageState(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class FormItemCompletionListener implements FormCompletionListener {
|
||||
|
||||
Component m_show;
|
||||
Component m_hide;
|
||||
|
||||
|
|
@ -178,11 +180,13 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
m_show.setVisible(e.getPageState(), true);
|
||||
m_hide.setVisible(e.getPageState(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class FormItemActionListener implements TableActionListener {
|
||||
|
||||
public void headSelected(TableActionEvent e) {}
|
||||
public void headSelected(TableActionEvent e) {
|
||||
}
|
||||
|
||||
public void cellSelected(TableActionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
|
|
@ -193,20 +197,18 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
m_edit_action.setVisible(state, true);
|
||||
m_list_actions.setVisible(state, false);
|
||||
} else {
|
||||
BigDecimal action_id = (BigDecimal)m_action.getSelectedKey(state);
|
||||
|
||||
try {
|
||||
BigDecimal formID = (BigDecimal)
|
||||
m_form.getSelectedKey( state );
|
||||
PersistentFormSection form =
|
||||
new PersistentFormSection( formID );
|
||||
BigDecimal action_id = (BigDecimal) m_action.getSelectedKey(state);
|
||||
|
||||
PersistentProcessListener l = (PersistentProcessListener)
|
||||
DomainObjectFactory.newInstance(
|
||||
try {
|
||||
BigDecimal formID = (BigDecimal) m_form.getSelectedKey(state);
|
||||
PersistentFormSection form = new PersistentFormSection(formID);
|
||||
|
||||
PersistentProcessListener l = (PersistentProcessListener) DomainObjectFactory
|
||||
.newInstance(
|
||||
new OID(PersistentProcessListener.BASE_DATA_OBJECT_TYPE,
|
||||
action_id));
|
||||
//l.delete();
|
||||
form.removeProcessListener( l );
|
||||
form.removeProcessListener(l);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new UncheckedWrapperException("cannot find listener", ex);
|
||||
}
|
||||
|
|
@ -214,11 +216,12 @@ public class ProcessListenerEditor extends SimpleContainer {
|
|||
|
||||
state.clearControlEvent();
|
||||
try {
|
||||
throw new RedirectSignal( state.stateAsURL(), true );
|
||||
} catch( IOException ex ) {
|
||||
throw new UncheckedWrapperException( ex );
|
||||
throw new RedirectSignal(state.stateAsURL(), true);
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,13 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.formbuilder.ui.editors;
|
||||
|
||||
import com.arsdigita.formbuilder.PersistentWidget;
|
||||
import com.arsdigita.formbuilder.PersistentFormSection;
|
||||
import com.arsdigita.formbuilder.parameters.PersistentParameterListener;
|
||||
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.FormData;
|
||||
|
|
@ -50,6 +49,7 @@ import com.arsdigita.bebop.parameters.StringParameter;
|
|||
import com.arsdigita.bebop.parameters.URLTokenValidationListener;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -57,7 +57,8 @@ import java.math.BigDecimal;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
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_action;
|
||||
|
|
@ -71,8 +72,10 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
|
||||
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,
|
||||
SingleSelectionModel form,
|
||||
|
|
@ -86,8 +89,6 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
addProcessListener(new WidgetFormProcessListener());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SingleSelectionModel getSelection() {
|
||||
return m_form;
|
||||
}
|
||||
|
|
@ -99,7 +100,7 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
|
||||
protected PersistentWidget getWidget(PageState state) {
|
||||
if (m_widget.get(state) == null) {
|
||||
BigDecimal action = (BigDecimal)m_action.getSelectedKey(state);
|
||||
BigDecimal action = (BigDecimal) m_action.getSelectedKey(state);
|
||||
|
||||
PersistentWidget widget = null;
|
||||
if (action == null) {
|
||||
|
|
@ -109,25 +110,31 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
try {
|
||||
widget = getWidget(action);
|
||||
} 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);
|
||||
}
|
||||
return (PersistentWidget)m_widget.get(state);
|
||||
return (PersistentWidget) m_widget.get(state);
|
||||
}
|
||||
|
||||
protected void addWidgets(FormSection section) {
|
||||
super.addWidgets(section);
|
||||
|
||||
if (showName()) addName(section);
|
||||
if (showDescription()) addDescription(section);
|
||||
if (includeRequiredRadioGroup()) addRequiredRadioGroup(section);
|
||||
if (showName()) {
|
||||
addName(section);
|
||||
}
|
||||
if (showDescription()) {
|
||||
addDescription(section);
|
||||
}
|
||||
if (includeRequiredRadioGroup()) {
|
||||
addRequiredRadioGroup(section);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the name field to the form. Override this method to alter the
|
||||
* creation of the name field.
|
||||
* Add the name field to the form. Override this method to alter the creation of the name field.
|
||||
*/
|
||||
protected void addName(FormSection section) {
|
||||
TextField name = new TextField(new StringParameter(NAME));
|
||||
|
|
@ -136,15 +143,14 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
name.addValidationListener(new StringInRangeValidationListener(1, 40));
|
||||
name.setSize(30);
|
||||
section.add(new Label(GlobalizationUtil.globalize(
|
||||
"formbuilder.ui.editors.name")), ColumnPanel.RIGHT);
|
||||
"formbuilder.ui.editors.name")), ColumnPanel.RIGHT);
|
||||
section.add(name);
|
||||
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the name field to the form. Override this method to alter the
|
||||
* creation of the name field.
|
||||
* Add the name field to the form. Override this method to alter the creation of the name field.
|
||||
*/
|
||||
protected void addDescription(FormSection section) {
|
||||
TextArea description = new TextArea(new StringParameter(DESCRIPTION));
|
||||
|
|
@ -152,7 +158,7 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
description.setRows(5);
|
||||
description.addValidationListener(new StringInRangeValidationListener(0, 200));
|
||||
section.add(new Label(GlobalizationUtil.globalize(
|
||||
"formbuilder.ui.editors.description")),
|
||||
"formbuilder.ui.editors.description")),
|
||||
ColumnPanel.RIGHT);
|
||||
section.add(description);
|
||||
|
||||
|
|
@ -160,60 +166,51 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
}
|
||||
|
||||
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(
|
||||
"formbuilder.ui.editors.answer_required")),
|
||||
"formbuilder.ui.editors.answer_required")),
|
||||
ColumnPanel.RIGHT);
|
||||
section.add(m_required);
|
||||
|
||||
|
||||
m_required.addOption(new Option(Boolean.TRUE.toString(), "Yes"));
|
||||
m_required.addOption(new Option(Boolean.FALSE.toString(), "No"));
|
||||
m_required.setOptionSelected(Boolean.FALSE.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is called then the value of the widget that is used for
|
||||
* the passed in model is used to auto-generate the value of the
|
||||
* "name" value. For instance, if you want the label to dictate
|
||||
* the "name" then you would pass in the label ParameterModel
|
||||
* and add the following to the labelWidget:
|
||||
* If this is called then the value of the widget that is used for the passed in model is used
|
||||
* to auto-generate the value of the "name" value. For instance, if you want the label to
|
||||
* dictate the "name" then you would pass in the label ParameterModel and add the following to
|
||||
* the labelWidget:
|
||||
*
|
||||
* labelWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " +
|
||||
* " defaulting = true; this.form." + NAME +
|
||||
* ".value = urlize(this.value); }");
|
||||
* labelWidget.setOnKeyUp(
|
||||
* "if (defaulting) { this.form." + NAME +
|
||||
* ".value = urlize(this.value) }"
|
||||
* );
|
||||
* labelWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " + " defaulting = true;
|
||||
* 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()
|
||||
*/
|
||||
protected void automaticallySetName(ParameterModel model) {
|
||||
Assert.exists(m_name);
|
||||
m_name.setOnFocus("defaulting = false");
|
||||
m_name.setOnBlur(
|
||||
"if (this.value == '') " +
|
||||
"{ defaulting = true; this.value = urlize(this.form." +
|
||||
model.getName() + ".value) }"
|
||||
"if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + model
|
||||
.getName() + ".value) }"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This determines whether or not the "required value" radio group
|
||||
* is part of the form. This returns true and should be overridden
|
||||
* by fields where it does not make sense to ask. For instance,
|
||||
* when the widget is a hidden field then asking if it is required
|
||||
* or not does not make any logical sense so those widgets should
|
||||
* return false.
|
||||
* This determines whether or not the "required value" radio group is part of the form. This
|
||||
* returns true and should be overridden by fields where it does not make sense to ask. For
|
||||
* instance, when the widget is a hidden field then asking if it is required 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
|
||||
* what state the widget is in.
|
||||
* This will always return the same value for a given widget no matter what state the widget is
|
||||
* in.
|
||||
*/
|
||||
protected boolean includeRequiredRadioGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void generateXML(PageState ps, Element parent) {
|
||||
m_script.generateXML(ps, parent);
|
||||
|
|
@ -221,8 +218,7 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
}
|
||||
|
||||
/**
|
||||
* Should the HTML name be on the form? Can be overridden
|
||||
* by sub classes.
|
||||
* Should the HTML name be on the form? Can be overridden by sub classes.
|
||||
*/
|
||||
protected boolean showName() {
|
||||
|
||||
|
|
@ -230,8 +226,7 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
}
|
||||
|
||||
/**
|
||||
* Should the description be on the form? Can be overridden
|
||||
* by sub classes.
|
||||
* Should the description be on the form? Can be overridden by sub classes.
|
||||
*/
|
||||
protected boolean showDescription() {
|
||||
|
||||
|
|
@ -261,31 +256,31 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
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
|
||||
if(includeRequiredRadioGroup()) {
|
||||
Collection col = widget.getValidationListeners();
|
||||
Iterator iterator;
|
||||
if(!col.isEmpty()) {
|
||||
iterator = col.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
PersistentParameterListener listener =
|
||||
(PersistentParameterListener)iterator.next();
|
||||
s_log.debug(listener.getClassName());
|
||||
|
||||
if(((String)listener.getClassName()).equals("com.arsdigita.bebop.parameters.NotEmptyValidationListener")) {
|
||||
m_required.setValue(state,Boolean.TRUE.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Get the associated listeners and set the value for the radio button accordingly
|
||||
if(includeRequiredRadioGroup()) {
|
||||
Collection col = widget.getValidationListeners();
|
||||
Iterator iterator;
|
||||
if(!col.isEmpty()) {
|
||||
iterator = col.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
PersistentParameterListener listener =
|
||||
(PersistentParameterListener)iterator.next();
|
||||
s_log.debug(listener.getClassName());
|
||||
|
||||
if(((String)listener.getClassName()).equals("com.arsdigita.bebop.parameters.NotEmptyValidationListener")) {
|
||||
m_required.setValue(state,Boolean.TRUE.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//m_name.setVisible(state, false);
|
||||
if(includeRequiredRadioGroup())
|
||||
if (includeRequiredRadioGroup()) {
|
||||
m_required.setValue(state, new Boolean(widget.isRequired()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +295,7 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
widget.setParameterName(name);
|
||||
|
||||
if (showDescription()) {
|
||||
String description = (String)data.get(DESCRIPTION);
|
||||
String description = (String) data.get(DESCRIPTION);
|
||||
widget.setDescription(description);
|
||||
}
|
||||
|
||||
|
|
@ -310,15 +305,15 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
}
|
||||
|
||||
if (includeRequiredRadioGroup()) {
|
||||
boolean required = ( (Boolean) m_required.getValue( pageState ) ).booleanValue();
|
||||
boolean required = ((Boolean) m_required.getValue(pageState)).booleanValue();
|
||||
|
||||
widget.setRequired( required );
|
||||
if( required ) {
|
||||
widget.setRequired(required);
|
||||
if (required) {
|
||||
// Answer is required
|
||||
String listenerClassName =
|
||||
"com.arsdigita.bebop.parameters.NotEmptyValidationListener";
|
||||
PersistentParameterListener listener =
|
||||
new PersistentParameterListener(listenerClassName);
|
||||
String listenerClassName
|
||||
= "com.arsdigita.bebop.parameters.NotEmptyValidationListener";
|
||||
PersistentParameterListener listener = new PersistentParameterListener(
|
||||
listenerClassName);
|
||||
widget.addValidationListener(listener);
|
||||
} else {
|
||||
// Answer is not required
|
||||
|
|
@ -328,14 +323,14 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
}
|
||||
|
||||
protected String getName(PageState pageState, FormData formData) {
|
||||
return (String)formData.get(NAME);
|
||||
return (String) formData.get(NAME);
|
||||
}
|
||||
|
||||
protected void addToForm(FormSectionEvent e,
|
||||
PersistentWidget widget)
|
||||
throws FormProcessException {
|
||||
|
||||
BigDecimal form_id = (BigDecimal)m_form.getSelectedKey(e.getPageState());
|
||||
BigDecimal form_id = (BigDecimal) m_form.getSelectedKey(e.getPageState());
|
||||
|
||||
PersistentFormSection form = null;
|
||||
try {
|
||||
|
|
@ -348,14 +343,14 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
form.save();
|
||||
}
|
||||
|
||||
|
||||
private class WidgetFormInitListener implements FormInitListener {
|
||||
|
||||
public void init(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
PageState state = e.getPageState();
|
||||
|
||||
BigDecimal action = (BigDecimal)m_action.getSelectedKey(state);
|
||||
BigDecimal action = (BigDecimal) m_action.getSelectedKey(state);
|
||||
|
||||
if (action == null) {
|
||||
initWidgets(e, null);
|
||||
|
|
@ -364,32 +359,38 @@ public abstract class WidgetForm extends PropertiesForm {
|
|||
try {
|
||||
widget = getWidget(action);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new FormProcessException("cannot find persistent widget "
|
||||
+ action, ex);
|
||||
throw new FormProcessException("cannot find persistent widget "
|
||||
+ action, ex);
|
||||
}
|
||||
initWidgets(e, widget);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class WidgetFormProcessListener implements FormProcessListener {
|
||||
|
||||
public void process(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
PageState state = e.getPageState();
|
||||
|
||||
if (isCancelled(state))
|
||||
if (isCancelled(state)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal action = (BigDecimal)m_action.getSelectedKey(state);
|
||||
BigDecimal action = (BigDecimal) m_action.getSelectedKey(state);
|
||||
|
||||
PersistentWidget widget = getWidget(state);
|
||||
|
||||
processWidgets(e, widget);
|
||||
widget.save();
|
||||
|
||||
if (action == null)
|
||||
if (action == null) {
|
||||
addToForm(e, widget);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<portlet-mode>HELP</portlet-mode>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>Hello, Pluto at last!</title>
|
||||
<title>Hello, Pluto from LibreCCM!</title>
|
||||
</portlet-info>
|
||||
</portlet>
|
||||
</portlet-app>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
<xsl:template match="theme:folder|theme:file" name="themeFolder">
|
||||
<tr>
|
||||
<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>
|
||||
|
||||
<xsl:if test="name()='theme:folder'">
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@
|
|||
<!-- EN Show categories to select -->
|
||||
<xsl:template match="cms:categoryWidget">
|
||||
<!-- <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"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@mode='javascript'">
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@
|
|||
<!-- DE Zeige die Kategorien zum Hinzufügen an -->
|
||||
<!-- EN Show categories to select -->
|
||||
<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"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@mode='javascript'">
|
||||
|
|
|
|||
|
|
@ -51,22 +51,34 @@
|
|||
<!--script type="text/javascript" src="/assets/fancybox/jquery.easing.pack.js"/-->
|
||||
|
||||
<!-- 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 -->
|
||||
<script type="text/javascript" src="/assets/fancybox2/source/jquery.fancybox.js"></script>
|
||||
<link rel="stylesheet" href="/assets/fancybox2/source/jquery.fancybox.css" type="text/css" media="screen"/>
|
||||
<script type="text/javascript"
|
||||
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) -->
|
||||
<link rel="stylesheet" type="text/css" href="/assets/fancybox2/source/helpers/jquery.fancybox-buttons.css" />
|
||||
<script type="text/javascript" src="/assets/fancybox2/source/helpers/jquery.fancybox-buttons.js"></script>
|
||||
<link rel="stylesheet"
|
||||
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) -->
|
||||
<link rel="stylesheet" type="text/css" href="/assets/fancybox2/source/helpers/jquery.fancybox-thumbs.css" />
|
||||
<script type="text/javascript" src="/assets/fancybox2/source/helpers/jquery.fancybox-thumbs.js"></script>
|
||||
<link rel="stylesheet"
|
||||
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) -->
|
||||
<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">
|
||||
$(document).ready(function() {
|
||||
|
|
|
|||
|
|
@ -196,23 +196,27 @@
|
|||
</xsl:template>
|
||||
|
||||
<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 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 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 match="useHTML5shiv">
|
||||
<xsl:text disable-output-escaping="yes">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="/assets/html5shiv.js"/>
|
||||
<![endif]-->
|
||||
</xsl:text>
|
||||
<xsl:value-of disable-output-escaping="yes" select="concat('
|
||||
<!--
|
||||
<!-[if lt IE 9]>
|
||||
<script src="', $context-prefix, '/assets/html5shiv.js"/>
|
||||
<![endif]
|
||||
-->')"/>
|
||||
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<!-- DE Setze den lokalisierten Seitentitel -->
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ Setting up global templates like getStaticText and getSetting
|
|||
</xsl:attribute>
|
||||
<img>
|
||||
<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 name="title">
|
||||
<xsl:value-of select="'moveUp'"/>
|
||||
|
|
@ -443,7 +443,7 @@ Setting up global templates like getStaticText and getSetting
|
|||
</xsl:attribute>
|
||||
<img>
|
||||
<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 name="title">
|
||||
<xsl:value-of select="'moveDown'"/>
|
||||
|
|
|
|||
|
|
@ -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}">Delete</a>
|
||||
<xsl:text> </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:when test="terms:indexer">
|
||||
<a href="{terms:action[@name='train']/@url}">Retrain indexer</a>
|
||||
<xsl:text> </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>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@
|
|||
<tr>
|
||||
<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>
|
||||
<xsl:text> </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>
|
||||
<xsl:text> </xsl:text>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<useJQuery/>
|
||||
<useFancybox/>
|
||||
<useMathJax/>
|
||||
<useHTML5shiv/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue