- Added new style labels to the forms of the generic contenttypes in ccm-cms

- Added PrintListeners to various select fields ins these forms. For the database driven fields this means that a restart is not 
  longer required to see new values (for example for contact types)


git-svn-id: https://svn.libreccm.org/ccm/trunk@2716 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-06-24 08:44:08 +00:00
parent 4b7ff4f902
commit 06bfe7c709
21 changed files with 1039 additions and 893 deletions

View File

@ -44,20 +44,20 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
/** /**
* Form to edit the basic properties of a Content Group. This form can be * Form to edit the basic properties of a Content Group. This form can be extended to create forms
* extended to create forms for Brand subclasses. * for Brand subclasses.
*/ */
public class ContentGroupPropertyForm extends BasicItemForm { public class ContentGroupPropertyForm extends BasicItemForm {
/** Internal logger instance to faciliate debugging. Enable logging output /**
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment * Internal logger instance to faciliate debugging. Enable logging output by editing
* and set com.arsdigita.cms.contenttypes.ui.ContentGroupPropertyForm=DEBUG * /WEB-INF/conf/log4j.properties int hte runtime environment and set
* by uncommenting or adding the line. */ * com.arsdigita.cms.contenttypes.ui.ContentGroupPropertyForm=DEBUG by uncommenting or adding
private final static org.apache.log4j.Logger s_log = * the line.
org.apache.log4j.Logger.getLogger(ContentGroupPropertyForm.class); */
private final static org.apache.log4j.Logger s_log = org.apache.log4j.Logger.getLogger(
ContentGroupPropertyForm.class);
public final static String ASSOCIATED_ITEMS = "associatedItems"; public final static String ASSOCIATED_ITEMS = "associatedItems";
public final static String RELATED_ITEM = "relatedItem"; public final static String RELATED_ITEM = "relatedItem";
@ -66,14 +66,14 @@ public class ContentGroupPropertyForm extends BasicItemForm {
private CheckboxGroup m_checkboxGroup; private CheckboxGroup m_checkboxGroup;
/** /**
* Creates a new form to edit the Brand object specified * Creates a new form to edit the Brand object specified by the item selection model passed in.
* by the item selection model passed in. *
* @param itemModel The ItemSelectionModel to use to obtain the * @param itemModel The ItemSelectionModel to use to obtain the ContentGroupContainer to
* ContentGroupContainer to work on * work on
* @param attributeName The name of the content group to use during * @param attributeName The name of the content group to use during the process stage of this
* the process stage of this form. * form.
*/ */
public ContentGroupPropertyForm(ItemSelectionModel itemModel, public ContentGroupPropertyForm(ItemSelectionModel itemModel,
String attributeName) { String attributeName) {
super("contentGroupProperty", itemModel); super("contentGroupProperty", itemModel);
m_attributeName = attributeName; m_attributeName = attributeName;
@ -84,40 +84,39 @@ public class ContentGroupPropertyForm extends BasicItemForm {
*/ */
@Override @Override
protected void addWidgets() { protected void addWidgets() {
add(new Label(GlobalizationUtil TextField nameWidget = new TextField(new TrimmedStringParameter(ContentGroup.NAME));
.globalize("cms.contenttypes.ui.content_group_name"))); nameWidget.setLabel(GlobalizationUtil
TextField nameWidget = .globalize("cms.contenttypes.ui.content_group_name"));
new TextField(new TrimmedStringParameter(ContentGroup.NAME));
nameWidget.addValidationListener(new NotNullValidationListener()); nameWidget.addValidationListener(new NotNullValidationListener());
add(nameWidget); add(nameWidget);
add(new Label(GlobalizationUtil add(new Label(GlobalizationUtil
.globalize("cms.contenttypes.ui.content_group_current_items")) { .globalize("cms.contenttypes.ui.content_group_current_items")) {
@Override @Override
public boolean isVisible(PageState state) { public boolean isVisible(PageState state) {
ContentGroupContainer item = ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
(ContentGroupContainer) getItemSelectionModel() .getSelectedObject(state);
.getSelectedObject(state); ContentGroup group = getCurrentGroup(item, m_attributeName);
ContentGroup group =
getCurrentGroup(item, m_attributeName);
return group != null && group.getContentItems().size() > 0; return group != null && group.getContentItems().size() > 0;
} }
}); });
m_checkboxGroup = new CheckboxGroup(ASSOCIATED_ITEMS) { m_checkboxGroup = new CheckboxGroup(ASSOCIATED_ITEMS) {
@Override
public boolean isVisible(PageState state) { @Override
ContentGroupContainer item = public boolean isVisible(PageState state) {
(ContentGroupContainer) getItemSelectionModel() ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
.getSelectedObject(state); .getSelectedObject(state);
ContentGroup group = ContentGroup group = getCurrentGroup(item, m_attributeName);
getCurrentGroup(item, m_attributeName); return group != null && group.getContentItems().size() > 0;
return group != null && group.getContentItems().size() > 0; }
}
}; };
add(m_checkboxGroup); add(m_checkboxGroup);
add(new Label(GlobalizationUtil add(new Label(GlobalizationUtil
.globalize("cms.contenttypes.ui.content_group_new_item"))); .globalize("cms.contenttypes.ui.content_group_new_item")));
try { try {
add(new ItemSearchWidget(RELATED_ITEM, getSearchContentType())); add(new ItemSearchWidget(RELATED_ITEM, getSearchContentType()));
} catch (DataObjectNotFoundException de) { } catch (DataObjectNotFoundException de) {
@ -125,12 +124,10 @@ public class ContentGroupPropertyForm extends BasicItemForm {
} }
} }
/** /**
* Perform form initialization. Children should override this * Perform form initialization. Children should override this this method to pre-fill the
* this method to pre-fill the widgets with data, instantiate * widgets with data, instantiate the content item, etc.
* the content item, etc. *
*
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
@ -138,8 +135,8 @@ public class ContentGroupPropertyForm extends BasicItemForm {
s_log.debug("here in init"); s_log.debug("here in init");
FormData data = e.getFormData(); FormData data = e.getFormData();
PageState state = e.getPageState(); PageState state = e.getPageState();
ContentGroupContainer item = ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
(ContentGroupContainer) getItemSelectionModel().getSelectedObject(state); .getSelectedObject(state);
ContentGroup group = getCurrentGroup(item, m_attributeName); ContentGroup group = getCurrentGroup(item, m_attributeName);
if (group != null) { if (group != null) {
data.put(ContentGroup.NAME, group.getName()); data.put(ContentGroup.NAME, group.getName());
@ -149,46 +146,42 @@ public class ContentGroupPropertyForm extends BasicItemForm {
ItemCollection collection = group.getContentItems(); ItemCollection collection = group.getContentItems();
Collection selected = new ArrayList(); Collection selected = new ArrayList();
while (collection.next()) { while (collection.next()) {
s_log.debug("NAME = " + s_log.debug("NAME = " + collection.getContentItem().getName());
collection.getContentItem().getName());
s_log.debug("ID = " + collection.getID()); s_log.debug("ID = " + collection.getID());
m_checkboxGroup.addOption m_checkboxGroup.addOption(new Option(collection.getID().toString(),
(new Option(collection.getID().toString(), collection.getContentItem().getName()), state);
collection.getContentItem().getName()), state);
selected.add(collection.getID().toString()); selected.add(collection.getID().toString());
} }
data.put(ASSOCIATED_ITEMS, selected.toArray()); data.put(ASSOCIATED_ITEMS, selected.toArray());
} }
} }
/** /**
* Process the form. Children should override this method to save * Process the form. Children should override this method to save the user's changes to the
* the user's changes to the database. * database.
* *
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
public void process(FormSectionEvent e) throws FormProcessException { public void process(FormSectionEvent e) throws FormProcessException {
s_log.debug("here in process"); s_log.debug("here in process");
ContentGroupContainer item = ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
(ContentGroupContainer) getItemSelectionModel()
.getSelectedObject(e.getPageState()); .getSelectedObject(e.getPageState());
FormData data = e.getFormData(); FormData data = e.getFormData();
if ( item != null && !getSaveCancelSection().getCancelButton() if (item != null && !getSaveCancelSection().getCancelButton()
.isSelected( e.getPageState() ) ) { .isSelected(e.getPageState())) {
ContentGroup group = getCurrentGroup(item, m_attributeName); ContentGroup group = getCurrentGroup(item, m_attributeName);
if (group == null) { if (group == null) {
group = new ContentGroup(); group = new ContentGroup();
group.setMaster((ContentItem) item); group.setMaster((ContentItem) item);
setContentGroup(item, group, m_attributeName); setContentGroup(item, group, m_attributeName);
} }
group.setName((String)data.get(ContentGroup.NAME)); group.setName((String) data.get(ContentGroup.NAME));
group.save (); group.save();
// iterate through the values so that we only remove items // iterate through the values so that we only remove items
// that have been unchecked. // that have been unchecked.
ItemCollection collection = group.getContentItems(); ItemCollection collection = group.getContentItems();
@ -201,8 +194,7 @@ public class ContentGroupPropertyForm extends BasicItemForm {
s_log.debug("XXXX adding " + id); s_log.debug("XXXX adding " + id);
s_log.debug("XXXX isDeleted? " + collection.getContentItem().isDeleted()); s_log.debug("XXXX isDeleted? " + collection.getContentItem().isDeleted());
} }
String[] values = String[] values = (String[]) m_checkboxGroup.getValue(e.getPageState());
(String[])m_checkboxGroup.getValue(e.getPageState());
if (values != null) { if (values != null) {
for (String value : values) { for (String value : values) {
ids.remove(value); ids.remove(value);
@ -213,11 +205,10 @@ public class ContentGroupPropertyForm extends BasicItemForm {
Iterator iterator = ids.iterator(); Iterator iterator = ids.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
s_log.debug("Removing item"); s_log.debug("Removing item");
group.removeContentItem group.removeContentItem((ContentItem) itemMap.get((String) iterator.next()));
((ContentItem)itemMap.get((String)iterator.next()));
} }
ContentItem newItem = (ContentItem)data.get(RELATED_ITEM); ContentItem newItem = (ContentItem) data.get(RELATED_ITEM);
if (newItem != null) { if (newItem != null) {
group.addContentItem(newItem); group.addContentItem(newItem);
} }
@ -227,31 +218,29 @@ public class ContentGroupPropertyForm extends BasicItemForm {
} }
} }
/** /**
* This returns the correct group for the attribute name * This returns the correct group for the attribute name
*/ */
private ContentGroup getCurrentGroup(ContentGroupContainer item, String attributeName) { private ContentGroup getCurrentGroup(ContentGroupContainer item, String attributeName) {
return item.getContentGroup(attributeName); return item.getContentGroup(attributeName);
} }
/** /**
* This sets the group for the given attribute name * This sets the group for the given attribute name
*/ */
private void setContentGroup(ContentGroupContainer item, ContentGroup group, private void setContentGroup(ContentGroupContainer item, ContentGroup group,
String attributeName) { String attributeName) {
item.setContentGroup(attributeName, group); item.setContentGroup(attributeName, group);
} }
/** /**
* The name of the Content Type to restrict the ItemSearchWidget to. * The name of the Content Type to restrict the ItemSearchWidget to. To allow the user to search
* To allow the user to search for any content type, this should * for any content type, this should return null.
* return null. *
* * @return
* @return
*/ */
protected String getSearchContentType() { protected String getSearchContentType() {
return null; return null;
} }
} }

View File

@ -27,6 +27,8 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
@ -41,8 +43,11 @@ import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -51,10 +56,10 @@ import org.apache.log4j.Logger;
* @author: Jens Pelzetter * @author: Jens Pelzetter
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
public class GenericAddressPropertyForm extends BasicPageForm public class GenericAddressPropertyForm extends BasicPageForm
implements FormProcessListener, implements FormProcessListener,
FormInitListener, FormInitListener,
FormSubmissionListener { FormSubmissionListener {
private static final Logger s_log = Logger.getLogger(GenericAddressPropertyForm.class); private static final Logger s_log = Logger.getLogger(GenericAddressPropertyForm.class);
@ -70,7 +75,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
this(itemModel, null); this(itemModel, null);
} }
public GenericAddressPropertyForm(ItemSelectionModel itemModel, public GenericAddressPropertyForm(ItemSelectionModel itemModel,
GenericAddressPropertiesStep step) { GenericAddressPropertiesStep step) {
super(ID, itemModel); super(ID, itemModel);
m_step = step; m_step = step;
@ -81,67 +86,82 @@ public class GenericAddressPropertyForm extends BasicPageForm
protected void addWidgets() { protected void addWidgets() {
super.addWidgets(); super.addWidgets();
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address")));
ParameterModel addressParam = new StringParameter(ADDRESS); ParameterModel addressParam = new StringParameter(ADDRESS);
addressParam.addParameterListener(new NotNullValidationListener()); addressParam.addParameterListener(new NotNullValidationListener());
addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextArea address = new TextArea(addressParam); TextArea address = new TextArea(addressParam);
address.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address"));
address.setRows(5); address.setRows(5);
address.setCols(30); address.setCols(30);
add(address); add(address);
add(new Label(ContenttypesGlobalizationUtil add(new Label());
.globalize("cms.contenttypes.ui.address.postal_code")));
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE); ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam); TextField postalCode = new TextField(postalCodeParam);
postalCode.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code"));
add(postalCode); add(postalCode);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city")));
ParameterModel cityParam = new StringParameter(CITY); ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam); TextField city = new TextField(cityParam);
city.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city"));
add(city); add(city);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state")));
ParameterModel stateParam = new StringParameter(STATE); ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam); TextField state = new TextField(stateParam);
state.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state"));
add(state); add(state);
if (!GenericAddress.getConfig().getHideCountryCodeSelection()) { if (!GenericAddress.getConfig().getHideCountryCodeSelection()) {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code")));
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE); ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
countryParam.addParameterListener(new StringInRangeValidationListener(0, 2)); countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
SingleSelect country = new SingleSelect(countryParam); SingleSelect country = new SingleSelect(countryParam);
country.addOption(new Option("", country.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("",
new Label(GlobalizationUtil new Label(GlobalizationUtil
.globalize("cms.ui.select_one")))); .globalize("cms.ui.select_one"))));
Iterator countries = GenericAddress.getSortedListOfCountries(null) try {
.entrySet().iterator(); country.addPrintListener(new PrintListener() {
while (countries.hasNext()) {
Map.Entry<String, String> elem = @Override
(Map.Entry<String, String>) countries.next(); public void prepare(final PrintEvent event) {
country.addOption(new Option(elem.getValue().toString(), final SingleSelect target = (SingleSelect) event.getTarget();
elem.getKey().toString()));
final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator();
while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next();
target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
country.addValidationListener(new ParameterListener() { country.addValidationListener(new ParameterListener() {
public void validate(ParameterEvent e) public void validate(ParameterEvent e)
throws FormProcessException { throws FormProcessException {
ParameterData data = e.getParameterData(); ParameterData data = e.getParameterData();
String isoCode = (String) data.getValue(); String isoCode = (String) data.getValue();
s_log.debug("ISO code is : " + isoCode); s_log.debug("ISO code is : " + isoCode);
if (isoCode == null || isoCode.length() == 0) { if (isoCode == null || isoCode.length() == 0) {
data.addError((String) ContenttypesGlobalizationUtil data.addError((String) ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.error_iso_country") .globalize("cms.contenttypes.ui.address.error_iso_country")
.localize()); .localize());
} }
} }
}); });
add(country); add(country);
@ -150,8 +170,8 @@ public class GenericAddressPropertyForm extends BasicPageForm
} }
/** /**
* *
* @param fse * @param fse
*/ */
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
@ -167,8 +187,8 @@ public class GenericAddressPropertyForm extends BasicPageForm
} }
/** /**
* *
* @param fse * @param fse
*/ */
public void submitted(FormSectionEvent fse) { public void submitted(FormSectionEvent fse) {
if (m_step != null if (m_step != null
@ -178,8 +198,8 @@ public class GenericAddressPropertyForm extends BasicPageForm
} }
/** /**
* *
* @param fse * @param fse
*/ */
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
@ -201,4 +221,5 @@ public class GenericAddressPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState()); m_step.maybeForwardToNextStep(fse.getPageState());
} }
} }
} }

View File

@ -31,6 +31,8 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -38,16 +40,15 @@ import org.apache.log4j.Logger;
* @author quasi * @author quasi
*/ */
public class GenericContactAttachPersonPropertyForm extends BasicPageForm public class GenericContactAttachPersonPropertyForm extends BasicPageForm
implements FormProcessListener, FormInitListener, FormSubmissionListener { implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
GenericContactPropertyForm.class); GenericContactPropertyForm.class);
private GenericContactPersonPropertiesStep m_step; private GenericContactPersonPropertiesStep m_step;
private ItemSearchWidget m_itemSearch; private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "contactPerson"; private final String ITEM_SEARCH = "contactPerson";
private final String CONTACTS_KEY = private final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY;
GenericPersonContactCollection.CONTACTS_KEY;
/** /**
* ID of the form * ID of the form
*/ */
@ -63,9 +64,8 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
} }
/** /**
* Constructor taking an ItemSelectionModel and an instance of * Constructor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
* ContactPropertiesStep. *
*
* @param itemModel * @param itemModel
* @param step * @param step
*/ */
@ -85,34 +85,46 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
public void addWidgets() { public void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil.globalize( add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.contact.select_person"))); "cms.contenttypes.ui.contact.select_person")));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType( findByAssociatedObjectType(
"com.arsdigita.cms.contenttypes.GenericPerson")); "com.arsdigita.cms.contenttypes.GenericPerson"));
m_itemSearch.setDisableCreatePane(true); m_itemSearch.setDisableCreatePane(true);
add(this.m_itemSearch); add(this.m_itemSearch);
// GenericContact type field // GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type")));
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY); ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam); SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", contactType.addOption(new Option("",
new Label(GlobalizationUtil new Label(GlobalizationUtil
.globalize("cms.ui.select_one")))); .globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget @Override
GenericContactTypeCollection contacttypes = public void prepare(final PrintEvent event) {
new GenericContactTypeCollection(); final SingleSelect target = (SingleSelect) event.getTarget();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) { final GenericContactTypeCollection contacttypes
RelationAttribute ct = contacttypes.getRelationAttribute(); = new GenericContactTypeCollection();
contactType.addOption(new Option(ct.getKey(), ct.getName())); contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
// Add the Options to the SingleSelect widget
add(contactType); add(contactType);
} }
@ -120,7 +132,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel(). GenericContact contact = (GenericContact) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
setVisible(state, true); setVisible(state, true);
@ -134,13 +146,13 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel(). GenericContact contact = (GenericContact) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
person = (GenericPerson) person.getContentBundle().getInstance(contact. person = (GenericPerson) person.getContentBundle().getInstance(contact.
getLanguage()); getLanguage());
contact.setPerson(person, (String) data.get(CONTACTS_KEY)); contact.setPerson(person, (String) data.get(CONTACTS_KEY));
} }
@ -156,21 +168,21 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() { getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
GenericContact contact = GenericContact contact = (GenericContact) getItemSelectionModel().
(GenericContact) getItemSelectionModel(). getSelectedObject(e.getPageState());
getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget(); Submit target = (Submit) e.getTarget();
if (contact.getPerson() != null) { if (contact.getPerson() != null) {
target.setButtonLabel(ContenttypesGlobalizationUtil. target.setButtonLabel(ContenttypesGlobalizationUtil.
globalize( globalize(
"cms.contenttypes.ui.contact.select_person.change")); "cms.contenttypes.ui.contact.select_person.change"));
} else { } else {
target.setButtonLabel(ContenttypesGlobalizationUtil. target.setButtonLabel(ContenttypesGlobalizationUtil.
globalize( globalize(
"cms.contenttypes.ui.contact.select_person.add")); "cms.contenttypes.ui.contact.select_person.add"));
} }
} }
}); });
} catch (Exception ex) { } catch (Exception ex) {
throw new UncheckedWrapperException("this cannot happen", ex); throw new UncheckedWrapperException("this cannot happen", ex);
@ -181,26 +193,26 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
public void validate(FormSectionEvent e) throws FormProcessException { public void validate(FormSectionEvent e) throws FormProcessException {
//Calling super.validate(e) here causes an exception because the super method checks things which not available //Calling super.validate(e) here causes an exception because the super method checks things which not available
//here. //here.
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final FormData data = e.getFormData(); final FormData data = e.getFormData();
if (data.get(ITEM_SEARCH) == null) { if (data.get(ITEM_SEARCH) == null) {
throw new FormProcessException((String) ContenttypesGlobalizationUtil. throw new FormProcessException((String) ContenttypesGlobalizationUtil.
globalize( globalize(
"cms.contenttypes.ui.contact.select_person.wrong_type"). "cms.contenttypes.ui.contact.select_person.wrong_type").
localize()); localize());
} }
GenericContact contact = (GenericContact) getItemSelectionModel(). GenericContact contact = (GenericContact) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
if (!(person.getContentBundle().hasInstance(contact.getLanguage(), if (!(person.getContentBundle().hasInstance(contact.getLanguage(),
Kernel.getConfig(). Kernel.getConfig().
languageIndependentItems()))) { languageIndependentItems()))) {
data.addError( data.addError(
"cms.contenttypes.ui.contact.select_person.no_suitable_language_variant"); "cms.contenttypes.ui.contact.select_person.no_suitable_language_variant");
} }
} }
@ -209,9 +221,10 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) { if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) {
init(e); init(e);
throw new FormProcessException((String) ContenttypesGlobalizationUtil. throw new FormProcessException((String) ContenttypesGlobalizationUtil.
globalize( globalize(
"cms.contenttypes.ui.contact.select_person.cancelled"). "cms.contenttypes.ui.contact.select_person.cancelled").
localize()); localize());
} }
} }
} }

