CCM NG/ccm-cms: EventPropertiesStep and associated ported to NG.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4762 8810af33-2d31-482b-a856-94f89814c4df
parent
3447dbe9e2
commit
d809c7611b
|
|
@ -0,0 +1,268 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2.1 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
|
import org.librecms.contenttypes.Event;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.libreccm.core.UnexpectedErrorException;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
import org.librecms.contenttypes.EventConfig;
|
||||||
|
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authoring step to view/edit the simple attributes of the Event content type
|
||||||
|
* (and its subclasses).
|
||||||
|
*
|
||||||
|
* The attributes edited are {@code name}, {@code title}, {@code lead},
|
||||||
|
* {@code startdate}, {@code starttime}, {@code end date},
|
||||||
|
* {@code endtime},{@code event date} (literal description of date),
|
||||||
|
* {@code location}, {@code main contributor} {@code event type},
|
||||||
|
* {@code map link}, and {@code cost}.
|
||||||
|
*
|
||||||
|
* This authoring step replaces the {@code com.arsdigita.ui.authoring.PageEdit}
|
||||||
|
* step for this type.
|
||||||
|
*/
|
||||||
|
public class EventPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the editing sheet added to this step
|
||||||
|
*/
|
||||||
|
public static String EDIT_SHEET_NAME = "edit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param itemSelectionModel
|
||||||
|
* @param authoringKitWizard
|
||||||
|
* @param selectedLanguageParam
|
||||||
|
*/
|
||||||
|
public EventPropertiesStep(final ItemSelectionModel itemSelectionModel,
|
||||||
|
final AuthoringKitWizard authoringKitWizard,
|
||||||
|
final StringParameter selectedLanguageParam) {
|
||||||
|
|
||||||
|
super(itemSelectionModel, authoringKitWizard, selectedLanguageParam);
|
||||||
|
|
||||||
|
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||||
|
BasicPageForm editSheet;
|
||||||
|
|
||||||
|
editSheet = new EventPropertyForm(itemSelectionModel, this);
|
||||||
|
add(EDIT_SHEET_NAME,
|
||||||
|
new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE),
|
||||||
|
new WorkflowLockedComponentAccess(editSheet, itemSelectionModel),
|
||||||
|
editSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
setDisplayComponent(getEventPropertySheet(itemSelectionModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a component that displays the properties of the Event specified
|
||||||
|
* by the ItemSelectionModel passed in.
|
||||||
|
*
|
||||||
|
* @param itemSelectionModel The ItemSelectionModel to use
|
||||||
|
*
|
||||||
|
* @return A component to display the state of the basic properties of the
|
||||||
|
* release
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static Component getEventPropertySheet(
|
||||||
|
final ItemSelectionModel itemSelectionModel) {
|
||||||
|
|
||||||
|
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
|
||||||
|
itemSelectionModel);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final ConfigurationManager confManager = cdiUtil
|
||||||
|
.findBean(ConfigurationManager.class);
|
||||||
|
final EventConfig eventConfig = confManager
|
||||||
|
.findConfiguration(EventConfig.class);
|
||||||
|
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"title");
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.name",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"name");
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.event.lead",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"lead");
|
||||||
|
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.event.start_time",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"startDate",
|
||||||
|
new DateTimeAttributeFormatter());
|
||||||
|
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.event.end_time",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"endDate",
|
||||||
|
new DateTimeAttributeFormatter());
|
||||||
|
if (!eventConfig.isHideDateDescription()) {
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.date_description",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"eventDate");
|
||||||
|
}
|
||||||
|
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.event.location",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"location");
|
||||||
|
|
||||||
|
if (!eventConfig.isHideMainContributor()) {
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.main_contributor",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"mainContributor");
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideEventType()) {
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.event_type",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"eventType");
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideLinkToMap()) {
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.link_to_map",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"mapLink");
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideCost()) {
|
||||||
|
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.event.cost",
|
||||||
|
CmsConstants.CMS_BUNDLE),
|
||||||
|
"cost");
|
||||||
|
}
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private class which implements an AttributeFormatter interface for date
|
||||||
|
* values. Its format(...) class returns a string representation for either
|
||||||
|
* a false or a true value.
|
||||||
|
*/
|
||||||
|
private static class DateTimeAttributeFormatter
|
||||||
|
implements DomainObjectPropertySheet.AttributeFormatter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor, does nothing.
|
||||||
|
*/
|
||||||
|
public DateTimeAttributeFormatter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formatter for the value of an attribute.
|
||||||
|
*
|
||||||
|
* It currently relays on the prerequisite that the passed in property
|
||||||
|
* attribute is in fact a date property. No type checking yet!
|
||||||
|
*
|
||||||
|
* Note: the format method has to be executed at each page request. Take
|
||||||
|
* care to properly adjust globalization and localization here!
|
||||||
|
*
|
||||||
|
* @param obj Object containing the attribute to format.
|
||||||
|
* @param attribute Name of the attribute to retrieve and format
|
||||||
|
* @param state PageState of the request
|
||||||
|
*
|
||||||
|
* @return A String representation of the retrieved boolean attribute of
|
||||||
|
* the domain object.
|
||||||
|
*/
|
||||||
|
public String format(final Object obj,
|
||||||
|
final String attribute,
|
||||||
|
final PageState state) {
|
||||||
|
|
||||||
|
if (obj != null && obj instanceof Event) {
|
||||||
|
|
||||||
|
final Event event = (Event) obj;
|
||||||
|
final BeanInfo beanInfo;
|
||||||
|
try {
|
||||||
|
beanInfo = Introspector.getBeanInfo(Event.class);
|
||||||
|
} catch (IntrospectionException ex) {
|
||||||
|
throw new UnexpectedErrorException(ex);
|
||||||
|
}
|
||||||
|
final Optional<PropertyDescriptor> propertyDescriptor = Arrays
|
||||||
|
.stream(beanInfo.getPropertyDescriptors())
|
||||||
|
.filter(current -> attribute.equals(current.getName()))
|
||||||
|
.findAny();
|
||||||
|
|
||||||
|
if (propertyDescriptor.isPresent()) {
|
||||||
|
|
||||||
|
final GlobalizationHelper globalizationHelper = CdiUtil
|
||||||
|
.createCdiUtil().findBean(GlobalizationHelper.class);
|
||||||
|
|
||||||
|
final Method readMethod = propertyDescriptor
|
||||||
|
.get()
|
||||||
|
.getReadMethod();
|
||||||
|
|
||||||
|
final Object result;
|
||||||
|
try {
|
||||||
|
result = readMethod.invoke(obj);
|
||||||
|
} catch (IllegalAccessException
|
||||||
|
| IllegalArgumentException
|
||||||
|
| InvocationTargetException ex) {
|
||||||
|
throw new UnexpectedErrorException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DateFormat
|
||||||
|
.getDateTimeInstance(
|
||||||
|
DateFormat.LONG,
|
||||||
|
DateFormat.SHORT,
|
||||||
|
globalizationHelper.getNegotiatedLocale())
|
||||||
|
.format(result);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return (String) new GlobalizedMessage(
|
||||||
|
"cms.ui.unknown",
|
||||||
|
CmsConstants.CMS_BUNDLE)
|
||||||
|
.localize();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return (String) new GlobalizedMessage("cms.ui.unknown",
|
||||||
|
CmsConstants.CMS_BUNDLE)
|
||||||
|
.localize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,536 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2.1 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.form.Time;
|
||||||
|
import com.arsdigita.bebop.parameters.DateParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.TimeParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
|
import org.librecms.contenttypes.Event;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ui.CMSDHTMLEditor;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
|
import org.librecms.contenttypes.EventConfig;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form to edit the basic properties of an {@link Event} object.
|
||||||
|
*
|
||||||
|
* Used by {@link EventPropertiesStep} authoring kit step.
|
||||||
|
*
|
||||||
|
* This form can be extended to create forms for Event subclasses.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EventPropertyForm
|
||||||
|
extends BasicPageForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of this form
|
||||||
|
*/
|
||||||
|
public static final String ID = "event_edit";
|
||||||
|
private final static Logger LOGGER = LogManager
|
||||||
|
.getLogger(EventPropertyForm.class);
|
||||||
|
private EventPropertiesStep eventPropertiesStep;
|
||||||
|
/**
|
||||||
|
* event date parameter name
|
||||||
|
*/
|
||||||
|
public static final String START_DATE = "startDate";
|
||||||
|
public static final String END_DATE = "endDate";
|
||||||
|
public static final String START_TIME = "startTime";
|
||||||
|
public static final String END_TIME = "endTime";
|
||||||
|
public static final String EVENT_DATE = "eventDate";
|
||||||
|
/**
|
||||||
|
* location parameter name
|
||||||
|
*/
|
||||||
|
public static final String LOCATION = "location";
|
||||||
|
/**
|
||||||
|
* lead parameter name
|
||||||
|
*/
|
||||||
|
public static final String LEAD = "lead";
|
||||||
|
/**
|
||||||
|
* Main contributor parameter name
|
||||||
|
*/
|
||||||
|
public static final String MAIN_CONTRIBUTOR = "main_contributor";
|
||||||
|
/**
|
||||||
|
* Event type parameter name
|
||||||
|
*/
|
||||||
|
public static final String EVENT_TYPE = "event_type";
|
||||||
|
/**
|
||||||
|
* Map link parameter name
|
||||||
|
*/
|
||||||
|
public static final String MAP_LINK = "map_link";
|
||||||
|
/**
|
||||||
|
* cost parameter name
|
||||||
|
*/
|
||||||
|
public static final String COST = "cost";
|
||||||
|
|
||||||
|
/* DateWidgets have to be accessible later on */
|
||||||
|
private com.arsdigita.bebop.form.Date startDateField;
|
||||||
|
private com.arsdigita.bebop.form.Date endDateField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new form to edit the Event object specified by the item
|
||||||
|
* selection model passed in.
|
||||||
|
*
|
||||||
|
* @param itemSelectionModel The ItemSelectionModel to use to obtain the
|
||||||
|
* Event to work on
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public EventPropertyForm(final ItemSelectionModel itemSelectionModel) {
|
||||||
|
this(itemSelectionModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new form to edit the Event object specified by the item
|
||||||
|
* selection model passed in.
|
||||||
|
*
|
||||||
|
* @param itemSelectionModel The ItemSelectionModel to use to obtain the
|
||||||
|
* Event to work on
|
||||||
|
* @param eventPropertiesStep The EventPropertiesStep which controls this
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public EventPropertyForm(final ItemSelectionModel itemSelectionModel,
|
||||||
|
final EventPropertiesStep eventPropertiesStep) {
|
||||||
|
super(ID, itemSelectionModel);
|
||||||
|
this.eventPropertiesStep = eventPropertiesStep;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds widgets to the form.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final ConfigurationManager confManager = cdiUtil
|
||||||
|
.findBean(ConfigurationManager.class);
|
||||||
|
final EventConfig eventConfig = confManager
|
||||||
|
.findConfiguration(EventConfig.class);
|
||||||
|
|
||||||
|
/* Summary (lead) */
|
||||||
|
final ParameterModel leadParam = new StringParameter(LEAD);
|
||||||
|
if (!eventConfig.isLeadTextOptional()) {
|
||||||
|
leadParam.addParameterListener(new NotNullValidationListener());
|
||||||
|
}
|
||||||
|
final TextArea lead = new TextArea(leadParam);
|
||||||
|
lead.setLabel(new GlobalizedMessage("cms.contenttypes.ui.event.lead",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
lead.setCols(50);
|
||||||
|
lead.setRows(5);
|
||||||
|
add(lead);
|
||||||
|
|
||||||
|
/* Start date and time */
|
||||||
|
final ParameterModel eventStartDateParam = new DateParameter(START_DATE);
|
||||||
|
eventStartDateParam
|
||||||
|
.addParameterListener(new NotNullValidationListener());
|
||||||
|
// Use bebop date instead of java.util.date
|
||||||
|
startDateField = new com.arsdigita.bebop.form.Date(eventStartDateParam);
|
||||||
|
startDateField.setLabel(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.start_date",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
// Set the upper und lower boundary of the year select box
|
||||||
|
startDateField
|
||||||
|
.setYearRange(
|
||||||
|
eventConfig.getStartYear(),
|
||||||
|
GregorianCalendar.getInstance().get(Calendar.YEAR)
|
||||||
|
+ eventConfig.getEndYearDelta());
|
||||||
|
add(startDateField);
|
||||||
|
|
||||||
|
final ParameterModel eventStartTimeParam = new TimeParameter(START_TIME);
|
||||||
|
if (!eventConfig.isStartTimeOptional()) {
|
||||||
|
eventStartTimeParam.addParameterListener(
|
||||||
|
new NotNullValidationListener());
|
||||||
|
}
|
||||||
|
final Time startTime = new Time(eventStartTimeParam);
|
||||||
|
startTime
|
||||||
|
.setLabel(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.start_time",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
add(startTime);
|
||||||
|
|
||||||
|
/* End date and time */
|
||||||
|
final ParameterModel eventEndDateParam = new DateParameter(END_DATE);
|
||||||
|
// Use bebop date instead of java.util.date
|
||||||
|
endDateField = new com.arsdigita.bebop.form.Date(eventEndDateParam);
|
||||||
|
endDateField
|
||||||
|
.setLabel(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.end_date",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
endDateField
|
||||||
|
.setHint(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.end_date_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
endDateField
|
||||||
|
.setYearRange(eventConfig.getStartYear(),
|
||||||
|
GregorianCalendar.getInstance().get(Calendar.YEAR)
|
||||||
|
+ eventConfig.getEndYearDelta());
|
||||||
|
add(endDateField);
|
||||||
|
|
||||||
|
final ParameterModel eventEndTimeParam = new TimeParameter(END_TIME);
|
||||||
|
final Time endTime = new Time(eventEndTimeParam);
|
||||||
|
endTime
|
||||||
|
.setLabel(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.end_time",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
endTime
|
||||||
|
.setHint(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.end_time_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
add(endTime);
|
||||||
|
|
||||||
|
|
||||||
|
/* optional additional / literal date description */
|
||||||
|
if (!eventConfig.isHideDateDescription()) {
|
||||||
|
final ParameterModel eventDateParam
|
||||||
|
= new StringParameter(EVENT_DATE);
|
||||||
|
if (eventConfig.isUseHtmlDateDescription()) {
|
||||||
|
CMSDHTMLEditor eventDate = new CMSDHTMLEditor(eventDateParam);
|
||||||
|
eventDate.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.date_description",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
eventDate.setHint(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.date_description_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
eventDate.setCols(40);
|
||||||
|
eventDate.setRows(8);
|
||||||
|
add(eventDate);
|
||||||
|
} else {
|
||||||
|
eventDateParam.addParameterListener(
|
||||||
|
new StringInRangeValidationListener(0, 100));
|
||||||
|
TextArea eventDate = new TextArea(eventDateParam);
|
||||||
|
eventDate
|
||||||
|
.setLabel(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.date_description",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
eventDate.setHint(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.date_description_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
eventDate.setCols(50);
|
||||||
|
eventDate.setRows(2);
|
||||||
|
add(eventDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* extensive description of location */
|
||||||
|
final ParameterModel locationParam = new StringParameter(LOCATION);
|
||||||
|
final CMSDHTMLEditor location = new CMSDHTMLEditor(locationParam);
|
||||||
|
location
|
||||||
|
.setLabel(
|
||||||
|
new GlobalizedMessage("cms.contenttypes.ui.event.location",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
location
|
||||||
|
.setHint(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.location_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
location.setCols(40);
|
||||||
|
location.setRows(8);
|
||||||
|
add(location);
|
||||||
|
|
||||||
|
|
||||||
|
/* optional: main contributor */
|
||||||
|
if (!eventConfig.isHideMainContributor()) {
|
||||||
|
final ParameterModel mainContributorParam
|
||||||
|
= new StringParameter(MAIN_CONTRIBUTOR);
|
||||||
|
final CMSDHTMLEditor mainContributor
|
||||||
|
= new CMSDHTMLEditor(mainContributorParam);
|
||||||
|
mainContributor.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.main_contributor",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
mainContributor.setHint(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.main_contributor_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
mainContributor.setCols(40);
|
||||||
|
mainContributor.setRows(10);
|
||||||
|
add(mainContributor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* optional: event type */
|
||||||
|
if (!eventConfig.isHideEventType()) {
|
||||||
|
final ParameterModel eventTypeParam
|
||||||
|
= new StringParameter(EVENT_TYPE);
|
||||||
|
final TextField eventType = new TextField(eventTypeParam);
|
||||||
|
eventType.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.event_type",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
eventType.setHint(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.event_type_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
eventType.setSize(30);
|
||||||
|
eventType.setMaxLength(30);
|
||||||
|
add(eventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* optional: link to map */
|
||||||
|
if (!eventConfig.isHideLinkToMap()) {
|
||||||
|
final ParameterModel mapLinkParam = new StringParameter(MAP_LINK);
|
||||||
|
final TextArea mapLink = new TextArea(mapLinkParam);
|
||||||
|
mapLink.setLabel(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.link_to_map",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
mapLink.setHint(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.link_to_map_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
mapLink.setCols(40);
|
||||||
|
mapLink.setRows(2);
|
||||||
|
add(mapLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* optional: costs */
|
||||||
|
if (!eventConfig.isHideCost()) {
|
||||||
|
final ParameterModel costParam = new TrimmedStringParameter(COST);
|
||||||
|
final TextField cost = new TextField(costParam);
|
||||||
|
cost.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.cost",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
cost.setHint(new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.cost_hint",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
cost.setSize(30);
|
||||||
|
cost.setMaxLength(30);
|
||||||
|
add(cost);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*
|
||||||
|
* @throws FormProcessException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void validate(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
super.validate(event);
|
||||||
|
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
java.util.Date startDate = data.getDate(START_DATE);
|
||||||
|
java.util.Date endDate = data.getDate(END_DATE);
|
||||||
|
|
||||||
|
if (endDate != null) {
|
||||||
|
if (startDate == null || startDate.compareTo(endDate) > 0) {
|
||||||
|
throw new FormProcessException(
|
||||||
|
"End date must be after start date",
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"cms.contenttypes.ui.event.end_date_after_start_date",
|
||||||
|
CmsConstants.CMS_BUNDLE)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form initialisation hook. Fills widgets with data.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) {
|
||||||
|
// Do some initialization hook stuff
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
final Event item = (Event) super.initBasicWidgets(event);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final ConfigurationManager confManager = cdiUtil
|
||||||
|
.findBean(ConfigurationManager.class);
|
||||||
|
final EventConfig eventConfig = confManager
|
||||||
|
.findConfiguration(EventConfig.class);
|
||||||
|
|
||||||
|
// Start date should always be set
|
||||||
|
final java.util.Date startDate;
|
||||||
|
if (item.getStartDate() == null) {
|
||||||
|
// new Date is initialised to current time
|
||||||
|
startDate = new java.util.Date();
|
||||||
|
} else {
|
||||||
|
startDate = item.getStartDate();
|
||||||
|
}
|
||||||
|
startDateField.addYear(startDate);
|
||||||
|
|
||||||
|
// End date can be null
|
||||||
|
final java.util.Date endDate;
|
||||||
|
if (item.getEndDate() == null) {
|
||||||
|
// new Date is initialised to current time
|
||||||
|
endDate = new java.util.Date();
|
||||||
|
} else {
|
||||||
|
endDate = item.getEndDate();
|
||||||
|
}
|
||||||
|
endDateField.addYear(endDate);
|
||||||
|
|
||||||
|
data.put(LEAD, item.getDescription());
|
||||||
|
data.put(START_DATE, startDate);
|
||||||
|
data.put(START_TIME, startDate.getTime());
|
||||||
|
data.put(END_DATE, endDate);
|
||||||
|
data.put(END_TIME, endDate.getTime());
|
||||||
|
if (!eventConfig.isHideDateDescription()) {
|
||||||
|
data.put(EVENT_DATE, item.getEventDate());
|
||||||
|
}
|
||||||
|
data.put(LOCATION, item.getLocation());
|
||||||
|
if (!eventConfig.isHideMainContributor()) {
|
||||||
|
data.put(MAIN_CONTRIBUTOR, item.getMainContributor());
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideEventType()) {
|
||||||
|
data.put(EVENT_TYPE, item.getEventType());
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideLinkToMap()) {
|
||||||
|
data.put(MAP_LINK, item.getMapLink());
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideCost()) {
|
||||||
|
data.put(COST, item.getCost());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels streamlined editing.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void submitted(final FormSectionEvent event) {
|
||||||
|
if (eventPropertiesStep != null
|
||||||
|
&& getSaveCancelSection()
|
||||||
|
.getCancelButton()
|
||||||
|
.isSelected(event.getPageState())) {
|
||||||
|
eventPropertiesStep.cancelStreamlinedCreation(event.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form processing hook. Saves Event object.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event) {
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
|
final Event item = (Event) super.processBasicWidgets(event);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final ConfigurationManager confManager = cdiUtil
|
||||||
|
.findBean(ConfigurationManager.class);
|
||||||
|
final EventConfig eventConfig = confManager
|
||||||
|
.findConfiguration(EventConfig.class);
|
||||||
|
|
||||||
|
// save only if save button was pressed
|
||||||
|
if (item != null
|
||||||
|
&& getSaveCancelSection()
|
||||||
|
.getSaveButton()
|
||||||
|
.isSelected(event.getPageState())) {
|
||||||
|
|
||||||
|
final java.util.Date startDate = (java.util.Date) data
|
||||||
|
.get(START_DATE);
|
||||||
|
startDate.setTime(((java.util.Date) data.get(START_TIME)).getTime());
|
||||||
|
item.setStartDate((java.util.Date) data.get(START_DATE));
|
||||||
|
|
||||||
|
final java.util.Date endDate = (java.util.Date) data
|
||||||
|
.get(END_DATE);
|
||||||
|
endDate.setTime(((java.util.Date) data.get(END_TIME)).getTime());
|
||||||
|
item.setEndDate((java.util.Date) data.get(END_DATE));
|
||||||
|
//date_description
|
||||||
|
if (!eventConfig.isHideDateDescription()) {
|
||||||
|
item.getEventDate().addValue(
|
||||||
|
KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) data.get(EVENT_DATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!eventConfig.isHideMainContributor()) {
|
||||||
|
item
|
||||||
|
.getMainContributor()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) data.get(MAIN_CONTRIBUTOR));
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideEventType()) {
|
||||||
|
item
|
||||||
|
.getEventType()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) data.get(EVENT_TYPE));
|
||||||
|
}
|
||||||
|
if (!eventConfig.isHideLinkToMap()) {
|
||||||
|
item.setMapLink((String) data.get(MAP_LINK));
|
||||||
|
}
|
||||||
|
item
|
||||||
|
.getLocation()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) data.get(LOCATION));
|
||||||
|
item
|
||||||
|
.getDescription()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) data.get(LEAD));
|
||||||
|
if (!eventConfig.isHideCost()) {
|
||||||
|
item
|
||||||
|
.getCost()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) data.get(COST));
|
||||||
|
}
|
||||||
|
|
||||||
|
final ContentItemRepository itemRepo = cdiUtil
|
||||||
|
.findBean(ContentItemRepository.class);
|
||||||
|
|
||||||
|
itemRepo.save(item);
|
||||||
|
}
|
||||||
|
if (eventPropertiesStep != null) {
|
||||||
|
eventPropertiesStep.maybeForwardToNextStep(event.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,6 @@ import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
import org.librecms.contenttypes.News;
|
import org.librecms.contenttypes.News;
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,10 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
import com.arsdigita.bebop.FormData;
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.form.RadioGroup;
|
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
import com.arsdigita.bebop.parameters.DateParameter;
|
import com.arsdigita.bebop.parameters.DateParameter;
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,145 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.contenttypes;
|
||||||
|
|
||||||
|
import org.libreccm.configuration.Configuration;
|
||||||
|
import org.libreccm.configuration.Setting;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class EventConfig {
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean hideDateDescription = false;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean hideMainContributor = false;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean hideEventType = false;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean hideLinkToMap = false;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean hideCost = false;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean useHtmlDateDescription = true;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private int startYear = GregorianCalendar.getInstance().get(Calendar.YEAR)
|
||||||
|
- 1;
|
||||||
|
@Setting
|
||||||
|
private int endYearDelta = 3;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean leadTextOptional = false;
|
||||||
|
|
||||||
|
@Setting
|
||||||
|
private boolean startTimeOptional = false;
|
||||||
|
|
||||||
|
public boolean isHideDateDescription() {
|
||||||
|
return hideDateDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHideDateDescription(final boolean hideDateDescription) {
|
||||||
|
this.hideDateDescription = hideDateDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isHideMainContributor() {
|
||||||
|
return hideMainContributor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHideMainContributor(final boolean hideMainContributor) {
|
||||||
|
this.hideMainContributor = hideMainContributor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isHideEventType() {
|
||||||
|
return hideEventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHideEventType(final boolean hideEventType) {
|
||||||
|
this.hideEventType = hideEventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isHideLinkToMap() {
|
||||||
|
return hideLinkToMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHideLinkToMap(final boolean hideLinkToMap) {
|
||||||
|
this.hideLinkToMap = hideLinkToMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isHideCost() {
|
||||||
|
return hideCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHideCost(final boolean hideCost) {
|
||||||
|
this.hideCost = hideCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isUseHtmlDateDescription() {
|
||||||
|
return useHtmlDateDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseHtmlDateDescription(final boolean useHtmlDateDescription) {
|
||||||
|
this.useHtmlDateDescription = useHtmlDateDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartYear() {
|
||||||
|
return startYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartYear(final int startYear) {
|
||||||
|
this.startYear = startYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEndYearDelta() {
|
||||||
|
return endYearDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndYearDelta(final int endYearDelta) {
|
||||||
|
this.endYearDelta = endYearDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isLeadTextOptional() {
|
||||||
|
return leadTextOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeadTextOptional(final boolean leadTextOptional) {
|
||||||
|
this.leadTextOptional = leadTextOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isStartTimeOptional() {
|
||||||
|
return startTimeOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTimeOptional(final boolean startTimeOptional) {
|
||||||
|
this.startTimeOptional = startTimeOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -18,19 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.bebop.form;
|
package com.arsdigita.bebop.form;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a text field in an HTML form.
|
* A class representing a text field in an HTML form.
|
||||||
*
|
*
|
||||||
* @author Karl Goldstein
|
* @author Karl Goldstein
|
||||||
* @author Uday Mathur
|
* @author Uday Mathur
|
||||||
* @author Rory Solomon
|
* @author Rory Solomon
|
||||||
* @author Michael Pih
|
* @author Michael Pih
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class TextField extends Widget {
|
public class TextField extends Widget {
|
||||||
|
|
||||||
|
|
@ -43,23 +40,23 @@ public class TextField extends Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string naming the type of this widget.
|
* Returns a string naming the type of this widget.
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "text";
|
return "text";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the <tt>MAXLENGTH</tt> attribute for the <tt>INPUT</tt> tag
|
* Sets the <tt>MAXLENGTH</tt> attribute for the <tt>INPUT</tt> tag used to
|
||||||
* used to render this form element.
|
* render this form element.
|
||||||
*/
|
*/
|
||||||
public void setMaxLength(int length) {
|
public void setMaxLength(int length) {
|
||||||
setAttribute("MAXLENGTH", String.valueOf(length));
|
setAttribute("MAXLENGTH", String.valueOf(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the <tt>SIZE</tt> attribute for the <tt>INPUT</tt> tag
|
* Sets the <tt>SIZE</tt> attribute for the <tt>INPUT</tt> tag used to
|
||||||
* used to render this form element.
|
* render this form element.
|
||||||
*/
|
*/
|
||||||
public void setSize(int size) {
|
public void setSize(int size) {
|
||||||
setAttribute("SIZE", String.valueOf(size));
|
setAttribute("SIZE", String.valueOf(size));
|
||||||
|
|
@ -69,5 +66,4 @@ public class TextField extends Widget {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue