- 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,12 +66,12 @@ 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) {
@ -84,35 +84,34 @@ 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 = ContentGroup group = getCurrentGroup(item, m_attributeName);
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 @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 = 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);
@ -125,11 +124,9 @@ 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
*/ */
@ -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,11 +146,9 @@ 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());
} }
@ -161,24 +156,22 @@ public class ContentGroupPropertyForm extends BasicItemForm {
} }
} }
/** /**
* 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) {
@ -186,8 +179,8 @@ public class ContentGroupPropertyForm extends BasicItemForm {
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.
@ -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,7 +218,6 @@ public class ContentGroupPropertyForm extends BasicItemForm {
} }
} }
/** /**
* This returns the correct group for the attribute name * This returns the correct group for the attribute name
*/ */
@ -235,7 +225,6 @@ public class ContentGroupPropertyForm extends BasicItemForm {
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
*/ */
@ -245,13 +234,13 @@ public class ContentGroupPropertyForm extends BasicItemForm {
} }
/** /**
* 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;
/** /**
@ -81,53 +86,67 @@ 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.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("", 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 {
country.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator(); .entrySet().iterator();
while (countries.hasNext()) { while (countries.hasNext()) {
Map.Entry<String, String> elem = Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
(Map.Entry<String, String>) countries.next(); .next();
country.addOption(new Option(elem.getValue().toString(), target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString())); elem.getKey().toString()));
} }
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
country.addValidationListener(new ParameterListener() { country.addValidationListener(new ParameterListener() {
@ -142,6 +161,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
.localize()); .localize());
} }
} }
}); });
add(country); add(country);
@ -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;
/** /**
@ -46,8 +48,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
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,8 +64,7 @@ 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
@ -93,26 +93,38 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
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();
final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); 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 the Options to the SingleSelect widget
add(contactType); add(contactType);
} }
@ -156,8 +168,7 @@ 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();
@ -171,6 +182,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
"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);
@ -214,4 +226,5 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
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,6 +46,9 @@ 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;
@ -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";
/** /**
@ -94,61 +101,72 @@ 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 {
country.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator(); .entrySet().iterator();
while (countries.hasNext()) { while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
countries.next(); .next();
country.addOption(new Option(elem.getValue().toString(), target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString())); elem.getKey().toString()));
} }
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
country.addValidationListener( country.addValidationListener(
new ParameterListener() { new ParameterListener() {
@ -164,6 +182,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
.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;
@ -80,8 +84,7 @@ 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
@ -98,56 +101,68 @@ 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) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper contacttypes.addLanguageFilter(GlobalizationHelper
.getNegotiatedLocale().getLanguage()); .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 the Options to the SingleSelect widget
add(contactType); add(contactType);
} }
@ -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,14 +48,17 @@ 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;
} }
@ -59,48 +67,58 @@ public class GenericContactEntryAddForm extends BasicItemForm {
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 @Override
GenericContactEntryKeys keyList = new GenericContactEntryKeys(); public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericContactEntryKeys keyList = new GenericContactEntryKeys();
keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale() keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
.getLanguage()); .getLanguage());
while(keyList.next()) { while (keyList.next()) {
String currentKey = keyList.getKey(); String currentKey = keyList.getKey();
contactEntryKey.addOption(new Option(currentKey, keyList.getName())); 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) {
@ -113,8 +131,7 @@ public class GenericContactEntryAddForm extends BasicItemForm {
*/ */
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
@ -123,11 +140,12 @@ public class GenericContactEntryAddForm extends BasicItemForm {
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;
/** /**
@ -77,33 +82,45 @@ public class GenericOrganizationalUnitContactAddForm
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) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericOrganizationContactTypeCollection contacttypes
= new GenericOrganizationContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); 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);
} }
@ -134,8 +151,7 @@ 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)) {
@ -204,9 +220,8 @@ public class GenericOrganizationalUnitContactAddForm
} }
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);
@ -224,7 +239,6 @@ public class GenericOrganizationalUnitContactAddForm
} }
} }
if (orgaunit.getLanguage().equals( if (orgaunit.getLanguage().equals(
GlobalizationHelper.LANG_INDEPENDENT)) { GlobalizationHelper.LANG_INDEPENDENT)) {
contact = (GenericContact) contact.getContentBundle(). contact = (GenericContact) contact.getContentBundle().
@ -247,4 +261,5 @@ public class GenericOrganizationalUnitContactAddForm
contacts.close(); contacts.close();
} }
} }
} }

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;
/** /**
@ -86,47 +90,69 @@ public class GenericOrganizationalUnitPersonAddForm
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")));
ParameterModel roleParam =
new StringParameter(
GenericOrganizationalUnitPersonCollection.PERSON_ROLE); 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 {
roleSelect.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final RelationAttributeCollection roles = new RelationAttributeCollection(
getRoleAttributeName()); getRoleAttributeName());
roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); getLanguage());
while (roles.next()) { while (roles.next()) {
RelationAttribute role; RelationAttribute role;
role = roles.getRelationAttribute(); role = roles.getRelationAttribute();
roleSelect.addOption(new Option(role.getKey(), role.getName())); 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")));
ParameterModel statusModel =
new StringParameter(
GenericOrganizationalUnitPersonCollection.STATUS); GenericOrganizationalUnitPersonCollection.STATUS);
SingleSelect statusSelect = new SingleSelect(statusModel); final SingleSelect statusSelect = new SingleSelect(statusModel);
statusSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status"));
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() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
RelationAttributeCollection statusColl = new RelationAttributeCollection(
getStatusAttributeName()); getStatusAttributeName());
statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); getLanguage());
while (statusColl.next()) { while (statusColl.next()) {
RelationAttribute status; RelationAttribute status;
status = statusColl.getRelationAttribute(); status = statusColl.getRelationAttribute();
statusSelect.addOption(new Option(status.getKey(), status.getName())); 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,8 +193,7 @@ 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,8 +202,7 @@ 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()));
@ -240,8 +264,7 @@ public class GenericOrganizationalUnitPersonAddForm
} }
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);
@ -255,10 +278,8 @@ public class GenericOrganizationalUnitPersonAddForm
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", persons.addFilter(String.format("id = %s",
bundle.getID().toString())); bundle.getID().toString()));
@ -290,4 +311,5 @@ public class GenericOrganizationalUnitPersonAddForm
protected String getStatusAttributeName() { protected String getStatusAttributeName() {
return "GenericOrganizationalUnitMemberStatus"; return "GenericOrganizationalUnitMemberStatus";
} }
} }

View File

@ -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);
} }
@ -96,8 +88,7 @@ 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());
@ -108,8 +99,7 @@ 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)
@ -121,4 +111,5 @@ public class GenericOrganizationalUnitPropertyForm
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,13 +46,15 @@ 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>
*/ */
@ -64,7 +68,9 @@ public class GenericPersonContactAddForm extends BasicItemForm {
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);
@ -87,26 +93,37 @@ public class GenericPersonContactAddForm extends BasicItemForm {
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")));
ParameterModel contactTypeParam =
new StringParameter(
GenericPersonContactCollection.CONTACTS_KEY); 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() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
// Add the Options to the SingleSelect widget // Add the Options to the SingleSelect widget
GenericContactTypeCollection contacttypes = final GenericContactTypeCollection contacttypes
new GenericContactTypeCollection(); = new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage()); 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);
@ -184,4 +201,5 @@ public class GenericPersonContactAddForm extends BasicItemForm {
contacts.close(); contacts.close();
} }
} }