View File

@ -28,6 +28,8 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
@ -44,20 +46,23 @@ import java.util.Map;
import com.arsdigita.cms.contenttypes.GenericAddress; import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.GenericContact; import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* *
* @author quasi, Created on 8. Juli 2009, 10:27 * @author quasi, Created on 8. Juli 2009, 10:27
*/ */
public class GenericContactEditAddressPropertyForm extends BasicPageForm public class GenericContactEditAddressPropertyForm extends BasicPageForm
implements FormProcessListener, implements FormProcessListener,
FormInitListener, FormInitListener,
FormSubmissionListener { FormSubmissionListener {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
GenericContactPropertyForm.class); GenericContactPropertyForm.class);
public static final String ADDRESS = GenericAddress.ADDRESS; public static final String ADDRESS = GenericAddress.ADDRESS;
public static final String POSTAL_CODE = GenericAddress.POSTAL_CODE; public static final String POSTAL_CODE = GenericAddress.POSTAL_CODE;
@ -67,7 +72,9 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
private GenericContactAddressPropertiesStep m_step; private GenericContactAddressPropertiesStep m_step;
/** ID of the form */ /**
* ID of the form
*/
public static final String ID = "ContactEditAddress"; public static final String ID = "ContactEditAddress";
/** /**
@ -81,11 +88,11 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
/** /**
* Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep. * Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
* *
* @param itemModel * @param itemModel
* @param step * @param step
*/ */
public GenericContactEditAddressPropertyForm(ItemSelectionModel itemModel, public GenericContactEditAddressPropertyForm(ItemSelectionModel itemModel,
GenericContactAddressPropertiesStep step) { GenericContactAddressPropertiesStep step) {
super(ID, itemModel); super(ID, itemModel);
m_step = step; m_step = step;
@ -94,77 +101,89 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
@Override @Override
public void addWidgets() { public void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address")));
ParameterModel addressParam = new StringParameter(ADDRESS); ParameterModel addressParam = new StringParameter(ADDRESS);
addressParam.addParameterListener(new NotNullValidationListener()); addressParam.addParameterListener(new NotNullValidationListener());
addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextArea address = new TextArea(addressParam); TextArea address = new TextArea(addressParam);
address.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address"));
address.setRows(5); address.setRows(5);
address.setCols(30); address.setCols(30);
add(address); add(address);
if (!GenericContact.getConfig().getHideAddressPostalCode()) { if (!GenericContact.getConfig().getHideAddressPostalCode()) {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code")));
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE); ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam); TextField postalCode = new TextField(postalCodeParam);
postalCode.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code"));
/* XXX NumberListener ?*/ /* XXX NumberListener ?*/
add(postalCode); add(postalCode);
} }
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city")));
ParameterModel cityParam = new StringParameter(CITY); ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam); TextField city = new TextField(cityParam);
city.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city"));
add(city); add(city);
if (!GenericContact.getConfig().getHideAddressState()) { if (!GenericContact.getConfig().getHideAddressState()) {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state")));
ParameterModel stateParam = new StringParameter(STATE); ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam); TextField state = new TextField(stateParam);
state.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state"));
add(state); add(state);
} }
if (!GenericContact.getConfig().getHideAddressCountry()) { if (!GenericContact.getConfig().getHideAddressCountry()) {
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code")));
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE); ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
countryParam.addParameterListener(new countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
StringInRangeValidationListener(0, 2));
SingleSelect country = new SingleSelect(countryParam); SingleSelect country = new SingleSelect(countryParam);
country.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new country.addOption(new Option("",
Option("", new Label(ContenttypesGlobalizationUtil
new Label(ContenttypesGlobalizationUtil .globalize("cms.ui.select_one"))));
.globalize("cms.ui.select_one"))));
Iterator countries = GenericAddress.getSortedListOfCountries(null) try {
.entrySet().iterator(); country.addPrintListener(new PrintListener() {
while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) @Override
countries.next(); public void prepare(final PrintEvent event) {
country.addOption(new Option(elem.getValue().toString(), final SingleSelect target = (SingleSelect) event.getTarget();
elem.getKey().toString()));
final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator();
while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next();
target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
country.addValidationListener( country.addValidationListener(
new ParameterListener() { new ParameterListener() {
@Override @Override
public void validate(ParameterEvent e) throws FormProcessException { public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData(); ParameterData data = e.getParameterData();
String isoCode = (String) data.getValue(); String isoCode = (String) data.getValue();
if (isoCode == null || isoCode.length() == 0) { if (isoCode == null || isoCode.length() == 0) {
data.addError((String) ContenttypesGlobalizationUtil data.addError((String) ContenttypesGlobalizationUtil
.globalize( .globalize(
"cms.contenttypes.ui.address.error_iso_country") "cms.contenttypes.ui.address.error_iso_country")
.localize()); .localize());
}
} }
}
}); });
add(country); add(country);
} }
@ -216,4 +235,5 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState()); m_step.maybeForwardToNextStep(fse.getPageState());
} }
} }
} }

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.cms.contenttypes.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
@ -26,6 +25,8 @@ 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.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
@ -44,6 +45,9 @@ import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -51,14 +55,14 @@ import org.apache.log4j.Logger;
* *
* @author quasi * @author quasi
*/ */
public class GenericContactEditPersonPropertyForm extends BasicPageForm public class GenericContactEditPersonPropertyForm extends BasicPageForm
implements FormProcessListener, implements FormProcessListener,
FormInitListener, FormInitListener,
FormSubmissionListener { FormSubmissionListener {
private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class); private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class);
private GenericContactPersonPropertiesStep m_step; private GenericContactPersonPropertiesStep m_step;
public static final String SURNAME = GenericPerson.SURNAME; public static final String SURNAME = GenericPerson.SURNAME;
public static final String GIVENNAME = GenericPerson.GIVENNAME; public static final String GIVENNAME = GenericPerson.GIVENNAME;
public static final String TITLEPRE = GenericPerson.TITLEPRE; public static final String TITLEPRE = GenericPerson.TITLEPRE;
@ -80,13 +84,12 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
} }
/** /**
* Constructor taking an ItemSelectionModel and an instance of * Constructor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
* ContactPropertiesStep. *
*
* @param itemModel * @param itemModel
* @param step * @param step
*/ */
public GenericContactEditPersonPropertyForm(ItemSelectionModel itemModel, public GenericContactEditPersonPropertyForm(ItemSelectionModel itemModel,
GenericContactPersonPropertiesStep step) { GenericContactPersonPropertiesStep step) {
super(ID, itemModel); super(ID, itemModel);
m_step = step; m_step = step;
@ -94,60 +97,72 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
} }
/** /**
* *
*/ */
@Override @Override
public void addWidgets() { public void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.surname")));
ParameterModel surnameParam = new StringParameter(SURNAME); ParameterModel surnameParam = new StringParameter(SURNAME);
surnameParam.addParameterListener(new NotNullValidationListener()); surnameParam.addParameterListener(new NotNullValidationListener());
surnameParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); surnameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField surname = new TextField(surnameParam); TextField surname = new TextField(surnameParam);
surname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.surname"));
add(surname); add(surname);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.givenname")));
ParameterModel givennameParam = new StringParameter(GIVENNAME); ParameterModel givennameParam = new StringParameter(GIVENNAME);
givennameParam.addParameterListener(new NotNullValidationListener()); givennameParam.addParameterListener(new NotNullValidationListener());
givennameParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); givennameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField givenname = new TextField(givennameParam); TextField givenname = new TextField(givennameParam);
givenname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.givenname"));
add(givenname); add(givenname);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepre")));
ParameterModel titlepreParam = new StringParameter(TITLEPRE); ParameterModel titlepreParam = new StringParameter(TITLEPRE);
titlepreParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); titlepreParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField titlepre = new TextField(titlepreParam); TextField titlepre = new TextField(titlepreParam);
titlepre.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepre"));
add(titlepre); add(titlepre);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepost")));
ParameterModel titlepostParam = new StringParameter(TITLEPOST); ParameterModel titlepostParam = new StringParameter(TITLEPOST);
titlepostParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); titlepostParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField titlepost = new TextField(titlepostParam); TextField titlepost = new TextField(titlepostParam);
titlepost.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepost"));
add(titlepost); add(titlepost);
// GenericContact type field // GenericContact type field
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.contact.type")));
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY); ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam); SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new contactType.addOption(new Option("",
Option("", new Label(GlobalizationUtil
new Label(GlobalizationUtil .globalize("cms.ui.select_one"))));
.globalize("cms.ui.select_one")))); try {
contactType.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget @Override
GenericContactTypeCollection contacttypes = new GenericContactTypeCollection(); public void prepare(final PrintEvent event) {
contacttypes.addLanguageFilter(GlobalizationHelper final SingleSelect target = (SingleSelect) event.getTarget();
.getNegotiatedLocale().getLanguage());
while (contacttypes.next()) { final GenericContactTypeCollection contacttypes
RelationAttribute ct = contacttypes.getRelationAttribute(); = new GenericContactTypeCollection();
contactType.addOption(new Option(ct.getKey(), ct.getName())); contacttypes.addLanguageFilter(GlobalizationHelper
.getNegotiatedLocale().getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
// Add the Options to the SingleSelect widget
add(contactType); add(contactType);
} }
@ -156,7 +171,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel() GenericContact contact = (GenericContact) getItemSelectionModel()
.getSelectedObject(state); .getSelectedObject(state);
if (contact.getPerson() != null) { if (contact.getPerson() != null) {
data.put(SURNAME, contact.getPerson().getSurname()); data.put(SURNAME, contact.getPerson().getSurname());
@ -178,7 +193,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel() GenericContact contact = (GenericContact) getItemSelectionModel()
.getSelectedObject(state); .getSelectedObject(state);
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
@ -187,7 +202,6 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
// contact.getPerson().setName("Person for " + contact.getName() + "(" + contact.getID() + ")"); // contact.getPerson().setName("Person for " + contact.getName() + "(" + contact.getID() + ")");
// contact.getPerson().setTitle("Person for " + contact.getName() + "(" + contact.getID() + ")"); // contact.getPerson().setTitle("Person for " + contact.getName() + "(" + contact.getID() + ")");
// } // }
contact.getPerson().setSurname((String) data.get(SURNAME)); contact.getPerson().setSurname((String) data.get(SURNAME));
contact.getPerson().setGivenName((String) data.get(GIVENNAME)); contact.getPerson().setGivenName((String) data.get(GIVENNAME));
contact.getPerson().setTitlePre((String) data.get(TITLEPRE)); contact.getPerson().setTitlePre((String) data.get(TITLEPRE));
@ -201,4 +215,5 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState()); m_step.maybeForwardToNextStep(fse.getPageState());
} }
} }
} }

View File

@ -21,6 +21,8 @@ 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.Label;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
@ -36,6 +38,9 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicItemForm; import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -43,91 +48,104 @@ import org.apache.log4j.Logger;
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
public class GenericContactEntryAddForm extends BasicItemForm { public class GenericContactEntryAddForm extends BasicItemForm {
private static final Logger s_log = Logger.getLogger(GenericContactEntryAddForm.class); private static final Logger s_log = Logger.getLogger(GenericContactEntryAddForm.class);
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
/** Creates a new instance of CategoryLocalizationAddForm */ /**
* Creates a new instance of CategoryLocalizationAddForm
*/
public GenericContactEntryAddForm(ItemSelectionModel itemModel) { public GenericContactEntryAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm",itemModel); super("ContactEntryAddForm", itemModel);
m_itemModel = itemModel; m_itemModel = itemModel;
} }
@Override @Override
protected void addWidgets() { protected void addWidgets() {
// Key field // Key field
add(new Label(ContenttypesGlobalizationUtil.globalize( ParameterModel contactEntryKeyParam = new StringParameter(GenericContactEntry.KEY);
"cms.contenttypes.ui.genericcontact.contactEntry.key")));
ParameterModel contactEntryKeyParam = new
StringParameter(GenericContactEntry.KEY);
SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam); SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam);
contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.key"));
contactEntryKey.addValidationListener(new NotNullValidationListener()); contactEntryKey.addValidationListener(new NotNullValidationListener());
contactEntryKey.addOption(new contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
Option("", new Label(GlobalizationUtil.globalize( "cms.ui.select_one"))));
"cms.ui.select_one")) )); try {
contactEntryKey.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget
GenericContactEntryKeys keyList = new GenericContactEntryKeys(); @Override
keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale() public void prepare(final PrintEvent event) {
.getLanguage()); final SingleSelect target = (SingleSelect) event.getTarget();
while(keyList.next()) {
String currentKey = keyList.getKey(); final GenericContactEntryKeys keyList = new GenericContactEntryKeys();
contactEntryKey.addOption(new Option(currentKey, keyList.getName())); keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
.getLanguage());
while (keyList.next()) {
String currentKey = keyList.getKey();
target.addOption(new Option(currentKey, keyList.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
// Add the Options to the SingleSelect widget
add(contactEntryKey); add(contactEntryKey);
// Value field // Value field
add(new Label(ContenttypesGlobalizationUtil.globalize( ParameterModel contactEntryValueParam = new StringParameter(GenericContactEntry.VALUE);
"cms.contenttypes.ui.genericcontact.contactEntry.value")));
ParameterModel contactEntryValueParam = new
StringParameter(GenericContactEntry.VALUE);
TextField contactEntryValue = new TextField(contactEntryValueParam); TextField contactEntryValue = new TextField(contactEntryValueParam);
contactEntryValue.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.value"));
contactEntryValue.addValidationListener(new NotNullValidationListener()); contactEntryValue.addValidationListener(new NotNullValidationListener());
add(contactEntryValue); add(contactEntryValue);
// Description field, only for internal usage // Description field, only for internal usage
add(new Label(ContenttypesGlobalizationUtil.globalize( ParameterModel contactEntryDescriptionParam = new StringParameter(
"cms.contenttypes.ui.genericcontact.contactEntry.description"))); GenericContactEntry.DESCRIPTION);
ParameterModel contactEntryDescriptionParam = new
StringParameter(GenericContactEntry.DESCRIPTION);
TextField contactEntryDescription = new TextField(contactEntryDescriptionParam); TextField contactEntryDescription = new TextField(contactEntryDescriptionParam);
contactEntryDescription.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.description"));
add(contactEntryDescription); add(contactEntryDescription);
} }
/** /**
* Does nothing here. * Does nothing here.
* @param fse *
* @param fse
*/ */
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
} }
/** /**
* *
* @param fse * @param fse
*/ */
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
GenericContact contact = (GenericContact) GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(fse.getPageState());
m_itemModel.getSelectedObject(fse.getPageState());
// save only if save button was pressed // save only if save button was pressed
if (contact != null if (contact != null
&& getSaveCancelSection().getSaveButton() && getSaveCancelSection().getSaveButton()
.isSelected(fse.getPageState())) { .isSelected(fse.getPageState())) {
GenericContactEntry contactEntry = new GenericContactEntry( GenericContactEntry contactEntry = new GenericContactEntry(
contact, contact,
(String)data.get(GenericContactEntry.KEY), (String) data.get(GenericContactEntry.KEY),
(String)data.get(GenericContactEntry.VALUE), (String) data.get(GenericContactEntry.VALUE),
(String)data.get(GenericContactEntry.DESCRIPTION)); (String) data.get(GenericContactEntry.DESCRIPTION));
contact.addContactEntry(contactEntry); contact.addContactEntry(contactEntry);
} }
} }
} }

View File

@ -84,16 +84,6 @@ public class GenericContactPropertyForm extends BasicPageForm
@Override @Override
public void addWidgets() { public void addWidgets() {
super.addWidgets(); super.addWidgets();
/*
add(new Label(BaseContactGlobalizationUtil.globalize(
"cms.contenttypes.ui.contact.basic_properties.description")
)));
TextArea description = new TextArea(DESCRIPTION);
description.setRows(5);
description.setCols(30);
add(description);
*/
} }
@Override @Override

View File

@ -74,29 +74,29 @@ public class GenericContactTypeAddForm extends BasicItemForm {
@Override @Override
protected void addWidgets() { protected void addWidgets() {
// Key // Key
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.key")));
ParameterModel keyParam = new StringParameter(KEY); ParameterModel keyParam = new StringParameter(KEY);
keyParam.addParameterListener(new NotNullValidationListener()); keyParam.addParameterListener(new NotNullValidationListener());
keyParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); keyParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField key = new TextField(keyParam); TextField key = new TextField(keyParam);
key.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.key"));
add(key); add(key);
// Language // Language
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language")));
ParameterModel languageParam = new StringParameter(LANGUAGE); ParameterModel languageParam = new StringParameter(LANGUAGE);
language = new SingleSelect(languageParam); language = new SingleSelect(languageParam);
language.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language"));
language.addValidationListener(new NotNullValidationListener()); language.addValidationListener(new NotNullValidationListener());
language.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize()))); language.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
// Name // Name
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.name")));
ParameterModel nameParam = new StringParameter(NAME); ParameterModel nameParam = new StringParameter(NAME);
nameParam.addParameterListener(new NotNullValidationListener()); nameParam.addParameterListener(new NotNullValidationListener());
nameParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); nameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField name = new TextField(nameParam); TextField name = new TextField(nameParam);
name.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.name"));
add(name); add(name);

View File