View File

@ -64,18 +64,22 @@ 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());
@ -88,8 +92,9 @@ 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 {
@ -142,4 +147,5 @@ public class GenericPersonCreate extends PageCreate {
return String.format("%s %s", surname, givenName); return String.format("%s %s", surname, givenName);
} }
} }

View File

@ -53,8 +53,7 @@ public class GenericPersonPropertyForm extends BasicPageForm
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;
@ -71,17 +70,18 @@ public class GenericPersonPropertyForm extends BasicPageForm
* *
* @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,19 +98,18 @@ 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"))));
@ -124,46 +123,47 @@ public class GenericPersonPropertyForm extends BasicPageForm
"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,7 +174,8 @@ 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())) {
@ -182,10 +183,10 @@ public class GenericPersonPropertyForm extends BasicPageForm
} }
} }
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()
@ -196,7 +197,7 @@ public class GenericPersonPropertyForm extends BasicPageForm
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,6 +36,7 @@ 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;
@ -69,6 +69,7 @@ public class Date extends Widget implements BebopConstants {
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
@ -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);
} }
} }
/** /**
@ -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

@ -50,10 +50,9 @@ public abstract class OptionGroup extends Widget
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
@ -66,18 +65,22 @@ public abstract class OptionGroup extends Widget
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 @Override
public Object initialValue(PageState ps) { public Object initialValue(PageState ps) {
return new ArrayList(); return new ArrayList();
} }
}; };
public final boolean isCompound() { public final boolean isCompound() {
return true; return true;
} }
// this is only used for single selection option groups // 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."; 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 * The ParameterModel for mutliple OptionGroups is always an array parameter
@ -96,8 +99,8 @@ public abstract class OptionGroup extends Widget
} }
/** /**
* Returns an Iterator of all the default Options in this group, plus any * Returns an Iterator of all the default Options in this group, plus any request-specific
* request-specific options. * options.
*/ */
public Iterator getOptions(PageState ps) { public Iterator getOptions(PageState ps) {
ArrayList allOptions = new ArrayList(); ArrayList allOptions = new ArrayList();
@ -120,8 +123,8 @@ public abstract class OptionGroup extends Widget
/** /**
* Adds a new option. * Adds a new option.
* *
* @param opt The {@link Option} to be added. Note: the argument is modified * @param opt The {@link Option} to be added. Note: the argument is modified and associated with
* and associated with this OptionGroup, regardless of what its group was. * this OptionGroup, regardless of what its group was.
*/ */
public void addOption(Option opt) { public void addOption(Option opt) {
addOption(opt, null, false); addOption(opt, null, false);
@ -134,8 +137,8 @@ public abstract class OptionGroup extends Widget
/** /**
* Adds a new option.at the beginning of the list * Adds a new option.at the beginning of the list
* *
* @param opt The {@link Option} to be added. Note: the argument is modified * @param opt The {@link Option} to be added. Note: the argument is modified and associated with
* and associated with this OptionGroup, regardless of what its group was. * this OptionGroup, regardless of what its group was.
*/ */
public void prependOption(Option opt) { public void prependOption(Option opt) {
addOption(opt, null, true); addOption(opt, null, true);
@ -150,15 +153,13 @@ public abstract class OptionGroup extends Widget
} }
/** /**
* Adds a new option for the scope of the current request, or to the page as * Adds a new option for the scope of the current request, or to the page as a whole if there is
* a whole if there is no current request. * no current request.
* *
* @param opt The {@link Option} to be added. Note: the argument is modified * @param opt The {@link Option} to be added. Note: the argument is modified and associated
* and associated with this OptionGroup, regardless of what its group was. * with this OptionGroup, regardless of what its group was.
* @param ps the current page state. if ps is null, adds option to the * @param ps the current page state. if ps is null, adds option to the default option list.
* default option list. * @param prepend If true, prepend option to the list instead of appending it
* @param prepend If true, prepend option to the list instead of appending
* it
*/ */
public void addOption(Option opt, PageState ps, boolean prepend) { public void addOption(Option opt, PageState ps, boolean prepend) {
ArrayList list = m_options; ArrayList list = m_options;
@ -191,8 +192,7 @@ public abstract class OptionGroup extends Widget
} }
/** /**
* Removes the first option whose key is isEqual to the key that is passed * Removes the first option whose key is isEqual to the key that is passed in.
* in.
*/ */
public void removeOption(String key, PageState ps) { 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
@ -221,8 +221,8 @@ public abstract class OptionGroup extends 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);
@ -233,14 +233,12 @@ public abstract class OptionGroup extends Widget
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);
@ -259,15 +257,14 @@ public abstract class OptionGroup extends Widget
} }
setParameterModel(new ParameterModelWrapper(model) { setParameterModel(new ParameterModelWrapper(model) {
@Override @Override
public ParameterData createParameterData(final HttpServletRequest request, public ParameterData createParameterData(final HttpServletRequest request,
Object defaultValue, Object defaultValue,
boolean isSubmission) { boolean isSubmission) {
final String[] values = final String[] values = request.getParameterValues(getName());
request.getParameterValues(getName()); String[] otherValues = request.getParameterValues(getName() + ".other");
String[] otherValues =
request.getParameterValues(getName() + ".other");
String other = (null == otherValues) ? null : otherValues[0]; String other = (null == otherValues) ? null : otherValues[0];
@ -282,6 +279,7 @@ public abstract class OptionGroup extends Widget
s_log.debug("createParameterData in OptionGroup"); s_log.debug("createParameterData in OptionGroup");
return super.createParameterData(new HttpServletRequestWrapper(request) { return super.createParameterData(new HttpServletRequestWrapper(request) {
@Override @Override
public String[] getParameterValues(String key) { public String[] getParameterValues(String key) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
@ -293,20 +291,21 @@ public abstract class OptionGroup extends Widget
} }
return super.getParameterValues(key); return super.getParameterValues(key);
} }
}, defaultValue, isSubmission); }, defaultValue, isSubmission);
} }
private void replaceOther(String[] values, String other) { private void replaceOther(String[] values, String other) {
} }
}); });
} }
/** /**
* Make an option selected by default. Updates the parameter model for the * Make an option selected by default. Updates the parameter model for the option group
* option group accordingly. * accordingly.
* *
* @param value the value of the option to be added to the * @param value the value of the option to be added to the by-default-selected set.
* by-default-selected set.
*/ */
public void setOptionSelected(String value) { public void setOptionSelected(String value) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
@ -335,20 +334,17 @@ public abstract class OptionGroup extends Widget
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; * @return true if this OptionGroup can have more than one selected option; false otherwise.
* false otherwise.
*/ */
public boolean isMultiple() { public boolean isMultiple() {
return true; return true;
@ -387,17 +383,23 @@ public abstract class OptionGroup extends Widget
} }
/** /**
* 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) {
optionGroup.addAttribute("label", (String) getLabel().localize(state.getRequest()));
}
if (isMultiple()) { if (isMultiple()) {
optionGroup.addAttribute("multiple", "multiple"); optionGroup.addAttribute("multiple", "multiple");
} }
@ -412,4 +414,5 @@ public abstract class OptionGroup extends Widget
m_otherOption.generateXML(state, optionGroup); 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">