@ -25,6 +25,8 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.SaveCancelSection;
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.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -43,6 +45,9 @@ import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm; import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -51,11 +56,11 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class GenericOrganizationalUnitContactAddForm public class GenericOrganizationalUnitContactAddForm
extends BasicItemForm extends BasicItemForm
implements FormSubmissionListener { implements FormSubmissionListener {
private final static Logger s_log = Logger.getLogger( private final static Logger s_log = Logger.getLogger(
GenericOrganizationalUnitContactAddForm.class); GenericOrganizationalUnitContactAddForm.class);
private GenericOrganizationalUnitPropertiesStep m_step; private GenericOrganizationalUnitPropertiesStep m_step;
private ItemSearchWidget m_itemSearch; private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
@ -75,35 +80,47 @@ public class GenericOrganizationalUnitContactAddForm
@Override @Override
protected void addWidgets() { protected void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil.globalize( add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact"))); "cms.contenttypes.ui.genericorgaunit.select_contact")));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(GenericContact.class.getName())); findByAssociatedObjectType(GenericContact.class
.getName()));
m_itemSearch.setDisableCreatePane(false); m_itemSearch.setDisableCreatePane(false);
add(m_itemSearch); add(m_itemSearch);
selectedContactLabel = new Label(""); selectedContactLabel = new Label("");
add(selectedContactLabel); add(selectedContactLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.contact.type")));
ParameterModel contactTypeParam = new StringParameter( ParameterModel contactTypeParam = new StringParameter(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE); GenericOrganizationalUnitContactCollection.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam); SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", contactType.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil. new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one")))); globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
GenericOrganizationContactTypeCollection contacttypes = @Override
new GenericOrganizationContactTypeCollection(); public void prepare(final PrintEvent event) {
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). final SingleSelect target = (SingleSelect) event.getTarget();
getLanguage());
while (contacttypes.next()) { final GenericOrganizationContactTypeCollection contacttypes
RelationAttribute ct = contacttypes.getRelationAttribute(); = new GenericOrganizationContactTypeCollection();
contactType.addOption(new Option(ct.getKey(), ct.getName())); contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
add(contactType); add(contactType);
} }
@ -134,9 +151,8 @@ public class GenericOrganizationalUnitContactAddForm
public void process(FormSectionEvent fse) throws FormProcessException { public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericOrganizationalUnit orgaunit = GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel().
(GenericOrganizationalUnit) getItemSelectionModel(). getSelectedObject(state);
getSelectedObject(state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
GenericContact selectedContact; GenericContact selectedContact;
@ -146,17 +162,17 @@ public class GenericOrganizationalUnitContactAddForm
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
if (orgaunit.getLanguage().equals( if (orgaunit.getLanguage().equals(
GlobalizationHelper.LANG_INDEPENDENT)) { GlobalizationHelper.LANG_INDEPENDENT)) {
contact = (GenericContact) contact.getContentBundle(). contact = (GenericContact) contact.getContentBundle().
getPrimaryInstance(); getPrimaryInstance();
} else { } else {
contact = (GenericContact) contact.getContentBundle(). contact = (GenericContact) contact.getContentBundle().
getInstance(orgaunit.getLanguage()); getInstance(orgaunit.getLanguage());
} }
orgaunit.addContact(contact, orgaunit.addContact(contact,
(String) data.get( (String) data.get(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE)); GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
} else { } else {
GenericOrganizationalUnitContactCollection contacts; GenericOrganizationalUnitContactCollection contacts;
@ -169,7 +185,7 @@ public class GenericOrganizationalUnitContactAddForm
} }
contacts.setContactType((String) data.get( contacts.setContactType((String) data.get(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE)); GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
editStep.setSelectedContact(null); editStep.setSelectedContact(null);
editStep.setSelectedContactType(null); editStep.setSelectedContactType(null);
@ -182,7 +198,7 @@ public class GenericOrganizationalUnitContactAddForm
public void submitted(FormSectionEvent fse) throws FormProcessException { public void submitted(FormSectionEvent fse) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected( if (getSaveCancelSection().getCancelButton().isSelected(
fse.getPageState())) { fse.getPageState())) {
editStep.setSelectedContact(null); editStep.setSelectedContact(null);
editStep.setSelectedContactType(null); editStep.setSelectedContactType(null);
@ -196,17 +212,16 @@ public class GenericOrganizationalUnitContactAddForm
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
if ((editStep.getSelectedContact() == null) if ((editStep.getSelectedContact() == null)
&& (data.get(ITEM_SEARCH) == null)) { && (data.get(ITEM_SEARCH) == null)) {
data.addError( data.addError(
"cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected"); "cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected");
return; return;
} }
if (editStep.getSelectedContact() == null) { if (editStep.getSelectedContact() == null) {
GenericOrganizationalUnit orgaunit = GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel()
(GenericOrganizationalUnit) getItemSelectionModel(). .getSelectedObject(state);
getSelectedObject(state);
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
@ -215,36 +230,36 @@ public class GenericOrganizationalUnitContactAddForm
if (!(contact.getContentBundle().hasInstance(orgaunit. if (!(contact.getContentBundle().hasInstance(orgaunit.
getLanguage(), getLanguage(),
Kernel.getConfig(). Kernel.getConfig().
languageIndependentItems()))) { languageIndependentItems()))) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant")); "cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant"));
return; return;
} }
} }
if (orgaunit.getLanguage().equals( if (orgaunit.getLanguage().equals(
GlobalizationHelper.LANG_INDEPENDENT)) { GlobalizationHelper.LANG_INDEPENDENT)) {
contact = (GenericContact) contact.getContentBundle(). contact = (GenericContact) contact.getContentBundle().
getPrimaryInstance(); getPrimaryInstance();
} else { } else {
contact = (GenericContact) contact.getContentBundle(). contact = (GenericContact) contact.getContentBundle().
getInstance(orgaunit.getLanguage()); getInstance(orgaunit.getLanguage());
} }
GenericOrganizationalUnitContactCollection contacts = orgaunit. GenericOrganizationalUnitContactCollection contacts = orgaunit.
getContacts(); getContacts();
contacts.addFilter(String.format("id = %s", contacts.addFilter(String.format("id = %s",
contact.getID().toString())); contact.getID().toString()));
if (contacts.size() > 0) { if (contacts.size() > 0) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.already_added")); "cms.contenttypes.ui.genericorgaunit.select_contact.already_added"));
} }
contacts.close(); contacts.close();
} }
} }
} }

View File

@ -38,41 +38,41 @@ import java.util.Date;
* @version $Id$ * @version $Id$
*/ */
public class GenericOrganizationalUnitCreate extends PageCreate { public class GenericOrganizationalUnitCreate extends PageCreate {
public GenericOrganizationalUnitCreate(final ItemSelectionModel itemModel, public GenericOrganizationalUnitCreate(final ItemSelectionModel itemModel,
final CreationSelector parent) { final CreationSelector parent) {
super(itemModel, parent); super(itemModel, parent);
} }
@Override @Override
public void process(final FormSectionEvent fse) throws FormProcessException { public void process(final FormSectionEvent fse) throws FormProcessException {
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
final ContentSection section = m_parent.getContentSection(state); final ContentSection section = m_parent.getContentSection(state);
final Folder folder = m_parent.getFolder(state); final Folder folder = m_parent.getFolder(state);
final ContentPage item = createContentPage(state); final ContentPage item = createContentPage(state);
item.setLanguage((String) data.get(LANGUAGE)); item.setLanguage((String) data.get(LANGUAGE));
item.setName((String) data.get(NAME)); item.setName((String) data.get(NAME));
item.setTitle((String) data.get(TITLE)); item.setTitle((String) data.get(TITLE));
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
item.setLaunchDate((Date) data.get(LAUNCH_DATE)); item.setLaunchDate((Date) data.get(LAUNCH_DATE));
} }
final GenericOrganizationalUnitBundle bundle = createBundle(item); final GenericOrganizationalUnitBundle bundle = createBundle(item);
//new GenericOrganizationalUnitBundle(item); //new GenericOrganizationalUnitBundle(item);
bundle.setParent(folder); bundle.setParent(folder);
bundle.setContentSection(section); bundle.setContentSection(section);
bundle.save(); bundle.save();
m_workflowSection.applyWorkflow(state, item); m_workflowSection.applyWorkflow(state, item);
m_parent.editItem(state, item); m_parent.editItem(state, item);
} }
protected GenericOrganizationalUnitBundle createBundle( protected GenericOrganizationalUnitBundle createBundle(
final ContentItem primary) { final ContentItem primary) {
return new GenericOrganizationalUnitBundle(primary); return new GenericOrganizationalUnitBundle(primary);
} }
} }

View File

@ -26,6 +26,8 @@ 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.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -43,6 +45,8 @@ import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm; import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -52,13 +56,13 @@ import org.apache.log4j.Logger;
* @version $Id$ * @version $Id$
*/ */
public class GenericOrganizationalUnitPersonAddForm public class GenericOrganizationalUnitPersonAddForm
extends BasicItemForm extends BasicItemForm
implements FormProcessListener, implements FormProcessListener,
FormInitListener, FormInitListener,
FormSubmissionListener { FormSubmissionListener {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
GenericOrganizationalUnitPersonAddForm.class); GenericOrganizationalUnitPersonAddForm.class);
private GenericOrganizationalUnitPersonPropertiesStep m_step; private GenericOrganizationalUnitPersonPropertiesStep m_step;
private ItemSearchWidget m_itemSearch; private ItemSearchWidget m_itemSearch;
private final String ITEM_SEARCH = "orgaunitPerson"; private final String ITEM_SEARCH = "orgaunitPerson";
@ -75,58 +79,80 @@ public class GenericOrganizationalUnitPersonAddForm
@Override @Override
protected void addWidgets() { protected void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil.globalize( add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_person"))); "cms.contenttypes.ui.genericorgaunit.select_person")));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(getPersonType())); findByAssociatedObjectType(getPersonType()));
/*m_itemSearch.getItemField().addValidationListener( /*m_itemSearch.getItemField().addValidationListener(
new NotNullValidationListener());*/ new NotNullValidationListener());*/
m_itemSearch.setDisableCreatePane(false); m_itemSearch.setDisableCreatePane(false);
add(this.m_itemSearch); add(this.m_itemSearch);
selectedPersonNameLabel = new Label(""); selectedPersonNameLabel = new Label("");
add(selectedPersonNameLabel); add(selectedPersonNameLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize( ParameterModel roleParam = new StringParameter(
"cms.contenttypes.ui.genericorgaunit.person.role"))); GenericOrganizationalUnitPersonCollection.PERSON_ROLE);
ParameterModel roleParam =
new StringParameter(
GenericOrganizationalUnitPersonCollection.PERSON_ROLE);
SingleSelect roleSelect = new SingleSelect(roleParam); SingleSelect roleSelect = new SingleSelect(roleParam);
roleSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role"));
roleSelect.addValidationListener(new NotNullValidationListener()); roleSelect.addValidationListener(new NotNullValidationListener());
roleSelect.addOption( roleSelect.addOption(
new Option("", new Option("",
new Label(ContenttypesGlobalizationUtil new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one")))); .globalize("cms.ui.select_one"))));
RelationAttributeCollection roles = new RelationAttributeCollection( try {
getRoleAttributeName()); roleSelect.addPrintListener(new PrintListener() {
roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); @Override
while (roles.next()) { public void prepare(final PrintEvent event) {
RelationAttribute role; final SingleSelect target = (SingleSelect) event.getTarget();
role = roles.getRelationAttribute();
roleSelect.addOption(new Option(role.getKey(), role.getName())); final RelationAttributeCollection roles = new RelationAttributeCollection(
getRoleAttributeName());
roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (roles.next()) {
RelationAttribute role;
role = roles.getRelationAttribute();
target.addOption(new Option(role.getKey(), role.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong...", ex);
} }
add(roleSelect); add(roleSelect);
add(new Label(ContenttypesGlobalizationUtil.globalize( final ParameterModel statusModel = new StringParameter(
"cms.contenttypes.ui.genericorgaunit.person.status"))); GenericOrganizationalUnitPersonCollection.STATUS);
ParameterModel statusModel = final SingleSelect statusSelect = new SingleSelect(statusModel);
new StringParameter( statusSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
GenericOrganizationalUnitPersonCollection.STATUS); "cms.contenttypes.ui.genericorgaunit.person.status"));
SingleSelect statusSelect = new SingleSelect(statusModel);
statusSelect.addValidationListener(new NotNullValidationListener()); statusSelect.addValidationListener(new NotNullValidationListener());
statusSelect.addOption(new Option("", statusSelect.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil. new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one")))); globalize("cms.ui.select_one"))));
RelationAttributeCollection statusColl = try {
new RelationAttributeCollection( statusSelect.addPrintListener(new PrintListener() {
getStatusAttributeName());
statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). @Override
getLanguage()); public void prepare(final PrintEvent event) {
while (statusColl.next()) { final SingleSelect target = (SingleSelect) event.getTarget();
RelationAttribute status; RelationAttributeCollection statusColl = new RelationAttributeCollection(
status = statusColl.getRelationAttribute(); getStatusAttributeName());
statusSelect.addOption(new Option(status.getKey(), status.getName())); statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (statusColl.next()) {
RelationAttribute status;
status = statusColl.getRelationAttribute();
target.addOption(new Option(status.getKey(), status.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Somethin has gone terribly wrong", ex);
} }
add(statusSelect); add(statusSelect);
@ -167,9 +193,8 @@ public class GenericOrganizationalUnitPersonAddForm
public void process(FormSectionEvent fse) throws FormProcessException { public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericOrganizationalUnit orga = GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel().
(GenericOrganizationalUnit) getItemSelectionModel(). getSelectedObject(state);
getSelectedObject(state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
@ -177,16 +202,15 @@ public class GenericOrganizationalUnitPersonAddForm
person = selector.getSelectedPerson(); person = selector.getSelectedPerson();
if (person == null) { if (person == null) {
GenericPerson personToAdd = GenericPerson personToAdd = (GenericPerson) data.get(ITEM_SEARCH);
(GenericPerson) data.get(ITEM_SEARCH);
logger.debug(String.format("Adding person %s", logger.debug(String.format("Adding person %s",
personToAdd.getFullName())); personToAdd.getFullName()));
orga.addPerson(personToAdd, orga.addPerson(personToAdd,
(String) data.get( (String) data.get(
GenericOrganizationalUnitPersonCollection.PERSON_ROLE), GenericOrganizationalUnitPersonCollection.PERSON_ROLE),
(String) data.get( (String) data.get(
GenericOrganizationalUnitPersonCollection.STATUS)); GenericOrganizationalUnitPersonCollection.STATUS));
m_itemSearch.publishCreatedItem(data, personToAdd); m_itemSearch.publishCreatedItem(data, personToAdd);
} else { } else {
GenericOrganizationalUnitPersonCollection persons; GenericOrganizationalUnitPersonCollection persons;
@ -200,9 +224,9 @@ public class GenericOrganizationalUnitPersonAddForm
} }
persons.setRoleName((String) data.get( persons.setRoleName((String) data.get(
GenericOrganizationalUnitPersonCollection.PERSON_ROLE)); GenericOrganizationalUnitPersonCollection.PERSON_ROLE));
persons.setStatus((String) data.get( persons.setStatus((String) data.get(
GenericOrganizationalUnitPersonCollection.STATUS)); GenericOrganizationalUnitPersonCollection.STATUS));
selector.setSelectedPerson(null); selector.setSelectedPerson(null);
selector.setSelectedPersonRole(null); selector.setSelectedPersonRole(null);
@ -217,7 +241,7 @@ public class GenericOrganizationalUnitPersonAddForm
public void submitted(FormSectionEvent fse) throws FormProcessException { public void submitted(FormSectionEvent fse) throws FormProcessException {
if (this.getSaveCancelSection().getCancelButton().isSelected( if (this.getSaveCancelSection().getCancelButton().isSelected(
fse.getPageState())) { fse.getPageState())) {
selector.setSelectedPerson(null); selector.setSelectedPerson(null);
selector.setSelectedPersonRole(null); selector.setSelectedPersonRole(null);
selector.setSelectedPersonStatus(null); selector.setSelectedPersonStatus(null);
@ -232,46 +256,43 @@ public class GenericOrganizationalUnitPersonAddForm
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
if ((selector.getSelectedPerson() == null) if ((selector.getSelectedPerson() == null)
&& (data.get(ITEM_SEARCH) == null)) { && (data.get(ITEM_SEARCH) == null)) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.no_person_selected")); "cms.contenttypes.ui.genericorgaunit.person.no_person_selected"));
return; return;
} }
if (selector.getSelectedPerson() == null) { if (selector.getSelectedPerson() == null) {
GenericOrganizationalUnit orga = GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel().
(GenericOrganizationalUnit) getItemSelectionModel(). getSelectedObject(state);
getSelectedObject(state);
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
/*if (!(person.getContentBundle().hasInstance(orga.getLanguage(), /*if (!(person.getContentBundle().hasInstance(orga.getLanguage(),
Kernel.getConfig(). Kernel.getConfig().
languageIndependentItems()))) { languageIndependentItems()))) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant")); "cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant"));
return;
}*/
return;
}*/
final ContentBundle bundle = person.getContentBundle(); final ContentBundle bundle = person.getContentBundle();
final GenericOrganizationalUnitPersonCollection persons = final GenericOrganizationalUnitPersonCollection persons = orga.getPersons();
orga.getPersons();
persons.addFilter(String.format("id = %s",
bundle.getID().toString()));
/*person = (GenericPerson) person.getContentBundle().getInstance(orga.
getLanguage());
GenericOrganizationalUnitPersonCollection persons =
orga.getPersons();
persons.addFilter(String.format("id = %s", persons.addFilter(String.format("id = %s",
person.getID().toString()));*/ bundle.getID().toString()));
/*person = (GenericPerson) person.getContentBundle().getInstance(orga.
getLanguage());
GenericOrganizationalUnitPersonCollection persons =
orga.getPersons();
persons.addFilter(String.format("id = %s",
person.getID().toString()));*/
if (persons.size() > 0) { if (persons.size() > 0) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.already_added")); "cms.contenttypes.ui.genericorgaunit.person.already_added"));
} }
@ -290,4 +311,5 @@ public class GenericOrganizationalUnitPersonAddForm
protected String getStatusAttributeName() { protected String getStatusAttributeName() {
return "GenericOrganizationalUnitMemberStatus"; return "GenericOrganizationalUnitMemberStatus";
} }
} }

View File

@ -40,13 +40,13 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class GenericOrganizationalUnitPropertyForm public class GenericOrganizationalUnitPropertyForm
extends BasicPageForm extends BasicPageForm
implements FormProcessListener, implements FormProcessListener,
FormInitListener, FormInitListener,
FormSubmissionListener { FormSubmissionListener {
private final static Logger s_log = Logger.getLogger( private final static Logger s_log = Logger.getLogger(
GenericOrganizationalUnitPropertyForm.class); GenericOrganizationalUnitPropertyForm.class);
private GenericOrganizationalUnitPropertiesStep m_step; private GenericOrganizationalUnitPropertiesStep m_step;
//public static final String NAME = GenericOrganizationalUnit.NAME; //public static final String NAME = GenericOrganizationalUnit.NAME;
//public static final String ORGAUNIT_NAME = GenericOrganizationalUnit.ORGAUNIT_NAME; //public static final String ORGAUNIT_NAME = GenericOrganizationalUnit.ORGAUNIT_NAME;
@ -68,18 +68,10 @@ public class GenericOrganizationalUnitPropertyForm
protected void addWidgets() { protected void addWidgets() {
super.addWidgets(); super.addWidgets();
/*add(new Label(
(String) ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorganunit.name").localize()));
ParameterModel nameParam = new StringParameter(NAME);
TextField name = new TextField(nameParam);
add(name);*/
add(new Label(
ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.addendum")));
ParameterModel addendumParam = new StringParameter(ADDENDUM); ParameterModel addendumParam = new StringParameter(ADDENDUM);
TextField addendum = new TextField(addendumParam); TextField addendum = new TextField(addendumParam);
addendum.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.addendum"));
add(addendum); add(addendum);
} }
@ -87,7 +79,7 @@ public class GenericOrganizationalUnitPropertyForm
@Override @Override
public void submitted(FormSectionEvent fse) throws FormProcessException { public void submitted(FormSectionEvent fse) throws FormProcessException {
if ((m_step != null) if ((m_step != null)
&& getSaveCancelSection().getCancelButton().isSelected(fse. && getSaveCancelSection().getCancelButton().isSelected(fse.
getPageState())) { getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState()); m_step.cancelStreamlinedCreation(fse.getPageState());
} }
@ -96,9 +88,8 @@ public class GenericOrganizationalUnitPropertyForm
@Override @Override
public void init(FormSectionEvent fse) throws FormProcessException { public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
GenericOrganizationalUnit orgaunit = GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) super.
(GenericOrganizationalUnit) super. initBasicWidgets(fse);
initBasicWidgets(fse);
//data.put(NAME, orgaunit.getName()); //data.put(NAME, orgaunit.getName());
data.put(ADDENDUM, orgaunit.getAddendum()); data.put(ADDENDUM, orgaunit.getAddendum());
@ -108,17 +99,17 @@ public class GenericOrganizationalUnitPropertyForm
public void process(FormSectionEvent fse) throws FormProcessException { public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
GenericOrganizationalUnit orgaunit = GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) super.
(GenericOrganizationalUnit) super. processBasicWidgets(fse);
processBasicWidgets(fse);
if ((orgaunit != null) if ((orgaunit != null)
&& getSaveCancelSection().getSaveButton().isSelected(fse. && getSaveCancelSection().getSaveButton().isSelected(fse.
getPageState())) { getPageState())) {
//orgaunit.setName((String) data.get(NAME)); //orgaunit.setName((String) data.get(NAME));
orgaunit.setAddendum((String) data.get(ADDENDUM)); orgaunit.setAddendum((String) data.get(ADDENDUM));
orgaunit.save(); orgaunit.save();
} }
} }
} }

View File

@ -24,6 +24,8 @@ import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -44,27 +46,31 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Generates a form for creating new localisations for the given category. * Generates a form for creating new localisations for the given category.
* *
* This class is part of the admin GUI of CCM and extends the standard form * This class is part of the admin GUI of CCM and extends the standard form in order to present
* in order to present forms for managing the multi-language categories. * forms for managing the multi-language categories.
* *
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
public class GenericPersonContactAddForm extends BasicItemForm { public class GenericPersonContactAddForm extends BasicItemForm {
private static final Logger s_log = Logger.getLogger( private static final Logger s_log = Logger.getLogger(
GenericPersonContactAddForm.class); GenericPersonContactAddForm.class);
private GenericPersonPropertiesStep m_step; private GenericPersonPropertiesStep m_step;
private ItemSearchWidget m_itemSearch; private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "personAddress"; private final String ITEM_SEARCH = "personAddress";
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
/** Creates a new instance of CategoryLocalizationAddForm */ /**
* Creates a new instance of CategoryLocalizationAddForm
*/
public GenericPersonContactAddForm(ItemSelectionModel itemModel) { public GenericPersonContactAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel); super("ContactEntryAddForm", itemModel);
@ -80,33 +86,44 @@ public class GenericPersonContactAddForm extends BasicItemForm {
// Attach a GenericContact object // Attach a GenericContact object
add(new Label(ContenttypesGlobalizationUtil.globalize( add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.select_contact"))); "cms.contenttypes.ui.genericperson.select_contact")));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType( findByAssociatedObjectType(
"com.arsdigita.cms.contenttypes.GenericContact")); "com.arsdigita.cms.contenttypes.GenericContact"));
add(this.m_itemSearch); add(this.m_itemSearch);
// GenericContact type field // GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize( ParameterModel contactTypeParam = new StringParameter(
"cms.contenttypes.ui.genericperson.contact.type"))); GenericPersonContactCollection.CONTACTS_KEY);
ParameterModel contactTypeParam =
new StringParameter(
GenericPersonContactCollection.CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam); SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", contactType.addOption(new Option("",
new Label(GlobalizationUtil. new Label(GlobalizationUtil.
globalize("cms.ui.select_one")))); globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget @Override
GenericContactTypeCollection contacttypes = public void prepare(final PrintEvent event) {
new GenericContactTypeCollection(); final SingleSelect target = (SingleSelect) event.getTarget();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). // Add the Options to the SingleSelect widget
getLanguage()); final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) { while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute(); RelationAttribute ct = contacttypes.getRelationAttribute();
contactType.addOption(new Option(ct.getKey(), ct.getName())); target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
} }
add(contactType); add(contactType);
@ -126,17 +143,17 @@ public class GenericPersonContactAddForm extends BasicItemForm {
final FormData data = fse.getFormData(); final FormData data = fse.getFormData();
final PageState state = fse.getPageState(); final PageState state = fse.getPageState();
GenericPerson person = (GenericPerson) getItemSelectionModel(). GenericPerson person = (GenericPerson) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) { if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
contact = (GenericContact) contact.getContentBundle().getInstance( contact = (GenericContact) contact.getContentBundle().getInstance(
person.getLanguage()); person.getLanguage());
person.addContact(contact, person.addContact(contact,
(String) data.get( (String) data.get(
GenericPersonContactCollection.CONTACTS_KEY)); GenericPersonContactCollection.CONTACTS_KEY));
m_itemSearch.publishCreatedItem(data, contact); m_itemSearch.publishCreatedItem(data, contact);
} }
@ -150,38 +167,39 @@ public class GenericPersonContactAddForm extends BasicItemForm {
if (data.get(ITEM_SEARCH) == null) { if (data.get(ITEM_SEARCH) == null) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.select_contact.none_selected")); "cms.contenttypes.ui.genericperson.select_contact.none_selected"));
return; return;
} }
GenericPerson person = (GenericPerson) getItemSelectionModel(). GenericPerson person = (GenericPerson) getItemSelectionModel().
getSelectedObject(state); getSelectedObject(state);
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH); GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
if (!(contact.getContentBundle().hasInstance(person.getLanguage(), if (!(contact.getContentBundle().hasInstance(person.getLanguage(),
Kernel.getConfig(). Kernel.getConfig().
languageIndependentItems()))) { languageIndependentItems()))) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.select_contact.no_suitable_language_variant")); "cms.contenttypes.ui.genericperson.select_contact.no_suitable_language_variant"));
return; return;
} }
contact = (GenericContact) contact.getContentBundle().getInstance(person. contact = (GenericContact) contact.getContentBundle().getInstance(person.
getLanguage()); getLanguage());
GenericPersonContactCollection contacts = person.getContacts(); GenericPersonContactCollection contacts = person.getContacts();
contacts.addFilter(String.format("id = %s", contact.getID().toString())); contacts.addFilter(String.format("id = %s", contact.getID().toString()));
if (contacts.size() > 0) { if (contacts.size() > 0) {
data.addError( data.addError(
ContenttypesGlobalizationUtil.globalize( ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.select_contact.already_added")); "cms.contenttypes.ui.genericperson.select_contact.already_added"));
} }
contacts.close(); contacts.close();
} }
} }

View File

@ -46,17 +46,17 @@ import java.util.Date;
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
public class GenericPersonCreate extends PageCreate { public class GenericPersonCreate extends PageCreate {
private static final String SURNAME = GenericPerson.SURNAME; private static final String SURNAME = GenericPerson.SURNAME;
private static final String GIVENNAME = GenericPerson.GIVENNAME; private static final String GIVENNAME = GenericPerson.GIVENNAME;
private static final String TITLEPRE = GenericPerson.TITLEPRE; private static final String TITLEPRE = GenericPerson.TITLEPRE;
private static final String TITLEPOST = GenericPerson.TITLEPOST; private static final String TITLEPOST = GenericPerson.TITLEPOST;
public GenericPersonCreate(final ItemSelectionModel itemModel, public GenericPersonCreate(final ItemSelectionModel itemModel,
final CreationSelector parent) { final CreationSelector parent) {
super(itemModel, parent); super(itemModel, parent);
} }
@Override @Override
protected void addWidgets() { protected void addWidgets() {
ContentType type = getItemSelectionModel().getContentType(); ContentType type = getItemSelectionModel().getContentType();
@ -64,21 +64,25 @@ public class GenericPersonCreate extends PageCreate {
add(m_workflowSection, ColumnPanel.INSERT); add(m_workflowSection, ColumnPanel.INSERT);
add(new Label(GlobalizationUtil.globalize("cms.ui.authoring.content_type"))); add(new Label(GlobalizationUtil.globalize("cms.ui.authoring.content_type")));
add(new Label(type.getLabel())); add(new Label(type.getLabel()));
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field"))); //add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
add(new LanguageWidget(LANGUAGE)); //add(new LanguageWidget(LANGUAGE));
final LanguageWidget languageWidget = new LanguageWidget(LANGUAGE);
languageWidget.setLabel(GlobalizationUtil.globalize("cms.ui.language.field"));
add(languageWidget);
// Set all mandatory field widgets which will be used to generat the title and name // Set all mandatory field widgets which will be used to generat the title and name
GenericPersonPropertyForm.mandatoryFieldWidgets(this); GenericPersonPropertyForm.mandatoryFieldWidgets(this);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
add(new Label(GlobalizationUtil.globalize( //add(new Label(GlobalizationUtil.globalize(
"cms.ui.authoring.page_launch_date"))); // "cms.ui.authoring.page_launch_date")));
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE); ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date( com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date(
launchDateParam); launchDateParam);
launchDate.setLabel(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"));
if (ContentSection.getConfig().getRequireLaunchDate()) { if (ContentSection.getConfig().getRequireLaunchDate()) {
launchDate.addValidationListener( launchDate.addValidationListener(
new LaunchDateValidationListener()); new LaunchDateValidationListener());
// if launch date is required, help user by suggesting today's date // if launch date is required, help user by suggesting today's date
launchDateParam.setDefaultValue(new Date()); launchDateParam.setDefaultValue(new Date());
} }
@ -88,11 +92,12 @@ public class GenericPersonCreate extends PageCreate {
/** /**
* Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here * Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here
* because the super method {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries * because the super method
* to access things which on existing yet. * {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries to access
* things which on existing yet.
*/ */
@Override @Override
public void validate(FormSectionEvent e) throws FormProcessException { public void validate(FormSectionEvent e) throws FormProcessException {
Folder f = m_parent.getFolder(e.getPageState()); Folder f = m_parent.getFolder(e.getPageState());
Assert.exists(f); Assert.exists(f);
validateNameUniqueness(f, e, GenericPerson.urlSave(getItemName(e))); validateNameUniqueness(f, e, GenericPerson.urlSave(getItemName(e)));
@ -105,10 +110,10 @@ public class GenericPersonCreate extends PageCreate {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final ContentSection section = m_parent.getContentSection(state); final ContentSection section = m_parent.getContentSection(state);
Folder folder = m_parent.getFolder(state); Folder folder = m_parent.getFolder(state);
String fullName = getItemName(e); String fullName = getItemName(e);
Assert.exists(section, ContentSection.class); Assert.exists(section, ContentSection.class);
final ContentPage item = createContentPage(state); final ContentPage item = createContentPage(state);
item.setLanguage((String) data.get(LANGUAGE)); item.setLanguage((String) data.get(LANGUAGE));
item.setName(GenericPerson.urlSave(fullName)); item.setName(GenericPerson.urlSave(fullName));
@ -116,21 +121,21 @@ public class GenericPersonCreate extends PageCreate {
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
item.setLaunchDate((Date) data.get(LAUNCH_DATE)); item.setLaunchDate((Date) data.get(LAUNCH_DATE));
} }
final GenericPersonBundle bundle = new GenericPersonBundle(item); final GenericPersonBundle bundle = new GenericPersonBundle(item);
bundle.setParent(folder); bundle.setParent(folder);
bundle.setContentSection(m_parent.getContentSection(state)); bundle.setContentSection(m_parent.getContentSection(state));
bundle.save(); bundle.save();
m_workflowSection.applyWorkflow(state, item); m_workflowSection.applyWorkflow(state, item);
GenericPerson person = new GenericPerson(item.getOID()); GenericPerson person = new GenericPerson(item.getOID());
person.setTitlePre(data.getString(TITLEPRE)); person.setTitlePre(data.getString(TITLEPRE));
person.setGivenName(data.getString(GIVENNAME)); person.setGivenName(data.getString(GIVENNAME));
person.setSurname(data.getString(SURNAME)); person.setSurname(data.getString(SURNAME));
person.setTitlePost(data.getString(TITLEPOST)); person.setTitlePost(data.getString(TITLEPOST));
person.save(); person.save();
m_parent.editItem(state, item); m_parent.editItem(state, item);
} }
@ -139,7 +144,8 @@ public class GenericPersonCreate extends PageCreate {
final FormData data = e.getFormData(); final FormData data = e.getFormData();
String givenName = data.getString(GIVENNAME); String givenName = data.getString(GIVENNAME);
String surname = data.getString(SURNAME); String surname = data.getString(SURNAME);
return String.format("%s %s", surname, givenName); return String.format("%s %s", surname, givenName);
} }
} }

View File

@ -48,13 +48,12 @@ import org.apache.log4j.Logger;
* *
* @author: Jens Pelzetter * @author: Jens Pelzetter
*/ */
public class GenericPersonPropertyForm extends BasicPageForm public class GenericPersonPropertyForm extends BasicPageForm
implements FormProcessListener, implements FormProcessListener,
FormInitListener, FormInitListener,
FormSubmissionListener { FormSubmissionListener {
private static final Logger s_log = private static final Logger s_log = Logger.getLogger(GenericPersonPropertyForm.class);
Logger.getLogger(GenericPersonPropertyForm.class);
private GenericPersonPropertiesStep m_step; private GenericPersonPropertiesStep m_step;
public static final String PERSON = GenericPerson.PERSON; public static final String PERSON = GenericPerson.PERSON;
public static final String SURNAME = GenericPerson.SURNAME; public static final String SURNAME = GenericPerson.SURNAME;
@ -68,20 +67,21 @@ public class GenericPersonPropertyForm extends BasicPageForm
/** /**
* Constructor, creates an empty form. * Constructor, creates an empty form.
* *
* @param itemModel * @param itemModel
*/ */
public GenericPersonPropertyForm(ItemSelectionModel itemModel) { public GenericPersonPropertyForm(final ItemSelectionModel itemModel) {
this(itemModel, null); this(itemModel, null);
} }
/** /**
* Constructor, creates an empty form. * Constructor, creates an empty form.
*
* @param itemModel * @param itemModel
* @param step * @param step
*/ */
public GenericPersonPropertyForm(ItemSelectionModel itemModel, public GenericPersonPropertyForm(final ItemSelectionModel itemModel,
GenericPersonPropertiesStep step) { final GenericPersonPropertiesStep step) {
super(ID, itemModel); super(ID, itemModel);
m_step = step; m_step = step;
addSubmissionListener(this); addSubmissionListener(this);
@ -98,72 +98,72 @@ public class GenericPersonPropertyForm extends BasicPageForm
// Add mandatory widgets title/Surname/giben name/name appendix // Add mandatory widgets title/Surname/giben name/name appendix
mandatoryFieldWidgets(this); mandatoryFieldWidgets(this);
add(new Label(ContenttypesGlobalizationUtil final ParameterModel birthdateParam = new DateParameter(BIRTHDATE);
.globalize("cms.contenttypes.ui.genericperson.birthdate"))); final com.arsdigita.bebop.form.Date birthdate = new com.arsdigita.bebop.form.Date(birthdateParam);
ParameterModel birthdateParam = new DateParameter(BIRTHDATE); birthdate.setLabel(ContenttypesGlobalizationUtil
com.arsdigita.bebop.form.Date birthdate = new .globalize("cms.contenttypes.ui.genericperson.birthdate"));
com.arsdigita.bebop.form.Date(birthdateParam); final Calendar today = new GregorianCalendar();
Calendar today = new GregorianCalendar();
birthdate.setYearRange(1900, today.get(Calendar.YEAR)); birthdate.setYearRange(1900, today.get(Calendar.YEAR));
add(birthdate); add(birthdate);
add(new Label(ContenttypesGlobalizationUtil final ParameterModel genderParam = new StringParameter(GENDER);
.globalize("cms.contenttypes.ui.genericperson.gender"))); final SingleSelect gender = new SingleSelect(genderParam);
ParameterModel genderParam = new StringParameter(GENDER); gender.setLabel(ContenttypesGlobalizationUtil
SingleSelect gender = new SingleSelect(genderParam); .globalize("cms.contenttypes.ui.genericperson.gender"));
gender.addOption(new Option( gender.addOption(new Option(
"", "",
new Label(GlobalizationUtil.globalize("cms.ui.select_one")))); new Label(GlobalizationUtil.globalize("cms.ui.select_one"))));
gender.addOption(new Option( gender.addOption(new Option(
"f", "f",
new Label(ContenttypesGlobalizationUtil.globalize( new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.gender.f")))); "cms.contenttypes.ui.genericperson.gender.f"))));
gender.addOption(new Option( gender.addOption(new Option(
"m", "m",
new Label(ContenttypesGlobalizationUtil.globalize( new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.gender.m")))); "cms.contenttypes.ui.genericperson.gender.m"))));
add(gender); add(gender);
add(new Label(ContenttypesGlobalizationUtil final ParameterModel descriptionParam = new StringParameter(DESCRIPTION);
.globalize("cms.contenttypes.ui.genericperson.description"))); final TextArea description = new TextArea(descriptionParam);
ParameterModel descriptionParam = new StringParameter(DESCRIPTION); description.setLabel(ContenttypesGlobalizationUtil
TextArea description = new TextArea(descriptionParam); .globalize("cms.contenttypes.ui.genericperson.description"));
description.setCols(50); description.setCols(50);
description.setRows(5); description.setRows(5);
add(description); add(description);
} }
public static void mandatoryFieldWidgets(FormSection form) { public static void mandatoryFieldWidgets(final FormSection form) {
form.add(new Label(ContenttypesGlobalizationUtil final ParameterModel titlepreParam = new StringParameter(TITLEPRE);
.globalize("cms.contenttypes.ui.genericperson.titlepre"))); final TextField titlepre = new TextField(titlepreParam);
ParameterModel titlepreParam = new StringParameter(TITLEPRE); titlepre.setLabel(ContenttypesGlobalizationUtil
TextField titlepre = new TextField(titlepreParam); .globalize("cms.contenttypes.ui.genericperson.titlepre"));
form.add(titlepre); form.add(titlepre);
form.add(new Label(ContenttypesGlobalizationUtil final ParameterModel surnameParam = new StringParameter(SURNAME);
.globalize("cms.contenttypes.ui.genericperson.surname")));
ParameterModel surnameParam = new StringParameter(SURNAME);
surnameParam.addParameterListener(new NotNullValidationListener()); surnameParam.addParameterListener(new NotNullValidationListener());
TextField surname = new TextField(surnameParam); final TextField surname = new TextField(surnameParam);
surname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.surname"));
form.add(surname); form.add(surname);
form.add(new Label(ContenttypesGlobalizationUtil final ParameterModel givennameParam = new StringParameter(GIVENNAME);
.globalize("cms.contenttypes.ui.genericperson.givenname"))); final TextField givenname = new TextField(givennameParam);
ParameterModel givennameParam = new StringParameter(GIVENNAME); givenname.setLabel(ContenttypesGlobalizationUtil
TextField givenname = new TextField(givennameParam); .globalize("cms.contenttypes.ui.genericperson.givenname"));
form.add(givenname); form.add(givenname);
form.add(new Label(ContenttypesGlobalizationUtil final ParameterModel titlepostParam = new StringParameter(TITLEPOST);
.globalize("cms.contenttypes.ui.genericperson.titlepost"))); final TextField titlepost = new TextField(titlepostParam);
ParameterModel titlepostParam = new StringParameter(TITLEPOST); titlepost.setLabel(ContenttypesGlobalizationUtil
TextField titlepost = new TextField(titlepostParam); .globalize("cms.contenttypes.ui.genericperson.titlepost"));
form.add(titlepost); form.add(titlepost);
} }
public void init(FormSectionEvent fse) { @Override
FormData data = fse.getFormData(); public void init(final FormSectionEvent fse) {
GenericPerson person = (GenericPerson) super.initBasicWidgets(fse); final FormData data = fse.getFormData();
final GenericPerson person = (GenericPerson) super.initBasicWidgets(fse);
data.put(TITLEPRE, person.getTitlePre()); data.put(TITLEPRE, person.getTitlePre());
data.put(SURNAME, person.getSurname()); data.put(SURNAME, person.getSurname());
@ -174,29 +174,30 @@ public class GenericPersonPropertyForm extends BasicPageForm
data.put(DESCRIPTION, person.getDescription()); data.put(DESCRIPTION, person.getDescription());
} }
public void submitted(FormSectionEvent fse) { @Override
public void submitted(final FormSectionEvent fse) {
if (m_step != null if (m_step != null
&& getSaveCancelSection().getCancelButton() && getSaveCancelSection().getCancelButton()
.isSelected(fse.getPageState())) { .isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState()); m_step.cancelStreamlinedCreation(fse.getPageState());
} }
} }
public void process(FormSectionEvent fse) { @Override
FormData data = fse.getFormData(); public void process(final FormSectionEvent fse) {
final FormData data = fse.getFormData();
GenericPerson person = (GenericPerson) super.processBasicWidgets(fse); final GenericPerson person = (GenericPerson) super.processBasicWidgets(fse);
if (person != null if (person != null
&& getSaveCancelSection().getSaveButton() && getSaveCancelSection().getSaveButton()
.isSelected(fse.getPageState())) { .isSelected(fse.getPageState())) {
person.setTitlePre((String) data.get(TITLEPRE)); person.setTitlePre((String) data.get(TITLEPRE));
person.setSurname((String) data.get(SURNAME)); person.setSurname((String) data.get(SURNAME));
person.setGivenName((String) data.get(GIVENNAME)); person.setGivenName((String) data.get(GIVENNAME));
person.setTitlePost((String) data.get(TITLEPOST)); person.setTitlePost((String) data.get(TITLEPOST));
person.setBirthdate((Date) data.get(BIRTHDATE)); person.setBirthdate((Date) data.get(BIRTHDATE));
person.setGender((String) data.get(GENDER)); person.setGender((String) data.get(GENDER));
person.setDescription((String)data.get(DESCRIPTION)); person.setDescription((String) data.get(DESCRIPTION));
person.save(); person.save();
} }
@ -205,5 +206,5 @@ public class GenericPersonPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState()); m_step.maybeForwardToNextStep(fse.getPageState());
} }
} }
} }

View File

@ -95,3 +95,5 @@ bebop.save=Save
bebop.cancel=Cancel bebop.cancel=Cancel
bebop.cancel.msg=Submission Cancelled bebop.cancel.msg=Submission Cancelled
bebop.parameter.unexpected_value_type=Unexpected value type: {0} bebop.parameter.unexpected_value_type=Unexpected value type: {0}
bebop.date.year.hint=Year
bebop.date.year.label=Year

View File

@ -95,3 +95,5 @@ bebop.save=Speichern
bebop.cancel=Abbrechen bebop.cancel=Abbrechen
bebop.cancel.msg=Bearbeitung abgebrochen bebop.cancel.msg=Bearbeitung abgebrochen
bebop.parameter.unexpected_value_type=Unerwarteter Typ des Wertes: {0} bebop.parameter.unexpected_value_type=Unerwarteter Typ des Wertes: {0}
bebop.date.year.hint=Jahr
bebop.date.year.label=Jahr

View File

@ -95,3 +95,5 @@ bebop.save=TRANSLATE THIS: Previous (bebop.save)
bebop.cancel=TRANSLATE THIS: Previous (bebop.cancel) bebop.cancel=TRANSLATE THIS: Previous (bebop.cancel)
bebop.cancel.msg=TRANSLATE THIS: Previous (bebop.cancel.submission.msg) bebop.cancel.msg=TRANSLATE THIS: Previous (bebop.cancel.submission.msg)
bebop.parameter.unexpected_value_type=Unexpected value type: {0} bebop.parameter.unexpected_value_type=Unexpected value type: {0}
bebop.date.year.hint=
bebop.date.year.label=

View File

@ -23,7 +23,6 @@ import java.text.DateFormatSymbols;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.DateParameter;
@ -37,19 +36,20 @@ import com.arsdigita.bebop.parameters.*;
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.bebop.util.GlobalizationUtil;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
/** /**
* A class representing a date field in an HTML form. * A class representing a date field in an HTML form.
* *
* @author Karl Goldstein * @author Karl Goldstein
* @author Uday Mathur * @author Uday Mathur
* @author Michael Pih * @author Michael Pih
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
* @version $Id: Date.java 288 2010-02-20 07:29:00Z sbernstein $ * @version $Id: Date.java 288 2010-02-20 07:29:00Z sbernstein $
*/ */
public class Date extends Widget implements BebopConstants { public class Date extends Widget implements BebopConstants {
@ -58,19 +58,20 @@ public class Date extends Widget implements BebopConstants {
protected TextField m_day; protected TextField m_day;
private int m_year_begin; private int m_year_begin;
private int m_year_end; private int m_year_end;
private Locale m_locale; private Locale m_locale;
// Inner classes for the fragment widgets // Inner classes for the fragment widgets
protected class YearFragment extends SingleSelect { protected class YearFragment extends SingleSelect {
protected Date parent; protected Date parent;
private boolean autoCurrentYear; //Decide wether to set the current year if year is null private boolean autoCurrentYear; //Decide wether to set the current year if year is null
public YearFragment(String name, Date parent) { public YearFragment(String name, Date parent) {
super(name); super(name);
this.parent = parent; this.parent = parent;
setHint(GlobalizationUtil.globalize("bebop.date.year.hint"));
} }
@Override @Override
protected ParameterData getParameterData(PageState ps) { protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps); Object value = getValue(ps);
@ -79,7 +80,7 @@ public class Date extends Widget implements BebopConstants {
} }
return new ParameterData(getParameterModel(), value); return new ParameterData(getParameterModel(), value);
} }
public void setAutoCurrentYear(final boolean autoCurrentYear) { public void setAutoCurrentYear(final boolean autoCurrentYear) {
this.autoCurrentYear = autoCurrentYear; this.autoCurrentYear = autoCurrentYear;
} }
@ -100,6 +101,7 @@ public class Date extends Widget implements BebopConstants {
} }
return value; return value;
} }
} }
protected class MonthFragment extends SingleSelect { protected class MonthFragment extends SingleSelect {
@ -130,6 +132,7 @@ public class Date extends Widget implements BebopConstants {
} }
return parent.getFragmentValue(ps, Calendar.MONTH); return parent.getFragmentValue(ps, Calendar.MONTH);
} }
} }
protected class DayFragment extends TextField { protected class DayFragment extends TextField {
@ -160,6 +163,7 @@ public class Date extends Widget implements BebopConstants {
} }
return parent.getFragmentValue(ps, Calendar.DATE); return parent.getFragmentValue(ps, Calendar.DATE);
} }
} }
/** /**
@ -170,7 +174,7 @@ public class Date extends Widget implements BebopConstants {
if (!(model instanceof DateParameter || model instanceof DateTimeParameter)) { if (!(model instanceof DateParameter || model instanceof DateTimeParameter)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The Date widget " + model.getName() "The Date widget " + model.getName()
+ " must be backed by a DateParameter parmeter model"); + " must be backed by a DateParameter parmeter model");
} }
@ -202,7 +206,7 @@ public class Date extends Widget implements BebopConstants {
public void setAutoCurrentYear(final boolean autoCurrentYear) { public void setAutoCurrentYear(final boolean autoCurrentYear) {
((YearFragment) m_year).setAutoCurrentYear(autoCurrentYear); ((YearFragment) m_year).setAutoCurrentYear(autoCurrentYear);
} }
public void setYearRange(int yearBegin, int yearEnd) { public void setYearRange(int yearBegin, int yearEnd) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
if (yearBegin != m_year_begin || yearEnd != m_year_end) { if (yearBegin != m_year_begin || yearEnd != m_year_end) {
@ -214,9 +218,9 @@ public class Date extends Widget implements BebopConstants {
// Create an empty year entry to unset a date, if either // Create an empty year entry to unset a date, if either
// a) skipYearAllowed is true // a) skipYearAllowed is true
// b) skipDayAllowed is true and skipMonthAllowed is true, to unset a date // b) skipDayAllowed is true and skipMonthAllowed is true, to unset a date
if (((IncompleteDateParameter) this.getParameterModel()).isSkipYearAllowed() || if (((IncompleteDateParameter) this.getParameterModel()).isSkipYearAllowed()
(((IncompleteDateParameter) this.getParameterModel()).isSkipDayAllowed() && || (((IncompleteDateParameter) this.getParameterModel()).isSkipDayAllowed()
((IncompleteDateParameter) this.getParameterModel()).isSkipMonthAllowed())) { && ((IncompleteDateParameter) this.getParameterModel()).isSkipMonthAllowed())) {
m_year.addOption(new Option("", "")); m_year.addOption(new Option("", ""));
} }
} }
@ -247,8 +251,8 @@ public class Date extends Widget implements BebopConstants {
} }
/** /**
* 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 render this form
* used to render this form element. * element.
*/ */
public void setMaxLength(int length) { public void setMaxLength(int length) {
setAttribute("MAXLENGTH", String.valueOf(length)); setAttribute("MAXLENGTH", String.valueOf(length));
@ -258,7 +262,8 @@ public class Date extends Widget implements BebopConstants {
return true; return true;
} }
/** The XML tag for this derived class of Widget. /**
* The XML tag for this derived class of Widget.
*/ */
@Override @Override
protected String getElementTag() { protected String getElementTag() {
@ -274,6 +279,9 @@ public class Date extends Widget implements BebopConstants {
Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS); Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
date.addAttribute("name", getParameterModel().getName()); date.addAttribute("name", getParameterModel().getName());
if (getLabel() != null) {
date.addAttribute("label", (String) getLabel().localize(ps.getRequest()));
}
exportAttributes(date); exportAttributes(date);
generateLocalizedWidget(ps, date); generateLocalizedWidget(ps, date);
@ -345,12 +353,12 @@ public class Date extends Widget implements BebopConstants {
} }
/** /**
* Sets the Form Object for this Widget. This method will throw an * Sets the Form Object for this Widget. This method will throw an exception if the _form
* exception if the _form pointer is already set. To explicity * pointer is already set. To explicity change the _form pointer the developer must first call
* change the _form pointer the developer must first call
* setForm(null) * setForm(null)
* *
* @param the <code>Form</code> Object for this Widget. * @param the <code>Form</code> Object for this Widget.
*
* @exception IllegalStateException if form already set. * @exception IllegalStateException if form already set.
*/ */
@Override @Override
@ -410,4 +418,5 @@ public class Date extends Widget implements BebopConstants {
m_locale = GlobalizationHelper.getNegotiatedLocale(); m_locale = GlobalizationHelper.getNegotiatedLocale();
} }
} }
} }

View File

@ -46,370 +46,373 @@ import org.apache.log4j.Logger;
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $ * @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $
*/ */
public abstract class OptionGroup extends Widget public abstract class OptionGroup extends Widget
implements BebopConstants { implements BebopConstants {
private static final Logger s_log = Logger.getLogger(OptionGroup.class); private static final Logger s_log = Logger.getLogger(OptionGroup.class);
/** /**
* The XML element to be used by individual options belonging to this group. * The XML element to be used by individual options belonging to this group. This variable has
* This variable has to be initialized by every subclass of OptionGroup. * to be initialized by every subclass of OptionGroup. LEGACY: An abstract method would be the
* LEGACY: An abstract method would be the better design, but changing it * better design, but changing it would break the API.
* would break the API. */
*/ protected String m_xmlElement;
protected String m_xmlElement; // this only needs to be an ArrayList for multiple selection option groups
// this only needs to be an ArrayList for multiple selection option groups private ArrayList m_selected;
private ArrayList m_selected; private ArrayList m_options;
private ArrayList m_options; private Widget m_otherOption = null;
private Widget m_otherOption = null; private Form m_form = null;
private Form m_form = null; private boolean m_isDisabled = false;
private boolean m_isDisabled = false; private boolean m_isReadOnly = false;
private boolean m_isReadOnly = false; public static final String OTHER_OPTION = "__other__";
public static final String OTHER_OPTION = "__other__"; // request-local copy of selected elements, options
// request-local copy of selected elements, options private RequestLocal m_requestOptions = new RequestLocal() {
private RequestLocal m_requestOptions = new RequestLocal() {
@Override
public Object initialValue(PageState ps) {
return new ArrayList();
}
};
public final boolean isCompound() { @Override
return true; public Object initialValue(PageState ps) {
} return new ArrayList();
// this is only used for single selection option groups }
private final static String TOO_MANY_OPTIONS_SELECTED =
"Only one option may be selected by default on this option group.";
/** };
* The ParameterModel for mutliple OptionGroups is always an array parameter
*/
protected OptionGroup(ParameterModel model) {
super(model);
m_options = new ArrayList();
m_selected = new ArrayList();
}
/** public final boolean isCompound() {
* Returns an Iterator of all the default Options in this group. return true;
*/ }
public Iterator getOptions() {
return m_options.iterator();
}
/** // this is only used for single selection option groups
* Returns an Iterator of all the default Options in this group, plus any
* request-specific options.
*/
public Iterator getOptions(PageState ps) {
ArrayList allOptions = new ArrayList();
allOptions.addAll(m_options);
ArrayList requestOptions = (ArrayList) m_requestOptions.get(ps);
for (Iterator i = requestOptions.iterator(); i.hasNext();) {
Object obj = i.next();
if (!allOptions.contains(obj)) {
allOptions.add(obj);
}
}
return allOptions.iterator();
}
public void clearOptions() { private final static String TOO_MANY_OPTIONS_SELECTED
Assert.isUnlocked(this); = "Only one option may be selected by default on this option group.";
m_options = new ArrayList();
}
/** /**
* Adds a new option. * The ParameterModel for mutliple OptionGroups is always an array parameter
* */
* @param opt The {@link Option} to be added. Note: the argument is modified protected OptionGroup(ParameterModel model) {
* and associated with this OptionGroup, regardless of what its group was. super(model);
*/ m_options = new ArrayList();
public void addOption(Option opt) { m_selected = new ArrayList();
addOption(opt, null, false); }
}
public void addOption(Option opt, PageState ps) { /**
addOption(opt, ps, false); * Returns an Iterator of all the default Options in this group.
} */
public Iterator getOptions() {
return m_options.iterator();
}
/** /**
* Adds a new option.at the beginning of the list * Returns an Iterator of all the default Options in this group, plus any request-specific
* * options.
* @param opt The {@link Option} to be added. Note: the argument is modified */
* and associated with this OptionGroup, regardless of what its group was. public Iterator getOptions(PageState ps) {
*/ ArrayList allOptions = new ArrayList();
public void prependOption(Option opt) { allOptions.addAll(m_options);
addOption(opt, null, true); ArrayList requestOptions = (ArrayList) m_requestOptions.get(ps);
} for (Iterator i = requestOptions.iterator(); i.hasNext();) {
Object obj = i.next();
if (!allOptions.contains(obj)) {
allOptions.add(obj);
}
}
return allOptions.iterator();
}
public void prependOption(Option opt, PageState ps) { public void clearOptions() {
addOption(opt, ps, true); Assert.isUnlocked(this);
} m_options = new ArrayList();
}
public void removeOption(Option opt) { /**
removeOption(opt, null); * Adds a new option.
} *
* @param opt The {@link Option} to be added. Note: the argument is modified and associated with
* this OptionGroup, regardless of what its group was.
*/
public void addOption(Option opt) {
addOption(opt, null, false);
}
/** public void addOption(Option opt, PageState ps) {
* Adds a new option for the scope of the current request, or to the page as addOption(opt, ps, false);
* a whole if there is no current request. }
*
* @param opt The {@link Option} to be added. Note: the argument is modified
* and associated with this OptionGroup, regardless of what its group was.
* @param ps the current page state. if ps is null, adds option to the
* default option list.
* @param prepend If true, prepend option to the list instead of appending
* it
*/
public void addOption(Option opt, PageState ps, boolean prepend) {
ArrayList list = m_options;
if (ps == null) {
Assert.isUnlocked(this);
} else {
list = (ArrayList) m_requestOptions.get(ps);
}
opt.setGroup(this);
if (prepend == true) { /**
list.add(0, opt); * Adds a new option.at the beginning of the list
} else { *
list.add(opt); * @param opt The {@link Option} to be added. Note: the argument is modified and associated with
} * this OptionGroup, regardless of what its group was.
} */
public void prependOption(Option opt) {
addOption(opt, null, true);
}
public void removeOption(Option opt, PageState ps) { public void prependOption(Option opt, PageState ps) {
ArrayList list = m_options; addOption(opt, ps, true);
if (ps == null) { }
Assert.isUnlocked(this);
} else {
list = (ArrayList) m_requestOptions.get(ps);
}
list.remove(opt);
}
public void removeOption(String key) { public void removeOption(Option opt) {
removeOption(key, null); removeOption(opt, null);
} }
/** /**
* Removes the first option whose key is isEqual to the key that is passed * Adds a new option for the scope of the current request, or to the page as a whole if there is
* in. * no current request.
*/ *
public void removeOption(String key, PageState ps) { * @param opt The {@link Option} to be added. Note: the argument is modified and associated
* with this OptionGroup, regardless of what its group was.
* @param ps the current page state. if ps is null, adds option to the default option list.
* @param prepend If true, prepend option to the list instead of appending it
*/
public void addOption(Option opt, PageState ps, boolean prepend) {
ArrayList list = m_options;
if (ps == null) {
Assert.isUnlocked(this);
} else {
list = (ArrayList) m_requestOptions.get(ps);
}
opt.setGroup(this);
if (prepend == true) {
list.add(0, opt);
} else {
list.add(opt);
}
}
public void removeOption(Option opt, PageState ps) {
ArrayList list = m_options;
if (ps == null) {
Assert.isUnlocked(this);
} else {
list = (ArrayList) m_requestOptions.get(ps);
}
list.remove(opt);
}
public void removeOption(String key) {
removeOption(key, null);
}
/**
* Removes the first option whose key is isEqual to the key that is passed in.
*/
public void removeOption(String key, PageState ps) {
// This is not an entirely efficient technique. A more // This is not an entirely efficient technique. A more
// efficient solution is to switch to using a HashMap. // efficient solution is to switch to using a HashMap.
ArrayList list = m_options; ArrayList list = m_options;
if (ps == null) { if (ps == null) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
} else { } else {
list = (ArrayList) m_requestOptions.get(ps); list = (ArrayList) m_requestOptions.get(ps);
} }
Iterator i = list.iterator(); Iterator i = list.iterator();
Option o = null; Option o = null;
while (i.hasNext()) { while (i.hasNext()) {
o = (Option) i.next(); o = (Option) i.next();
if (o.getValue().equals(key)) { if (o.getValue().equals(key)) {
list.remove(o); list.remove(o);
break; break;
} }
} }
} }
/** /**
* Add an "Other (please specify)" type option to the widget * Add an "Other (please specify)" type option to the widget
* *
* @param hasOtherOption true is the widget has an "Other" option * @param hasOtherOption true is the widget has an "Other" option
* @param width The width, in characters, of the "Other" entry area * @param width The width, in characters, of the "Other" entry area
* @param height The height, in characters, of the "Other" entry area. If * @param height The height, in characters, of the "Other" entry area. If this is 1 then
* this is 1 then a TextField is used. Otherwise a TextArea is used. * a TextField is used. Otherwise a TextArea is used.
*/ */
public void addOtherOption(String label, int width, int height) { public void addOtherOption(String label, int width, int height) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
Option otherOption = new Option(OTHER_OPTION, label); Option otherOption = new Option(OTHER_OPTION, label);
addOption(otherOption); addOption(otherOption);
final ParameterModel model = getParameterModel(); final ParameterModel model = getParameterModel();
if (1 == height) { if (1 == height) {
TextField field = TextField field = new TextField(model.getName() + ".other");
new TextField(model.getName() + ".other"); field.setSize(width);
field.setSize(width);
m_otherOption = field; m_otherOption = field;
} else { } else {
TextArea area = TextArea area = new TextArea(model.getName() + ".other");
new TextArea(model.getName() + ".other"); area.setCols(width);
area.setCols(width); area.setRows(height);
area.setRows(height);
m_otherOption = area; m_otherOption = area;
} }
if (null != m_form) { if (null != m_form) {
m_otherOption.setForm(m_form); m_otherOption.setForm(m_form);
if (m_isDisabled) { if (m_isDisabled) {
m_otherOption.setDisabled(); m_otherOption.setDisabled();
} }
if (m_isReadOnly) { if (m_isReadOnly) {
m_otherOption.setReadOnly(); m_otherOption.setReadOnly();
} }
} }
setParameterModel(new ParameterModelWrapper(model) { setParameterModel(new ParameterModelWrapper(model) {
@Override
public ParameterData createParameterData(final HttpServletRequest request,
Object defaultValue,
boolean isSubmission) {
final String[] values = @Override
request.getParameterValues(getName()); public ParameterData createParameterData(final HttpServletRequest request,
String[] otherValues = Object defaultValue,
request.getParameterValues(getName() + ".other"); boolean isSubmission) {
String other = (null == otherValues) ? null : otherValues[0]; final String[] values = request.getParameterValues(getName());
String[] otherValues = request.getParameterValues(getName() + ".other");
if (null != values) { String other = (null == otherValues) ? null : otherValues[0];
for (int i = 0; i < values.length; i++) {
if (OTHER_OPTION.equals(values[i])) {
values[i] = other;
}
}
}
s_log.debug("createParameterData in OptionGroup"); if (null != values) {
for (int i = 0; i < values.length; i++) {
if (OTHER_OPTION.equals(values[i])) {
values[i] = other;
}
}
}
return super.createParameterData(new HttpServletRequestWrapper(request) { s_log.debug("createParameterData in OptionGroup");
@Override
public String[] getParameterValues(String key) {
if (s_log.isDebugEnabled()) {
s_log.debug("Getting values for " + key);
}
if (model.getName().equals(key)) { return super.createParameterData(new HttpServletRequestWrapper(request) {
return values;
}
return super.getParameterValues(key);
}
}, defaultValue, isSubmission);
}
private void replaceOther(String[] values, String other) { @Override
} public String[] getParameterValues(String key) {
}); if (s_log.isDebugEnabled()) {
} s_log.debug("Getting values for " + key);
}
/** if (model.getName().equals(key)) {
* Make an option selected by default. Updates the parameter model for the return values;
* option group accordingly. }
* return super.getParameterValues(key);
* @param value the value of the option to be added to the }
* by-default-selected set.
*/ }, defaultValue, isSubmission);
public void setOptionSelected(String value) { }
Assert.isUnlocked(this);
if (!isMultiple()) { private void replaceOther(String[] values, String other) {
}
});
}
/**
* Make an option selected by default. Updates the parameter model for the option group
* accordingly.
*
* @param value the value of the option to be added to the by-default-selected set.
*/
public void setOptionSelected(String value) {
Assert.isUnlocked(this);
if (!isMultiple()) {
// only one option may be selected // only one option may be selected
// to this selected list better be empty // to this selected list better be empty
Assert.isTrue(m_selected.size() == 0, TOO_MANY_OPTIONS_SELECTED); Assert.isTrue(m_selected.size() == 0, TOO_MANY_OPTIONS_SELECTED);
m_selected.add(value); m_selected.add(value);
getParameterModel().setDefaultValue(value); getParameterModel().setDefaultValue(value);
} else { } else {
m_selected.add(value); m_selected.add(value);
getParameterModel().setDefaultValue(m_selected.toArray()); getParameterModel().setDefaultValue(m_selected.toArray());
} }
} }
/** /**
* make an option selected by default * make an option selected by default
* *
* @param option the option to be added to the by-default-selected set. * @param option the option to be added to the by-default-selected set.
*/ */
public void setOptionSelected(Option option) { public void setOptionSelected(Option option) {
setOptionSelected(option.getValue()); setOptionSelected(option.getValue());
} }
@Override @Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
OptionGroup cloned = (OptionGroup) super.clone(); OptionGroup cloned = (OptionGroup) super.clone();
cloned.m_options = (ArrayList) m_options.clone(); cloned.m_options = (ArrayList) m_options.clone();
cloned.m_selected = cloned.m_selected = (ArrayList) m_selected.clone();
(ArrayList) m_selected.clone(); return cloned;
return cloned; }
}
/** /**
* Is this a multiple (and not single) selection option group? Note that * Is this a multiple (and not single) selection option group? Note that this should really be
* this should really be declared abstract, but we can't because it used to * declared abstract, but we can't because it used to be in the direct subclass Select and
* be in the direct subclass Select and making it abstract could break other * making it abstract could break other subclasses that don't declare isMultiple. So we have a
* subclasses that don't declare isMultiple. So we have a trivial * trivial implementation instead.
* implementation instead. *
* * @return true if this OptionGroup can have more than one selected option; false otherwise.
* @return true if this OptionGroup can have more than one selected option; */
* false otherwise. public boolean isMultiple() {
*/ return true;
public boolean isMultiple() { }
return true;
}
@Override @Override
public void setDisabled() { public void setDisabled() {
m_isDisabled = true; m_isDisabled = true;
if (null != m_otherOption) { if (null != m_otherOption) {
m_otherOption.setDisabled(); m_otherOption.setDisabled();
} }
super.setDisabled(); super.setDisabled();
} }
@Override @Override
public void setReadOnly() { public void setReadOnly() {
m_isReadOnly = true; m_isReadOnly = true;
if (null != m_otherOption) { if (null != m_otherOption) {
m_otherOption.setReadOnly(); m_otherOption.setReadOnly();
} }
super.setReadOnly(); super.setReadOnly();
} }
@Override @Override
public void setForm(Form form) { public void setForm(Form form) {
m_form = form; m_form = form;
if (null != m_otherOption) { if (null != m_otherOption) {
m_otherOption.setForm(form); m_otherOption.setForm(form);
} }
super.setForm(form); super.setForm(form);
} }
/** /**
* Generates the DOM for the select widget <p>Generates DOM fragment: <p><pre><code>&lt;bebop:* name=... [onXXX=...]&gt; * Generates the DOM for the select widget
* <p>
* Generates DOM fragment:
* <p>
* <pre><code>&lt;bebop:* name=... [onXXX=...]&gt;
* &lt;bebop:option name=... [selected]&gt; option value &lt;/bebop:option%gt; * &lt;bebop:option name=... [selected]&gt; option value &lt;/bebop:option%gt;
* ... * ...
* &lt;/bebop:*select&gt;</code></pre> * &lt;/bebop:*select&gt;</code></pre>
*/ */
@Override @Override
public void generateWidget(PageState state, Element parent) { public void generateWidget(PageState state, Element parent) {
Element optionGroup = Element optionGroup = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
parent.newChildElement(getElementTag(), BEBOP_XML_NS); optionGroup.addAttribute("name", getName());
optionGroup.addAttribute("name", getName()); optionGroup.addAttribute("class", getName().replace(".", " "));
optionGroup.addAttribute("class", getName().replace(".", " ")); if (getLabel() != null) {
if (isMultiple()) { optionGroup.addAttribute("label", (String) getLabel().localize(state.getRequest()));
optionGroup.addAttribute("multiple", "multiple"); }
} if (isMultiple()) {
exportAttributes(optionGroup); optionGroup.addAttribute("multiple", "multiple");
}
exportAttributes(optionGroup);
for (Iterator i = getOptions(state); i.hasNext();) { for (Iterator i = getOptions(state); i.hasNext();) {
Option o = (Option) i.next(); Option o = (Option) i.next();
o.generateXML(state, optionGroup); o.generateXML(state, optionGroup);
} }
if (null != m_otherOption) {
m_otherOption.generateXML(state, optionGroup);
}
}
if (null != m_otherOption) {
m_otherOption.generateXML(state, optionGroup);
}
}
} }

View File

@ -115,6 +115,9 @@
<!-- EN Create a select or multiselect widget. If wanted, creates a label instead for <!-- EN Create a select or multiselect widget. If wanted, creates a label instead for
a selection length of 1. --> a selection length of 1. -->
<xsl:template match="bebop:select | bebop:multiSelect"> <xsl:template match="bebop:select | bebop:multiSelect">
<xsl:call-template name="processLabel">
<xsl:with-param name="widget" select="."/>
</xsl:call-template>
<xsl:choose> <xsl:choose>
<xsl:when test="@class = 'displayOneOptionAsLabel' and count(bebop:option) = 1"> <xsl:when test="@class = 'displayOneOptionAsLabel' and count(bebop:option) = 1">
<xsl:choose> <xsl:choose>
@ -199,9 +202,15 @@
</xsl:template> </xsl:template>
<xsl:template match="bebop:date"> <xsl:template match="bebop:date">
<span class="date"> <!--<span class="date">
<xsl:apply-templates/> <xsl:apply-templates/>
</span> </span>-->
<fieldset class="date">
<legend>
<xsl:value-of select="@label"/>
</legend>
<xsl:apply-templates/>
</fieldset>
</xsl:template> </xsl:template>
<xsl:template match="bebop:time"> <xsl:template match="bebop:time">