First part of Enhancing globalization of content-center (#1763). Text output is localized, but badly placed on the page. Needs further reworking of several classes.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2670 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
0dd6e8ff55
commit
59252132a4
|
|
@ -271,10 +271,10 @@ public class EventPropertyForm extends BasicPageForm
|
|||
if (endDate != null) {
|
||||
|
||||
if (startDate == null || startDate.compareTo(endDate) > 0) {
|
||||
throw new FormProcessException((String)
|
||||
throw new FormProcessException("End date must be after start date",
|
||||
EventGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.event.end_date_after_start_date")
|
||||
.localize());
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class MultiPartArticleCreate extends MultiPartArticleForm
|
|||
FormSubmissionListener,
|
||||
FormValidationListener,
|
||||
CreationComponent {
|
||||
private CreationSelector m_parent;
|
||||
private final CreationSelector m_parent;
|
||||
private ApplyWorkflowFormSection m_workflowSection;
|
||||
|
||||
public MultiPartArticleCreate(ItemSelectionModel itemModel,
|
||||
|
|
@ -84,38 +84,45 @@ public class MultiPartArticleCreate extends MultiPartArticleForm
|
|||
*
|
||||
* @return the ApplyWorkflowFormSection associated with this CreationComponent.
|
||||
*/
|
||||
@Override
|
||||
public ApplyWorkflowFormSection getWorkflowSection() {
|
||||
return m_workflowSection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent event) throws FormProcessException {
|
||||
// this is currently a no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitted(FormSectionEvent event) throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
if (getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||
m_parent.redirectBack(state);
|
||||
throw new FormProcessException(
|
||||
(String)MPArticleGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.mparticle.submission_cancelled")
|
||||
.localize());
|
||||
"Submission cancelled",
|
||||
MPArticleGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.mparticle.submission_cancelled")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent event) throws FormProcessException {
|
||||
Folder f = m_parent.getFolder(event.getPageState());
|
||||
Assert.exists(f, Folder.class);
|
||||
if (!validateNameUniqueness(f, event)) {
|
||||
throw new FormProcessException(
|
||||
(String)MPArticleGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.mparticle." +
|
||||
"An item with this name already exists",
|
||||
MPArticleGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.mparticle." +
|
||||
"an_item_with_this_name_already_exists")
|
||||
.localize());
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent e) throws FormProcessException {
|
||||
final FormData data = e.getFormData();
|
||||
final PageState state = e.getPageState();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import com.arsdigita.util.Assert;
|
|||
public class MultiPartArticleEditForm extends MultiPartArticleForm
|
||||
implements FormSubmissionListener {
|
||||
|
||||
private SimpleEditStep m_step;
|
||||
private final SimpleEditStep m_step;
|
||||
|
||||
public MultiPartArticleEditForm(ItemSelectionModel itemModel,
|
||||
SimpleEditStep step) {
|
||||
|
|
@ -46,11 +46,15 @@ public class MultiPartArticleEditForm extends MultiPartArticleForm
|
|||
m_step = step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent e) throws FormProcessException {
|
||||
super.initBasicWidgets(e);
|
||||
}
|
||||
|
||||
/** Cancels streamlined editing. */
|
||||
/**
|
||||
* Cancels streamlined editing.
|
||||
* @param fse */
|
||||
@Override
|
||||
public void submitted( FormSectionEvent fse ) {
|
||||
if (getSaveCancelSection().getCancelButton()
|
||||
.isSelected( fse.getPageState())) {
|
||||
|
|
@ -58,12 +62,14 @@ public class MultiPartArticleEditForm extends MultiPartArticleForm
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
MultiPartArticle article = processBasicWidgets(e);
|
||||
m_step.maybeForwardToNextStep(e.getPageState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
FormData data = e.getFormData();
|
||||
|
|
@ -83,9 +89,10 @@ public class MultiPartArticleEditForm extends MultiPartArticleForm
|
|||
|
||||
if ( !valid ) {
|
||||
throw new FormProcessException
|
||||
((String)MPArticleGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.mparticle." +
|
||||
"an_item_with_name_already_exists").localize());
|
||||
("An item with name already exists",
|
||||
MPArticleGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.mparticle." +
|
||||
"an_item_with_name_already_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public class SectionDeleteForm extends Form
|
|||
return m_saveCancelSection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init ( FormSectionEvent event ) throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -97,14 +98,20 @@ public class SectionDeleteForm extends Form
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitted ( FormSectionEvent event ) throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
if ( m_saveCancelSection.getCancelButton().isSelected(state) ) {
|
||||
throw new FormProcessException( (String) MPArticleGlobalizationUtil.globalize("cms.contenttypes.ui.mparticle.submission_cancelled").localize());
|
||||
throw new FormProcessException(
|
||||
"Submission cancelled",
|
||||
MPArticleGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.mparticle.submission_cancelled")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process ( FormSectionEvent event ) throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
|
|
|
|||
|
|
@ -190,12 +190,48 @@ public class SectionEditForm extends Form {
|
|||
add(pageBreak);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to create a Section from the form data supplied.
|
||||
*
|
||||
* @param event
|
||||
* @param article
|
||||
* @return
|
||||
*/
|
||||
protected ArticleSection createSection(FormSectionEvent event,
|
||||
MultiPartArticle article) {
|
||||
|
||||
PageState state = event.getPageState();
|
||||
FormData data = event.getFormData();
|
||||
|
||||
ArticleSection section = new ArticleSection();
|
||||
|
||||
section.setTitle((String)data.get(TITLE));
|
||||
section.setName(article.getName() + ": " + (String)data.get(TITLE));
|
||||
section.setContentSection(article.getContentSection());
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
p.addGlobalStateParam(m_imageParam);
|
||||
p.addGlobalStateParam(m_textParam);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the form. If there is a selected section, ie. this
|
||||
* is an 'edit' step rather than a 'create new' step, load the data
|
||||
* into the form fields.
|
||||
*/
|
||||
private class SectionInitListener implements FormInitListener {
|
||||
|
||||
@Override
|
||||
public void init( FormSectionEvent event )
|
||||
throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
|
@ -245,6 +281,8 @@ public class SectionEditForm extends Form {
|
|||
* cancel button. If they did, don't continue with the form.
|
||||
*/
|
||||
private class SectionSubmissionListener implements FormSubmissionListener {
|
||||
|
||||
@Override
|
||||
public void submitted( FormSectionEvent event )
|
||||
throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
|
@ -255,9 +293,10 @@ public class SectionEditForm extends Form {
|
|||
state, MultiPartArticleViewSections.SECTION_TABLE+
|
||||
m_container.getTypeIDStr());
|
||||
throw new FormProcessException(
|
||||
(String)MPArticleGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.mparticle.submission_cancelled")
|
||||
.localize());
|
||||
"Submission cancelled",
|
||||
MPArticleGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.mparticle.submission_cancelled")
|
||||
);
|
||||
} else if ( m_imageUpload.getDeleteImageButton().isSelected(state) ) {
|
||||
BigDecimal id = new BigDecimal(m_selSection
|
||||
.getSelectedKey(state).toString());
|
||||
|
|
@ -278,6 +317,8 @@ public class SectionEditForm extends Form {
|
|||
* assign it to the current MultiPartArticle.
|
||||
*/
|
||||
private class SectionProcessListener implements FormProcessListener {
|
||||
|
||||
@Override
|
||||
public void process( FormSectionEvent event )
|
||||
throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
|
@ -294,7 +335,6 @@ public class SectionEditForm extends Form {
|
|||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
||||
|
||||
// get the selected section to update or create a new one
|
||||
ArticleSection section = (ArticleSection)
|
||||
m_selSection.getSelectedObject(state);
|
||||
|
|
@ -349,28 +389,4 @@ public class SectionEditForm extends Form {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility method to create a Section from the form data supplied.
|
||||
*/
|
||||
protected ArticleSection createSection(FormSectionEvent event,
|
||||
MultiPartArticle article) {
|
||||
|
||||
PageState state = event.getPageState();
|
||||
FormData data = event.getFormData();
|
||||
|
||||
ArticleSection section = new ArticleSection();
|
||||
|
||||
section.setTitle((String)data.get(TITLE));
|
||||
section.setName(article.getName() + ": " + (String)data.get(TITLE));
|
||||
section.setContentSection(article.getContentSection());
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
p.addGlobalStateParam(m_imageParam);
|
||||
p.addGlobalStateParam(m_textParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ cms.ui.item_search.search=Search
|
|||
|
||||
# Package com.arsdigita.cms.ui.authoring
|
||||
# ======================================
|
||||
cms.ui.authoring.an_item_with_this_name_already_exists=An item with this name already exists
|
||||
cms.ui.authoring.an_item_with_this_name_already_exists=An item with this name already exists!
|
||||
cms.ui.authoring.bad_getblob_datatype=Bad getBlob datatype
|
||||
cms.ui.authoring.bad_getclob_datatype=Bad getClob datatype
|
||||
cms.ui.authoring.body=Body:
|
||||
|
|
@ -1074,3 +1074,7 @@ cms.ui.change_password=Change password
|
|||
cms.ui.image_select.page_title=Select or upload image
|
||||
cms.ui.image_library=Image library
|
||||
cms.ui.image_upload=Upload image
|
||||
cms.ui.authoring.items_with_this_name_already_exist=Items with whit name already exist. (Id: {0})
|
||||
cms.ui.authoring.parameter_not_empty=This parameter may not be empty.
|
||||
cms.ui.authoring.parameter_should_be_a_valid_filename=This parameter should be a valid filename.
|
||||
cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ cms.ui.item_search.search=Suchen
|
|||
|
||||
# Package com.arsdigita.cms.ui.authoring
|
||||
# ======================================
|
||||
cms.ui.authoring.an_item_with_this_name_already_exists=Ein Dokument mit diesem Namen existiert bereits
|
||||
cms.ui.authoring.an_item_with_this_name_already_exists=Ein Dokument mit diesem Namen existiert bereits!
|
||||
cms.ui.authoring.bad_getblob_datatype=Ung\u00fcltiger Datentyp getBlob
|
||||
cms.ui.authoring.bad_getclob_datatype=Ung\u00fcltiger Datentyp getClob
|
||||
cms.ui.authoring.body=Textbereich:
|
||||
|
|
@ -1068,3 +1068,7 @@ cms.ui.change_password=Passwort \u00e4ndern
|
|||
cms.ui.image_select.page_title=Bild ausw\u00e4hlen oder hochladen
|
||||
cms.ui.image_library=Bildersammlung
|
||||
cms.ui.image_upload=Bild hochladen
|
||||
cms.ui.authoring.items_with_this_name_already_exist=Dokumentemitdiesem Namen existieren bereits. (ID: {0})
|
||||
cms.ui.authoring.parameter_not_empty=Dieser Parameter darf nicht leer sein.
|
||||
cms.ui.authoring.parameter_should_be_a_valid_filename=Dieser Parameter muss einem g\u00fcltigen Dateinamen entsprechen.
|
||||
cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods
|
||||
|
|
|
|||
|
|
@ -122,3 +122,7 @@ cms.ui.change_password=
|
|||
cms.ui.image_select.page_title=
|
||||
cms.ui.image_library=
|
||||
cms.ui.image_upload=
|
||||
cms.ui.authoring.items_with_this_name_already_exist=Items with whit name already exist. (Id: {0})
|
||||
cms.ui.authoring.parameter_not_empty=This parameter may not be empty.
|
||||
cms.ui.authoring.parameter_should_be_a_valid_filename=This parameter should be a valid filename.
|
||||
cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ cms.ui.no_items_matched_the_search=Pas d'\u00e9l\u00e9ment trouv\u00e9 dans la r
|
|||
|
||||
# Package com.arsdigita.cms.ui.authoring
|
||||
# ======================================
|
||||
cms.ui.authoring.an_item_with_this_name_already_exists=Un \u00e9l\u00e9ment de ce nom existe d\u00e9j\u00e0
|
||||
cms.ui.authoring.an_item_with_this_name_already_exists=Un \u00e9l\u00e9ment de ce nom existe d\u00e9j\u00e0!
|
||||
cms.ui.authoring.bad_getblob_datatype=TRANSLATE THIS: Bad getBlob datatype (cms.ui.authoring.bad_getblob_datatype)
|
||||
cms.ui.authoring.bad_getclob_datatype=TRANSLATE THIS: Bad getClob datatype (cms.ui.authoring.bad_getclob_datatype)
|
||||
cms.ui.authoring.body=Corsp de la page
|
||||
|
|
@ -596,3 +596,7 @@ cms.ui.change_password=
|
|||
cms.ui.image_select.page_title=
|
||||
cms.ui.image_library=
|
||||
cms.ui.image_upload=
|
||||
cms.ui.authoring.items_with_this_name_already_exist=Items with whit name already exist. (Id: {0})
|
||||
cms.ui.authoring.parameter_not_empty=This parameter may not be empty.
|
||||
cms.ui.authoring.parameter_should_be_a_valid_filename=This parameter should be a valid filename.
|
||||
cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods
|
||||
|
|
|
|||
|
|
@ -25,13 +25,12 @@ import com.arsdigita.persistence.DataQuery;
|
|||
|
||||
|
||||
/**
|
||||
* <p>Verifies that a specified {@link
|
||||
* com.arsdigita.persistence.DataQuery data query} has no results.
|
||||
* This is useful for making sure emails are unique in the
|
||||
* database.</p>
|
||||
* <p>Verifies that a specified
|
||||
* {@link com.arsdigita.persistence.DataQuery data query} has no results.
|
||||
* This is useful for making sure emails are unique in the database.</p>
|
||||
*
|
||||
* <p>Users of this class must override the method {@link
|
||||
* #getDataQuery} which specifies the data query to check.</p>
|
||||
* <p>Users of this class must override the method {@link #getDataQuery} which
|
||||
* specifies the data query to check.</p>
|
||||
*
|
||||
* @author Uday Mathur (umathur@arsdigita.com)
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
|
|
@ -40,6 +39,7 @@ import com.arsdigita.persistence.DataQuery;
|
|||
public abstract class DataQueryExistsListener
|
||||
implements FormValidationListener {
|
||||
|
||||
/** */
|
||||
protected String m_errorMsg;
|
||||
|
||||
|
||||
|
|
@ -50,8 +50,19 @@ public abstract class DataQueryExistsListener
|
|||
m_errorMsg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
public abstract DataQuery getDataQuery(FormSectionEvent event);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param event
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void validate(FormSectionEvent event) throws FormProcessException {
|
||||
DataQuery dq = getDataQuery(event);
|
||||
if ( dq.next() ) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ import java.util.Iterator;
|
|||
* extended to create forms for Brand subclasses.
|
||||
*/
|
||||
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
|
||||
* and set com.arsdigita.cms.contenttypes.ui.ContentGroupPropertyForm=DEBUG
|
||||
* by uncommenting or adding the line. */
|
||||
private final static org.apache.log4j.Logger s_log =
|
||||
org.apache.log4j.Logger.getLogger(ContentGroupPropertyForm.class);
|
||||
|
||||
|
|
@ -77,6 +82,7 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
/**
|
||||
* Adds widgets to the form.
|
||||
*/
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.content_group_name")));
|
||||
|
|
@ -87,6 +93,7 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.content_group_current_items")) {
|
||||
@Override
|
||||
public boolean isVisible(PageState state) {
|
||||
ContentGroupContainer item =
|
||||
(ContentGroupContainer) getItemSelectionModel()
|
||||
|
|
@ -97,6 +104,7 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
}
|
||||
});
|
||||
m_checkboxGroup = new CheckboxGroup(ASSOCIATED_ITEMS) {
|
||||
@Override
|
||||
public boolean isVisible(PageState state) {
|
||||
ContentGroupContainer item =
|
||||
(ContentGroupContainer) getItemSelectionModel()
|
||||
|
|
@ -122,7 +130,10 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
* Perform form initialization. Children should override this
|
||||
* this method to pre-fill the widgets with data, instantiate
|
||||
* the content item, etc.
|
||||
*
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void init(FormSectionEvent e) throws FormProcessException {
|
||||
s_log.debug("here in init");
|
||||
FormData data = e.getFormData();
|
||||
|
|
@ -154,7 +165,10 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
/**
|
||||
* Process the form. Children should override this method to save
|
||||
* the user's changes to the database.
|
||||
*
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
s_log.debug("here in process");
|
||||
ContentGroupContainer item =
|
||||
|
|
@ -190,9 +204,9 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
String[] values =
|
||||
(String[])m_checkboxGroup.getValue(e.getPageState());
|
||||
if (values != null) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
ids.remove(values[i]);
|
||||
s_log.debug("marking " + values[i] + " for keeping");
|
||||
for (String value : values) {
|
||||
ids.remove(value);
|
||||
s_log.debug("marking " + value + " for keeping");
|
||||
}
|
||||
}
|
||||
// now, we remove the itmes that were unselected
|
||||
|
|
@ -234,7 +248,9 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
* The name of the Content Type to restrict the ItemSearchWidget to.
|
||||
* To allow the user to search for any content type, this should
|
||||
* return null.
|
||||
**/
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getSearchContentType() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class GenericArticlePropertyForm extends BasicPageForm
|
|||
/**
|
||||
* Creates a new form to edit the Article object specified
|
||||
* by the item selection model passed in.
|
||||
*
|
||||
* @param itemModel The ItemSelectionModel to use to obtain the
|
||||
* Article to work on
|
||||
*/
|
||||
|
|
@ -52,6 +53,7 @@ public class GenericArticlePropertyForm extends BasicPageForm
|
|||
/**
|
||||
* Creates a new form to edit the GenericArticle object specified
|
||||
* by the item selection model passed in.
|
||||
*
|
||||
* @param itemModel The ItemSelectionModel to use to obtain the
|
||||
* GenericArticle to work on
|
||||
* @param step The GenericArticlePropertiesStep which controls this form.
|
||||
|
|
@ -76,14 +78,24 @@ public class GenericArticlePropertyForm extends BasicPageForm
|
|||
super.validate(e);
|
||||
}
|
||||
|
||||
/** Form initialisation hook. Fills widgets with data. */
|
||||
/**
|
||||
* Form initialisation hook. Fills widgets with data.
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) {
|
||||
// Do some initialization hook stuff
|
||||
FormData data = fse.getFormData();
|
||||
GenericArticle article = (GenericArticle) super.initBasicWidgets(fse);
|
||||
}
|
||||
|
||||
/** Cancels streamlined editing. */
|
||||
/**
|
||||
* Cancels streamlined editing.
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
@Override
|
||||
public void submitted(FormSectionEvent fse) {
|
||||
if (m_step != null
|
||||
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
|
||||
|
|
@ -91,7 +103,12 @@ public class GenericArticlePropertyForm extends BasicPageForm
|
|||
}
|
||||
}
|
||||
|
||||
/** Form processing hook. Saves Event object. */
|
||||
/**
|
||||
* Form processing hook. Saves Event object.
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) {
|
||||
FormData data = fse.getFormData();
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ public abstract class BaseForm extends Form
|
|||
addSubmissionListener(new FormSecurityListener(action, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled(final PageState state) {
|
||||
return m_cancel != null && m_cancel.isSelected(state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ import com.arsdigita.cms.ui.util.UniqueStringValidationListener;
|
|||
|
||||
|
||||
/**
|
||||
* Ensures that the name of the item is unique by resolving the
|
||||
* would-be URL of the item. If an item already "exists" at the URL in the
|
||||
* current context, then the name is invalid.
|
||||
* Ensures that the name of the item is unique by resolving the would-be URL
|
||||
* of the item. If an item already "exists" at the URL in the current context,
|
||||
* then the name is invalid.
|
||||
*
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
|
|
@ -71,6 +71,7 @@ public class UniqueItemNameValidationListener
|
|||
* @param value The submitted string value
|
||||
* @return true if the string value is unique, false otherwise
|
||||
*/
|
||||
@Override
|
||||
protected boolean isUnique(PageState state, String value) {
|
||||
|
||||
// Fetch the current content section.
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import com.arsdigita.cms.Folder;
|
|||
import com.arsdigita.cms.ItemCollection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import static com.arsdigita.cms.util.GlobalizationUtil.globalize;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
|
|
@ -55,17 +56,21 @@ import java.util.Collection;
|
|||
*
|
||||
* @author Stanislav Freidin (stas@arsdigita.com)
|
||||
* @version $Revision: #13 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
*
|
||||
*/
|
||||
public abstract class BasicItemForm extends FormSection
|
||||
implements FormInitListener,
|
||||
FormProcessListener,
|
||||
FormValidationListener {
|
||||
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.cms.ui.BasicItemForm=DEBUG
|
||||
* by uncommenting or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(BasicItemForm.class);
|
||||
|
||||
private final ItemSelectionModel m_itemModel;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private FormSection m_widgetSection;
|
||||
private final FormSection m_widgetSection;
|
||||
public static final String CONTENT_ITEM_ID = ContentItem.ID;
|
||||
public static final String NAME = ContentItem.NAME;
|
||||
public static final String TITLE = ContentPage.TITLE;
|
||||
|
|
@ -73,14 +78,11 @@ public abstract class BasicItemForm extends FormSection
|
|||
|
||||
/**
|
||||
* Construct a new BasicItemForm with 2 ColumnPanels and add basic content.
|
||||
*
|
||||
* The left Panel is used for Labels, the right Panel for values.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param formName the name of this form
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be responsible for loading the
|
||||
* current item
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be responsible
|
||||
* for loading the current item
|
||||
*/
|
||||
public BasicItemForm(String formName, ItemSelectionModel itemModel) {
|
||||
super(new ColumnPanel(2));
|
||||
|
|
@ -110,12 +112,13 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Construct a new BasicItemForm with a specified number of ColumnPanels and without any content
|
||||
* Construct a new BasicItemForm with a specified number of ColumnPanels
|
||||
* and without any content.
|
||||
*
|
||||
* @param formName the name of this form
|
||||
* @param columnPanel the columnpanel of the form
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be responsible for loading the
|
||||
* current item
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be
|
||||
* responsible for loading the current item
|
||||
*/
|
||||
public BasicItemForm(String formName,
|
||||
ColumnPanel columnPanel,
|
||||
|
|
@ -139,23 +142,22 @@ public abstract class BasicItemForm extends FormSection
|
|||
/**
|
||||
* Currently, to insert javascript code the Label Widget is "abused".
|
||||
*/
|
||||
private Label m_script = new Label(
|
||||
private final Label m_script = new Label(
|
||||
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>",
|
||||
false);
|
||||
|
||||
/**
|
||||
* Add basic widgets to the form.
|
||||
*
|
||||
* Widgets added are 'title' and 'name (url)' which are part of any content item. Child classes
|
||||
* will override this method to perform all their widget-adding needs but may use super() to add
|
||||
* the basic widgets.
|
||||
* Widgets added are 'title' and 'name (url)' which are part of any
|
||||
* content item. Child classes will override this method to perform all
|
||||
* their widget-adding needs but are supposed to use super() to add the
|
||||
* basic widgets.
|
||||
*/
|
||||
protected void addWidgets() {
|
||||
//add(new FormErrorDisplay(this), ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||
|
||||
//add(new Label("id"));
|
||||
final Hidden id = new Hidden(CONTENT_ITEM_ID);
|
||||
//final TextField id = new TextField(CONTENT_ITEM_ID);
|
||||
add(id);
|
||||
|
||||
// JavaScript auto-name generation is off by default.
|
||||
|
|
@ -175,6 +177,8 @@ public abstract class BasicItemForm extends FormSection
|
|||
// (jensp 2011-01-28)
|
||||
add(new Label(getTitleLabel()));
|
||||
final TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE));
|
||||
titleWidget.setLabel(getTitleLabel());
|
||||
titleWidget.setHint(getTitleHint());
|
||||
titleWidget.addValidationListener(new NotNullValidationListener());
|
||||
titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { "
|
||||
+ " defaulting = true; this.form." + NAME
|
||||
|
|
@ -182,8 +186,6 @@ public abstract class BasicItemForm extends FormSection
|
|||
titleWidget.setOnKeyUp(
|
||||
"if (defaulting) { this.form." + NAME
|
||||
+ ".value = urlize(this.value) }");
|
||||
titleWidget.setLabel(getTitleLabel());
|
||||
titleWidget.setHint(getTitleHint());
|
||||
add(titleWidget);
|
||||
|
||||
// For some content types it may be useful to change the label of
|
||||
|
|
@ -192,6 +194,9 @@ public abstract class BasicItemForm extends FormSection
|
|||
// (jensp 2011-01-28)
|
||||
add(new Label(getNameLabel()));
|
||||
final TextField nameWidget = new TextField(new TrimmedStringParameter(NAME));
|
||||
nameWidget.setLabel(getNameLabel());
|
||||
nameWidget.setHint(getNameHint());
|
||||
nameWidget.addValidationListener(new NotNullValidationListener());
|
||||
nameWidget.addValidationListener(new NameValidationListener());
|
||||
nameWidget.setMaxLength(190);
|
||||
nameWidget.setOnFocus("defaulting = false");
|
||||
|
|
@ -199,8 +204,6 @@ public abstract class BasicItemForm extends FormSection
|
|||
"if (this.value == '') "
|
||||
+ "{ defaulting = true; this.value = urlize(this.form." + TITLE
|
||||
+ ".value) } " + " else { this.value = urlize(this.value); }");
|
||||
nameWidget.addValidationListener(new NotNullValidationListener());
|
||||
nameWidget.setHint(getNameHint());
|
||||
add(nameWidget);
|
||||
|
||||
}
|
||||
|
|
@ -226,43 +229,48 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Perform form initialization. Children should override this this method to pre-fill the
|
||||
* widgets with data, instantiate the content item, etc.
|
||||
* Perform form initialization. Children should override this this method
|
||||
* to pre-fill the widgets with data, instantiate the content item, etc.
|
||||
*
|
||||
* @param e
|
||||
*
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public abstract void init(FormSectionEvent e) throws FormProcessException;
|
||||
|
||||
/**
|
||||
* Process the form. Children should override this method to save the user's changes to the
|
||||
* database.
|
||||
* Process the form. Children have to override this method to save the
|
||||
* user's changes to the database.
|
||||
*
|
||||
* @param e
|
||||
*
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public abstract void process(FormSectionEvent e) throws FormProcessException;
|
||||
|
||||
/**
|
||||
* Validate the form. Children should override this method to provide custom form validation.
|
||||
* Validate the form. Children should override this method to provide
|
||||
* custom form validation.
|
||||
*
|
||||
* @param e
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensure that the name of an item is unique within a folder. A "New item" form should call this
|
||||
* method in the validation listener.
|
||||
* Ensure that the name of an item is unique within a folder.
|
||||
* A "New item" form should call this method in the validation listener.
|
||||
*
|
||||
* @param parent the folder in which to check
|
||||
* @param event the {@link FormSectionEvent} which was passed to the validation listener
|
||||
* @param event the {@link FormSectionEvent} which was passed to the
|
||||
* validation listener
|
||||
*
|
||||
* @throws FormProcessException if the folder already contains an item with the name the user
|
||||
* provided on the input form.
|
||||
* @throws FormProcessException if the folder already contains an item
|
||||
* with the name the use provided on the input form.
|
||||
*/
|
||||
public void validateNameUniqueness(Folder parent, FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
|
@ -281,14 +289,18 @@ public abstract class BasicItemForm extends FormSection
|
|||
*
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
public void validateNameUniqueness(Folder parent, FormSectionEvent event,
|
||||
public void validateNameUniqueness(Folder parent,
|
||||
FormSectionEvent event,
|
||||
String newName)
|
||||
throws FormProcessException {
|
||||
|
||||
if (newName != null) {
|
||||
final String query = "com.arsdigita.cms.validateUniqueItemName";
|
||||
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
|
||||
dq.setParameter("parentId", parent.getID());
|
||||
dq.setParameter("name", newName.toUpperCase());
|
||||
FormData data = event.getFormData();
|
||||
|
||||
|
||||
if (dq.size() > 0) {
|
||||
// we need to add all of the items that are
|
||||
|
|
@ -299,25 +311,34 @@ public abstract class BasicItemForm extends FormSection
|
|||
|
||||
ContentItem item = null;
|
||||
if (getItemSelectionModel() != null) {
|
||||
item = (ContentItem) getItemSelectionModel().
|
||||
getSelectedObject(event.getPageState());
|
||||
item = (ContentItem) getItemSelectionModel()
|
||||
.getSelectedObject(event.getPageState());
|
||||
}
|
||||
if (item == null) {
|
||||
// this means it is a creation form
|
||||
// throw new FormProcessException(
|
||||
// "An item with this name already exists");
|
||||
data.addError(globalize(
|
||||
"cms.ui.authoring.an_item_with_this_name_already_exists"));
|
||||
throw new FormProcessException(
|
||||
"cms.ui.authoring.an_item_with_this_name_already_exists");
|
||||
"An item with this name already exists",
|
||||
globalize("cms.ui.authoring.an_item_with_this_name_already_exists"
|
||||
)
|
||||
);
|
||||
}
|
||||
Collection list = getAllVersionIDs(item);
|
||||
while (dq.next()) {
|
||||
itemID = (BigDecimal) dq.get("itemID");
|
||||
if (!list.contains(itemID)) {
|
||||
String[] itemObj=new String[1];
|
||||
itemObj[0]=itemID.toString();
|
||||
dq.close();
|
||||
// throw new FormProcessException(
|
||||
// "An item with this name already exists");
|
||||
data.addError(globalize(
|
||||
"cms.ui.authoring.an_item_with_this_name_already_exists"));
|
||||
throw new FormProcessException(
|
||||
"cms.ui.authoring.an_item_with_this_name_already_exists");
|
||||
"An item with this name already exists",
|
||||
globalize(
|
||||
"cms.ui.authoring.items_with_this_name_already_exist",
|
||||
itemObj)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -325,14 +346,15 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Ensure that the name of an item is unique within a category. This should only be called from
|
||||
* the validation listener of an "edit" form.
|
||||
* Ensure that the name of an item is unique within a category. This should
|
||||
* only be called from the validation listener of an "edit" form.
|
||||
*
|
||||
* @param event the {@link FormSectionEvent} which was passed to the validation listener
|
||||
* @param event the {@link FormSectionEvent} which was passed to the
|
||||
* validation listener
|
||||
* @param id The id of the item that is being checked. This must no be null.
|
||||
*
|
||||
* @throws FormProcessException if the folder already contains an item with the name the user
|
||||
* provided on the input form.
|
||||
* @throws FormProcessException if the folder already contains an item with
|
||||
* the name the user provided on the input form.
|
||||
*/
|
||||
public void validateNameUniquenessWithinCategory(FormSectionEvent event,
|
||||
BigDecimal id)
|
||||
|
|
@ -361,18 +383,25 @@ public abstract class BasicItemForm extends FormSection
|
|||
// pending or live version of the same item
|
||||
BigDecimal itemID = null;
|
||||
|
||||
ContentItem item = (ContentItem) getItemSelectionModel().getSelectedObject(event.
|
||||
getPageState());
|
||||
ContentItem item = (ContentItem)getItemSelectionModel()
|
||||
.getSelectedObject(event.getPageState());
|
||||
Collection list = getAllVersionIDs(item);
|
||||
try {
|
||||
while (query.next()) {
|
||||
itemID = (BigDecimal) query.get("itemID");
|
||||
if (!list.contains(itemID)) {
|
||||
StringBuffer buffer = new StringBuffer((String) GlobalizationUtil
|
||||
.globalize("cms.ui.authoring.error_conflicts_with_this_url")
|
||||
.localize());
|
||||
buffer.append(url);
|
||||
throw new FormProcessException(buffer.toString());
|
||||
// StringBuffer buffer = new StringBuffer((String) GlobalizationUtil
|
||||
// .globalize("cms.ui.authoring.error_conflicts_with_this_url")
|
||||
// .localize());
|
||||
// buffer.append(url);
|
||||
String[] urlObj=new String[1];
|
||||
urlObj[0]=url;
|
||||
throw new FormProcessException(
|
||||
"Error: Conflict with url: "+url,
|
||||
globalize(
|
||||
"cms.ui.authoring.error_conflicts_with_this_url",
|
||||
urlObj)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -411,14 +440,13 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a component with the specified layout constraints to this container. Layout constraints
|
||||
* are defined in each layout container as static ints. Use a bitwise OR to specify multiple
|
||||
* constraints.
|
||||
* Adds a component with the specified layout constraints to this container.
|
||||
* Layout constraints are defined in each layout container as static ints.
|
||||
* Use a bitwise OR to specify multiple constraints.
|
||||
*
|
||||
* @param pc the component to add to this container
|
||||
*
|
||||
* @param constraints layout constraints (a bitwise OR of static ints in the particular layout)
|
||||
*
|
||||
* @param constraints layout constraints (a bitwise OR of static ints in
|
||||
* the particular layout)
|
||||
*/
|
||||
@Override
|
||||
public void add(Component pc, int constraints) {
|
||||
|
|
@ -426,10 +454,11 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* jensp, 2011-01-28 This method can be overridden to change the label of the title field. To
|
||||
* change to label of the title field can be useful for some content types. For example, for an
|
||||
* organization the label "Title" for the field is may confusing for the normal user. For such a
|
||||
* content type, the label would be changed to something like "Name of the organization".
|
||||
* This method can be overridden to change the label of the title field. To
|
||||
* change to label of the title field can be useful for some content types.
|
||||
* For example, for an organization the label "Title" for the field may be
|
||||
* confusing for the normal user. For such a content type, the label would
|
||||
* be changed to something like "Name of the organization".
|
||||
*
|
||||
* @return (Content for the) Label for the title field as string
|
||||
*/
|
||||
|
|
@ -438,9 +467,8 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Provides the text for the user hint providing some detailed information how to use this
|
||||
* widget.
|
||||
*
|
||||
* Provides the text for the user hint providing some detailed information
|
||||
* how to use this widget.
|
||||
* This method can be overwritten to adjust the text for some content types.
|
||||
* {@link #getTitleLabel()}
|
||||
*
|
||||
|
|
@ -451,8 +479,8 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* jensp, 2011-01-28 This method does the same as {@link #getTitleLabel() } for the label of the
|
||||
* name (URL) field.
|
||||
* This method does the same as {@link #getTitleLabel() } for the labe
|
||||
*l of the name (URL) field.
|
||||
*
|
||||
* @return (Content for the) Label for the name field as string
|
||||
*/
|
||||
|
|
@ -461,9 +489,8 @@ public abstract class BasicItemForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Provides the text for the unser hint providing some detailed information how to use this
|
||||
* widget.
|
||||
*
|
||||
* Provides the text for the unser hint providing some detailed information
|
||||
* how to use this widget.
|
||||
* This method can be overwritten to adjust the text for some content types.
|
||||
* {@link #getNameLabel()}
|
||||
*
|
||||
|
|
|
|||
|
|
@ -206,7 +206,9 @@ public abstract class BasicPageForm extends BasicItemForm {
|
|||
* form. See {@link PageCreate} for an example.
|
||||
*
|
||||
* @param state the current page state
|
||||
* @return the new content item (or a proper subclass thereof) @pre state != null @post return != null
|
||||
* @return the new content item (or a proper subclass thereof)
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
* @pre state != null @post return != null
|
||||
*/
|
||||
public ContentPage createContentPage(PageState state)
|
||||
throws FormProcessException {
|
||||
|
|
@ -220,8 +222,12 @@ public abstract class BasicPageForm extends BasicItemForm {
|
|||
try {
|
||||
item = (ContentPage) m.createItem();
|
||||
} catch (ServletException ex) {
|
||||
throw new FormProcessException((String) GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.couldnt_create_contentpage").localize(), ex);
|
||||
throw new FormProcessException(
|
||||
"Couldn't create contentpage",
|
||||
GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.couldnt_create_contentpage"),
|
||||
ex
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure the item will be remembered across requests
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public class ItemCategoryStep extends SimpleContainer
|
|||
add(m_add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
|
||||
|
|
@ -109,6 +110,7 @@ public class ItemCategoryStep extends SimpleContainer
|
|||
p.addGlobalStateParam(m_mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(PageState state) {
|
||||
state.setValue(m_root, null);
|
||||
state.setValue(m_mode, null);
|
||||
|
|
@ -128,6 +130,7 @@ public class ItemCategoryStep extends SimpleContainer
|
|||
m_mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
|
||||
|
|
@ -147,6 +150,7 @@ public class ItemCategoryStep extends SimpleContainer
|
|||
}
|
||||
|
||||
private class ResetListener implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
reset(state);
|
||||
|
|
@ -159,6 +163,7 @@ public class ItemCategoryStep extends SimpleContainer
|
|||
public ExtensionListener(int i) {
|
||||
extensionIndex = i;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
m_summary.setVisible(state, false);
|
||||
|
|
|
|||
|
|
@ -21,49 +21,60 @@ package com.arsdigita.cms.ui.authoring;
|
|||
import com.arsdigita.bebop.event.ParameterEvent;
|
||||
import com.arsdigita.bebop.event.ParameterListener;
|
||||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import org.apache.log4j.Logger;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Verifies that the parameter is a valid filename, is not null, and
|
||||
* contains no reserved characters.
|
||||
* Verifies that the parameter is a valid filenamersp. URL stub, is not null,
|
||||
* and contains no reserved characters.
|
||||
*
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @author Peter Boy <pb@zes.uni-bremen.de>
|
||||
* @version $Id: NameValidationListener.java 2090 2010-04-17 08:04:14Z pboy $
|
||||
*/
|
||||
public class NameValidationListener implements ParameterListener {
|
||||
|
||||
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.cms.ui.authoring.NameValidationListener=DEBUG
|
||||
* by uncommenting or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(NameValidationListener.class);
|
||||
|
||||
// Why is this protected? XXX
|
||||
protected String label;
|
||||
/**
|
||||
* Default Constructor, creates a new <code>NameValidationListener</code>.
|
||||
*/
|
||||
public NameValidationListener() {
|
||||
|
||||
// XXX this stuff needs globalization
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>NameValidationListener</code>.
|
||||
*
|
||||
* @param label the label for the error message
|
||||
* @deprecated with no replacement. Does nothing anymore.
|
||||
*/
|
||||
public NameValidationListener(final String label) {
|
||||
this.label = label;
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>NameValidationListener</code>.
|
||||
* Validate the input field as passed in by ParameterEvent.
|
||||
*
|
||||
* @param e ParameterEvent containing input data.
|
||||
*/
|
||||
public NameValidationListener() {
|
||||
this("This parameter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final ParameterEvent e) {
|
||||
final ParameterData data = e.getParameterData();
|
||||
final Object value = data.getValue();
|
||||
|
||||
if (value == null || value.toString().length() < 1) {
|
||||
data.addError(label + " may not be null");
|
||||
data.addError(GlobalizationUtil
|
||||
.globalize("cms.ui.authoring.parameter_not_empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -76,12 +87,14 @@ public class NameValidationListener implements ParameterListener {
|
|||
final String token = tok.nextToken();
|
||||
|
||||
if (!token.equals(text)) {
|
||||
data.addError(label + " should be a valid filename");
|
||||
data.addError(GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.parameter_should_be_a_valid_filename"));
|
||||
}
|
||||
}
|
||||
|
||||
if (text.indexOf(".") != -1) {
|
||||
data.addError(label + " may not contain periods");
|
||||
data.addError(GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.parameter_should_be_a_valid_filename"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.arsdigita.cms.ItemSelectionModel;
|
|||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.util.Assert;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -66,12 +67,11 @@ public class PageCreate extends BasicPageForm
|
|||
*
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be
|
||||
* responsible for loading the current item
|
||||
*
|
||||
* @param parent The {@link CreationSelector} parent. This class
|
||||
* should call either the {@link
|
||||
* CreationSelector#redirectBack(PageState)} or {@link
|
||||
* CreationSelector#editItem(PageState, ContentItem)} methods on
|
||||
* the parent eventually
|
||||
* CreationSelector#editItem(PageState, ContentItem)}
|
||||
* methods on the parent eventually
|
||||
*/
|
||||
public PageCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
|
|
@ -114,21 +114,27 @@ public class PageCreate extends BasicPageForm
|
|||
*
|
||||
* @return the ApplyWorkflowFormSection associated with this CreationComponent.
|
||||
*/
|
||||
@Override
|
||||
public ApplyWorkflowFormSection getWorkflowSection() {
|
||||
return m_workflowSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new item id.
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void init(FormSectionEvent e) throws FormProcessException {
|
||||
// this is currently a no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Cancel button was pressed, hide self and
|
||||
* show the display component
|
||||
* If the Cancel button was pressed, hide self and show the display
|
||||
* component.
|
||||
*
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui.authoring;
|
||||
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
|
|
@ -33,10 +32,8 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
|
|||
import com.arsdigita.bebop.event.FormValidationListener;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.Hidden;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.AuthoringKit;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
|
|
@ -56,11 +53,7 @@ import com.arsdigita.cms.util.GlobalizationUtil;
|
|||
import com.arsdigita.dispatcher.MultipartHttpServletRequest;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.formbuilder.PersistentComponent;
|
||||
import com.arsdigita.formbuilder.PersistentForm;
|
||||
import com.arsdigita.metadata.DynamicObjectType;
|
||||
import com.arsdigita.mimetypes.ImageMimeType;
|
||||
import com.arsdigita.persistence.DataAssociationCursor;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
|
|
@ -70,7 +63,7 @@ import com.arsdigita.persistence.metadata.MetadataRoot;
|
|||
import com.arsdigita.persistence.metadata.ObjectType;
|
||||
import com.arsdigita.persistence.metadata.Property;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
|
@ -80,14 +73,13 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.TooManyListenersException;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* The creation component for user-defined content items
|
||||
* The creation component for user-defined content items.
|
||||
*
|
||||
* TODO: subclass PageCreate now that this no longer extends MetaForm?
|
||||
*/
|
||||
|
|
@ -343,6 +335,7 @@ public class PageCreateDynamic extends FormSection
|
|||
/**
|
||||
* instanciate and add the save/cancel section for this form
|
||||
*/
|
||||
@Override
|
||||
public void addSaveCancelSection() {
|
||||
if (m_parentComponent != null) {
|
||||
m_parentComponent.addSaveCancelSection();
|
||||
|
|
@ -352,6 +345,7 @@ public class PageCreateDynamic extends FormSection
|
|||
/**
|
||||
* @return the save/cancel section for this form
|
||||
*/
|
||||
@Override
|
||||
public SaveCancelSection getSaveCancelSection() {
|
||||
if (m_parentComponent != null) {
|
||||
return m_parentComponent.getSaveCancelSection();
|
||||
|
|
@ -365,6 +359,7 @@ public class PageCreateDynamic extends FormSection
|
|||
*
|
||||
* @return the ApplyWorkflowFormSection associated with this CreationComponent.
|
||||
*/
|
||||
@Override
|
||||
public ApplyWorkflowFormSection getWorkflowSection() {
|
||||
if (m_parentComponent != null) {
|
||||
return m_parentComponent.getWorkflowSection();
|
||||
|
|
@ -373,14 +368,18 @@ public class PageCreateDynamic extends FormSection
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent e) throws FormProcessException {
|
||||
// this is currently a no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* Submission: If the Cancel button was pressed, hide self and
|
||||
* show the display component
|
||||
* show the display component.
|
||||
*
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
||||
|
|
@ -393,8 +392,12 @@ public class PageCreateDynamic extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate: ensure name uniqueness
|
||||
* Validate: ensure name uniqueness.
|
||||
*
|
||||
* @param e
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||
Folder f = m_parent.getFolder(e.getPageState());
|
||||
Assert.exists(f);
|
||||
|
|
@ -402,8 +405,12 @@ public class PageCreateDynamic extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Process: save fields to the database
|
||||
* Process: save fields to the database.
|
||||
*
|
||||
* @param e
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
FormData data = e.getFormData();
|
||||
PageState state = e.getPageState();
|
||||
|
|
@ -590,11 +597,16 @@ public class PageCreateDynamic extends FormSection
|
|||
* @throws FormProcessException if the folder already contains an item
|
||||
* with the name the user provided on the input form.
|
||||
*/
|
||||
public void validateNameUniqueness(Folder parent, FormSectionEvent e) throws FormProcessException {
|
||||
public void validateNameUniqueness(Folder parent, FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
FormData data = e.getFormData();
|
||||
|
||||
if ( parent.getItem((String) data.get(NAME), false) != null ) {
|
||||
throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.authoring.an_item_with_this_name_already_exists").localize());
|
||||
throw new FormProcessException(
|
||||
"An Item with his name already exists",
|
||||
GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.an_item_with_this_name_already_exists")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -605,6 +617,7 @@ public class PageCreateDynamic extends FormSection
|
|||
*
|
||||
* @param state the current page state
|
||||
* @return the new content item (or a proper subclass thereof)
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
* @pre state != null
|
||||
* @post return != null
|
||||
*/
|
||||
|
|
@ -718,6 +731,7 @@ public class PageCreateDynamic extends FormSection
|
|||
*
|
||||
* @param pc the component to add to this BasicPageForm
|
||||
* */
|
||||
@Override
|
||||
public void add(Component pc) {
|
||||
if (m_parentComponent != null) {
|
||||
m_parentComponent.add(pc);
|
||||
|
|
@ -732,10 +746,10 @@ public class PageCreateDynamic extends FormSection
|
|||
* static ints. Use a bitwise OR to specify multiple constraints.
|
||||
*
|
||||
* @param pc the component to add to this container
|
||||
*
|
||||
* @param constraints layout constraints (a
|
||||
* bitwise OR of static ints in the particular layout)
|
||||
* */
|
||||
* @param constraints layout constraints (a bitwise OR of static ints
|
||||
* in the particular layout)
|
||||
*/
|
||||
@Override
|
||||
public void add(Component pc, int constraints) {
|
||||
if (m_parentComponent != null) {
|
||||
m_parentComponent.add(pc, constraints);
|
||||
|
|
|
|||
|
|
@ -120,12 +120,24 @@ public class PageEdit extends SimpleEditStep {
|
|||
super("PageEditForm", itemModel);
|
||||
}
|
||||
|
||||
// Init: load the item and preset the widgets
|
||||
/**
|
||||
* Load the item and preset the widgets.
|
||||
*
|
||||
* @param e
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void init(FormSectionEvent e) throws FormProcessException {
|
||||
super.initBasicWidgets(e);
|
||||
}
|
||||
|
||||
// Process: save fields to the database
|
||||
/**
|
||||
* Process the entry data, specifically save fields to the database.
|
||||
*
|
||||
* @param e
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
ContentPage item = (ContentPage)super.processBasicWidgets(e);
|
||||
|
|
@ -134,6 +146,7 @@ public class PageEdit extends SimpleEditStep {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent event) throws FormProcessException {
|
||||
super.validate(event);
|
||||
|
||||
|
|
|
|||
|
|
@ -202,11 +202,10 @@ public class SimpleEditStep extends SecurityPropertyEditor
|
|||
}
|
||||
|
||||
/**
|
||||
* Open the edit component if the streamlined
|
||||
* creation parameter is turned on _and_ the streamlined_creation
|
||||
* global state param is set to 'active'
|
||||
* Open the edit component if the streamlined creation parameter is turned
|
||||
* on _and_ the streamlined_creation global state param is set to 'active'
|
||||
*
|
||||
* @param state the PageState
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void pageRequested(RequestEvent e) {
|
||||
|
|
@ -265,6 +264,7 @@ public class SimpleEditStep extends SecurityPropertyEditor
|
|||
* @return A String representation of the retrieved boolean
|
||||
* attribute of the domain object.
|
||||
*/
|
||||
@Override
|
||||
public String format(DomainObject obj, String attribute, PageState state) {
|
||||
|
||||
if ( obj != null && obj instanceof ContentPage) {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class EditKit extends Form
|
|||
protected SaveCancelSection m_saveCancelSection;
|
||||
|
||||
/**
|
||||
* @param types The content type selection model. This is to tell the form
|
||||
* @param type The content type selection model. This is to tell the form
|
||||
* which content type is selected.
|
||||
*/
|
||||
public EditKit(ContentTypeRequestLocal type) {
|
||||
|
|
@ -87,6 +87,7 @@ public class EditKit extends Form
|
|||
addProcessListener(this);
|
||||
addInitListener(this);
|
||||
addSubmissionListener(new FormSubmissionListener() {
|
||||
@Override
|
||||
public void submitted(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
|
@ -134,7 +135,9 @@ public class EditKit extends Form
|
|||
|
||||
/**
|
||||
* Form init listener which initializes form values.
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void init(FormSectionEvent e) {
|
||||
FormData data = e.getFormData();
|
||||
PageState state = e.getPageState();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ public abstract class UniqueStringValidationListener
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param widget
|
||||
*/
|
||||
public UniqueStringValidationListener(Widget widget) {
|
||||
this(widget, null);
|
||||
|
|
@ -76,8 +78,10 @@ public abstract class UniqueStringValidationListener
|
|||
* then the name is invalid.
|
||||
*
|
||||
* @param event The form section event
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
* @pre ( event != null )
|
||||
*/
|
||||
@Override
|
||||
public final void validate(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public class GlobalizationUtil implements Globalized {
|
|||
/**
|
||||
* Returns a globalized message using the package specific bundle,
|
||||
* provided by BUNDLE_NAME.
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
|
|
@ -48,6 +50,9 @@ public class GlobalizationUtil implements Globalized {
|
|||
* Returns a globalized message object, using the package specific bundle,
|
||||
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
|
||||
* interpolate into the retrieved message using the MessageFormat class.
|
||||
* @param key
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key, Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
|
|
|
|||
|
|
@ -93,3 +93,5 @@ bebop.are_you_sure=Are you sure?
|
|||
bebop.the_model_is_empty=The Model is Empty
|
||||
bebop.save=Save
|
||||
bebop.cancel=Cancel
|
||||
bebop.cancel.msg=Submission Cancelled
|
||||
bebop.parameter.unexpected_value_type=Unexpected value type: {0}
|
||||
|
|
@ -93,3 +93,5 @@ bebop.are_you_sure=Sind Sie sicher?
|
|||
bebop.the_model_is_empty=The Model is Empty
|
||||
bebop.save=Speichern
|
||||
bebop.cancel=Abbrechen
|
||||
bebop.cancel.msg=Bearbeitung abgebrochen
|
||||
bebop.parameter.unexpected_value_type=Unerwarteter Typ des Wertes: {0}
|
||||
|
|
@ -93,3 +93,5 @@ bebop.are_you_sure=TRANSLATE THIS: Are you sure? (bebop.are_you_sure)
|
|||
bebop.the_model_is_empty=TRANSLATE THIS: The Model is Empty (bebop.the_model_is_empty)
|
||||
bebop.save=TRANSLATE THIS: Previous (bebop.save)
|
||||
bebop.cancel=TRANSLATE THIS: Previous (bebop.cancel)
|
||||
bebop.cancel.msg=TRANSLATE THIS: Previous (bebop.cancel.submission.msg)
|
||||
bebop.parameter.unexpected_value_type=Unexpected value type: {0}
|
||||
|
|
@ -350,6 +350,7 @@ public class FormData implements Map, Cloneable {
|
|||
*
|
||||
* @pre name != null
|
||||
* @pre message != null
|
||||
* @deprecated use addError(String name, GlobalizedMessage message) instead
|
||||
*/
|
||||
public void addError(String name, String message) {
|
||||
|
||||
|
|
@ -459,11 +460,13 @@ public class FormData implements Map, Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
seekToNextError();
|
||||
return paramErrors.hasNext() || formErrors.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object next() throws NoSuchElementException {
|
||||
|
||||
seekToNextError();
|
||||
|
|
@ -475,6 +478,7 @@ public class FormData implements Map, Cloneable {
|
|||
return formErrors.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
@ -493,9 +497,11 @@ public class FormData implements Map, Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the ParameterData object identified by the name in this FormData Object.
|
||||
* Sets the ParameterData object identified by the name in this FormData
|
||||
* Object.
|
||||
*
|
||||
* @param name the name of the parameterModel
|
||||
* @param value
|
||||
*/
|
||||
public void setParameter(String name, ParameterData value) {
|
||||
m_parameterDataValues.put(name,value);
|
||||
|
|
@ -512,9 +518,9 @@ public class FormData implements Map, Cloneable {
|
|||
|
||||
/**
|
||||
* Determines whether this request represents a submission event.
|
||||
*
|
||||
* @return <code>true</code> if this request represents a submission event;
|
||||
* <code>false</code> if it represents an initialization event.
|
||||
*
|
||||
*/
|
||||
public final boolean isSubmission() {
|
||||
return m_isSubmission;
|
||||
|
|
@ -523,8 +529,9 @@ public class FormData implements Map, Cloneable {
|
|||
/**
|
||||
* Determines whether the key-value string pairs in the
|
||||
* request have been transformed into Java data objects.
|
||||
* @return <code>true</code> if the key-value string pairs
|
||||
* have been transformed into Java data objects;
|
||||
*
|
||||
* @return <code>true</code> if the key-value string pairs have been
|
||||
* transformed into Java data objects;
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
*/
|
||||
|
|
@ -630,14 +637,17 @@ public class FormData implements Map, Cloneable {
|
|||
|
||||
// --- Public methods to satisfy Map interface ---
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return m_parameterDataValues.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
// this is very expensive with ParameterData
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
@ -647,6 +657,7 @@ public class FormData implements Map, Cloneable {
|
|||
* This is just plain wrong. Either you pretend to be a Map of
|
||||
* things, or you are a Map of ParameterData-s.
|
||||
*/
|
||||
@Override
|
||||
public Set entrySet() {
|
||||
return m_parameterDataValues.entrySet();
|
||||
}
|
||||
|
|
@ -660,6 +671,7 @@ public class FormData implements Map, Cloneable {
|
|||
* @throws java.lang.IllegalArgumentException thrown when the key
|
||||
* is not a valid parameter.
|
||||
*/
|
||||
@Override
|
||||
public Object get(Object key) throws IllegalArgumentException {
|
||||
|
||||
ParameterData p = getParameter((String)key);
|
||||
|
|
@ -671,6 +683,8 @@ public class FormData implements Map, Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param m
|
||||
* @return
|
||||
* @deprecated Use get(m.getName()) instead, and then manually check
|
||||
* for model identity
|
||||
*/
|
||||
|
|
@ -712,14 +726,17 @@ public class FormData implements Map, Cloneable {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return m_parameterDataValues.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set keySet() {
|
||||
return m_parameterDataValues.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object put(Object key, Object value) {
|
||||
Object previousValue = get(key);
|
||||
setParameterValue((String)key, value);
|
||||
|
|
@ -727,6 +744,7 @@ public class FormData implements Map, Cloneable {
|
|||
return previousValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map t) {
|
||||
for (Iterator i = t.keySet().iterator(); i.hasNext(); ) {
|
||||
String key = (String) i.next();
|
||||
|
|
@ -735,18 +753,32 @@ public class FormData implements Map, Cloneable {
|
|||
m_isValid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return m_parameterDataValues.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection values() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
FormData result = (FormData) super.clone();
|
||||
result.m_parameterDataValues = new HashMap();
|
||||
|
|
@ -764,8 +796,9 @@ public class FormData implements Map, Cloneable {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
for (Iterator i = getAllErrors(); i.hasNext();) {
|
||||
s.append(i.next()).append(System.getProperty("line.separator"));
|
||||
|
|
@ -777,11 +810,12 @@ public class FormData implements Map, Cloneable {
|
|||
/**
|
||||
* Converts to a String.
|
||||
* The method {@link #toString()} returns all errors.
|
||||
*
|
||||
* @return a human-readable representation of <code>this</code>.
|
||||
*/
|
||||
public String asString() {
|
||||
String newLine = System.getProperty("line.separator");
|
||||
StringBuffer to = new StringBuffer();
|
||||
StringBuilder to = new StringBuilder();
|
||||
to.append(super.toString() + " = {" + newLine);
|
||||
//Map
|
||||
to.append("m_parameterDataValues = ")
|
||||
|
|
|
|||
|
|
@ -18,39 +18,88 @@
|
|||
*/
|
||||
package com.arsdigita.bebop;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
/**
|
||||
* This class represents exceptions that occur within the processing
|
||||
* methods of any of the form event listeners. Typically the code
|
||||
* will catch specific exceptions such as <code>SQLException</code>
|
||||
* and rethrow them as instances of this class to pass the message to
|
||||
* the controller in a standard fashion.
|
||||
* This class represents exceptions that occur within the processing methods
|
||||
* of any of the form event listeners. Typically the code will catch specific
|
||||
* exceptions such as <code>SQLException</code> and rethrow them as instances
|
||||
* of this class to pass the message to the controller in a standard fashion.
|
||||
*
|
||||
* <p>Since this class is a subclass of <code>ServletException</code>,
|
||||
* servlets that do form processing within a <code>doPost</code> or
|
||||
* <code>doGet</code> methods do not need to explicitly catch
|
||||
* instances of this class. However, they may wish to do so for
|
||||
* special error reporting to the user, or to notify the webmaster via
|
||||
* e-mail of the problem.
|
||||
* <p>Since this class is a subclass of <code>ServletException</code>, servlets
|
||||
* that do form processing within a <code>doPost</code> or <code>doGet</code>
|
||||
* methods do not need to explicitly catch instances of this class. However,
|
||||
* they may wish to do so for special error reporting to the user, or to notify
|
||||
* the webmaster via e-mail of the problem.
|
||||
*
|
||||
* @version $Id: FormProcessException.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
|
||||
public class FormProcessException extends ServletException {
|
||||
|
||||
/** Globalized version of the exception message, intended for output in the UI */
|
||||
private GlobalizedMessage m_globalizedMessage;
|
||||
|
||||
public FormProcessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public FormProcessException(String message, Throwable rootCause) {
|
||||
public FormProcessException(String message,
|
||||
GlobalizedMessage globalizedMessage) {
|
||||
super(message);
|
||||
m_globalizedMessage = globalizedMessage;
|
||||
}
|
||||
|
||||
public FormProcessException(GlobalizedMessage globalizedMessage) {
|
||||
super();
|
||||
m_globalizedMessage = globalizedMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
* @param rootCause
|
||||
* @deprecated use FormProcessException(String,GlobalizedMessage,Throwable)
|
||||
* instead
|
||||
*/
|
||||
public FormProcessException(String message,
|
||||
Throwable rootCause) {
|
||||
super(message, rootCause);
|
||||
}
|
||||
|
||||
public FormProcessException(String message,
|
||||
GlobalizedMessage globalizedMessage,
|
||||
Throwable rootCause) {
|
||||
super(message, rootCause);
|
||||
m_globalizedMessage = globalizedMessage;
|
||||
}
|
||||
|
||||
public FormProcessException(Throwable rootCause) {
|
||||
super(rootCause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a globalized version of the exception message just in case a non-
|
||||
* globalized message enabled constructor has been used.
|
||||
*
|
||||
* @param globalizedMessage the globalized message intended for output in UI
|
||||
*/
|
||||
public void setGlobalizedMessage(GlobalizedMessage globalizedMessage) {
|
||||
m_globalizedMessage = globalizedMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the globalized version of the exception message, intended for
|
||||
* use in the UI widgets.
|
||||
* The standard non-globalizatin enabled exception message is for use in
|
||||
* log entries only!
|
||||
*
|
||||
* @return the globalized message intended for output in UI
|
||||
*/
|
||||
GlobalizedMessage getGlobalizedMessage() {
|
||||
return m_globalizedMessage;
|
||||
}
|
||||
/**
|
||||
* In addition to printing the stack trace for this exception, also prints
|
||||
* the stack trace for the root cause, if any. This is a workaround for
|
||||
|
|
@ -70,6 +119,7 @@ public class FormProcessException extends ServletException {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @see #printStackTrace()
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -82,6 +132,7 @@ public class FormProcessException extends ServletException {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @see #printStackTrace()
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -96,6 +147,7 @@ public class FormProcessException extends ServletException {
|
|||
/**
|
||||
* <p>Returns the concatenation of {@link #getMessage()} and {@link
|
||||
* #getRootCause()}.<code>getMessage()</code>.</p>
|
||||
* @return
|
||||
**/
|
||||
public String getMessages() {
|
||||
StringBuilder result = new StringBuilder(getMessage());
|
||||
|
|
|
|||
|
|
@ -27,18 +27,20 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
|
|||
import com.arsdigita.bebop.event.FormValidationListener;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A standalone section of a <code>Form</code>. A <code>FormSection</code>
|
||||
* contains other Bebop components, most importantly
|
||||
* <code>Widgets</code> and associated listeners. It serves two purposes:
|
||||
* <UL><LI>
|
||||
* Divides a form into visual sections</LI>
|
||||
* <LI>Serves as a container for form
|
||||
* fragments that can function by themselves and can be dropped into other
|
||||
* forms</LI></UL>
|
||||
* <UL>
|
||||
* <LI>Divides a form into visual sections</LI>
|
||||
* <LI>Serves as a container for form fragments that can function by themselves
|
||||
* and can be dropped into other forms</LI>
|
||||
* </UL>
|
||||
* <p>Since a <code>FormSection</code> has its own init, validation, and
|
||||
* process listeners, it can do all of its processing without any intervention
|
||||
* from the enclosing form.
|
||||
|
|
@ -62,29 +64,31 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class FormSection extends SimpleComponent implements Container {
|
||||
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
|
||||
* and set com.arsdigita.subsite.FormSection=DEBUG
|
||||
* by uncommenting or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(FormSection.class);
|
||||
/**
|
||||
* Underlying <code>FormModel</code> that stores
|
||||
* the parameter models for all the widgets in this form section.
|
||||
*/
|
||||
|
||||
/** Underlying <code>FormModel</code> that stores
|
||||
* the parameter models for all the widgets in this form section. */
|
||||
protected FormModel m_formModel;
|
||||
/**
|
||||
* The container to which all children are added. A
|
||||
* <code>ColumnPanel</code> by default.
|
||||
*/
|
||||
|
||||
/** The container to which all children are added. A
|
||||
* <code>ColumnPanel</code> by default. */
|
||||
protected Container m_panel;
|
||||
/**
|
||||
* Contains all the listeners that were added with the various
|
||||
|
||||
/** Contains all the listeners that were added with the various
|
||||
* addXXXListener methods.
|
||||
*
|
||||
* We maintain our own list of listeners, so that we can re-send the
|
||||
* events the FormModel generates, but with us as the source, not the
|
||||
* FormModel.
|
||||
*/
|
||||
* FormModel. */
|
||||
private EventListenerList m_listeners;
|
||||
// Listeners we attach to the FormModel to forward
|
||||
// form model events to our listeners with the right source
|
||||
|
||||
/** Listeners we attach to the FormModel to forward
|
||||
* form model events to our listeners with the right source */
|
||||
private FormSubmissionListener m_forwardSubmission;
|
||||
|
||||
private FormInitListener m_forwardInit;
|
||||
private FormValidationListener m_forwardValidation;
|
||||
private FormProcessListener m_forwardProcess;
|
||||
|
|
@ -101,6 +105,8 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
/**
|
||||
* Constructs a new form section. Sets the form model of this
|
||||
* <code>FormSection</code> to a new, anonymous FormModel.
|
||||
*
|
||||
* @param panel
|
||||
**/
|
||||
public FormSection(Container panel) {
|
||||
this(panel, new FormModel("anonymous"));
|
||||
|
|
@ -200,6 +206,9 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void forwardSubmission() {
|
||||
if (m_forwardSubmission == null) {
|
||||
m_forwardSubmission = createSubmissionListener();
|
||||
|
|
@ -217,6 +226,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
protected FormSubmissionListener createSubmissionListener() {
|
||||
return new FormSubmissionListener() {
|
||||
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
fireSubmitted(new FormSectionEvent(FormSection.this,
|
||||
|
|
@ -287,6 +297,9 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void forwardInit() {
|
||||
if (m_forwardInit == null) {
|
||||
m_forwardInit = createInitListener();
|
||||
|
|
@ -304,6 +317,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
protected FormInitListener createInitListener() {
|
||||
return new FormInitListener() {
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
fireInit(new FormSectionEvent(FormSection.this,
|
||||
|
|
@ -322,6 +336,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
protected FormCancelListener createCancelListener() {
|
||||
return new FormCancelListener() {
|
||||
|
||||
@Override
|
||||
public void cancel(FormSectionEvent e) throws FormProcessException {
|
||||
fireCancel(new FormSectionEvent(FormSection.this,
|
||||
e.getPageState(),
|
||||
|
|
@ -389,7 +404,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
listener.validate(e);
|
||||
} catch (FormProcessException fpe) {
|
||||
s_log.debug(fpe);
|
||||
data.addError(fpe.getMessage());
|
||||
data.addError(fpe.getGlobalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -411,6 +426,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
protected FormValidationListener createValidationListener() {
|
||||
return new FormValidationListener() {
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) {
|
||||
fireValidate(new FormSectionEvent(FormSection.this,
|
||||
e.getPageState(),
|
||||
|
|
@ -470,6 +486,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
protected FormProcessListener createProcessListener() {
|
||||
return new FormProcessListener() {
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
fireProcess(new FormSectionEvent(FormSection.this,
|
||||
|
|
@ -507,8 +524,10 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* (Processing of form sections is done by the form in which the
|
||||
* section is contained.)
|
||||
*
|
||||
* @throws javax.servlet.ServletException because processing a form section is
|
||||
* not meaningful.
|
||||
* @param data
|
||||
* @return
|
||||
* @throws javax.servlet.ServletException because processing a form section
|
||||
* is not meaningful.
|
||||
*/
|
||||
public FormData process(PageState data)
|
||||
throws javax.servlet.ServletException {
|
||||
|
|
@ -579,10 +598,10 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
*
|
||||
* @param f pointer to the form that is set inside Widgets within this
|
||||
* FormSection
|
||||
*
|
||||
* @param m the FormModel in which to merge ParameterModels and
|
||||
* Listeners
|
||||
* */
|
||||
@Override
|
||||
public void register(Form f, FormModel m) {
|
||||
m.mergeModel(getModel());
|
||||
}
|
||||
|
|
@ -599,12 +618,14 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
/**
|
||||
* Locks this FormSection, its FormModel, and the implicit Container.
|
||||
* */
|
||||
@Override
|
||||
public void lock() {
|
||||
m_formModel.lock();
|
||||
m_panel.lock();
|
||||
super.lock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void respond(PageState state) throws javax.servlet.ServletException {
|
||||
//call listeners here.
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
@ -614,7 +635,9 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* Returns the implicit Container of this FormSection.
|
||||
*
|
||||
* This must not be final, because MetaFrom needs to override it.
|
||||
* */
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Container getPanel() {
|
||||
return m_panel;
|
||||
}
|
||||
|
|
@ -626,6 +649,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
*
|
||||
* @post return != null
|
||||
* */
|
||||
@Override
|
||||
public Iterator children() {
|
||||
return m_panel.children();
|
||||
}
|
||||
|
|
@ -641,6 +665,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* @param pageState the state of the current page
|
||||
* @param parent the node that will be used to write to
|
||||
* */
|
||||
@Override
|
||||
public void generateXML(PageState pageState, Element parent) {
|
||||
if (isVisible(pageState)) {
|
||||
m_panel.generateXML(pageState, parent);
|
||||
|
|
@ -653,6 +678,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
*
|
||||
* @param pc the component to add to this container
|
||||
* */
|
||||
@Override
|
||||
public void add(Component pc) {
|
||||
m_panel.add(pc);
|
||||
}
|
||||
|
|
@ -667,6 +693,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* @param constraints layout constraints (a
|
||||
* bitwise OR of static ints in the particular layout)
|
||||
* */
|
||||
@Override
|
||||
public void add(Component pc, int constraints) {
|
||||
m_panel.add(pc, constraints);
|
||||
}
|
||||
|
|
@ -689,6 +716,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* specified component directly; <code>false</code> otherwise.
|
||||
*
|
||||
* */
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return m_panel.contains(o);
|
||||
}
|
||||
|
|
@ -706,6 +734,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
*
|
||||
* @return the component at the specified position in this container
|
||||
* */
|
||||
@Override
|
||||
public Component get(int index) {
|
||||
return (Component) m_panel.get(index);
|
||||
}
|
||||
|
|
@ -720,6 +749,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* the specified element, or -1 if this list does not contain this
|
||||
* element.
|
||||
* */
|
||||
@Override
|
||||
public int indexOf(Component pc) {
|
||||
return m_panel.indexOf(pc);
|
||||
}
|
||||
|
|
@ -730,6 +760,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
* @return <code>true</code> if this container contains no components
|
||||
* <code>false</code> otherwise.
|
||||
* */
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return m_panel.isEmpty();
|
||||
}
|
||||
|
|
@ -740,6 +771,7 @@ public class FormSection extends SimpleComponent implements Container {
|
|||
*
|
||||
* @return the number of components directly in this container.
|
||||
* */
|
||||
@Override
|
||||
public int size() {
|
||||
return m_panel.size();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ import com.arsdigita.bebop.form.Widget;
|
|||
*
|
||||
* @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a>
|
||||
* @version $Id: FormValidationException.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
**/
|
||||
*/
|
||||
|
||||
public class FormValidationException extends FormProcessException {
|
||||
|
||||
/** */
|
||||
private String m_name = null;
|
||||
|
||||
public FormValidationException(String message) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
|
|||
import com.arsdigita.bebop.list.DefaultListCellRenderer;
|
||||
import com.arsdigita.bebop.list.ListModelBuilder;
|
||||
import com.arsdigita.bebop.list.ListModel;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.util.SequentialMap;
|
||||
|
|
@ -101,8 +102,8 @@ import java.util.Map;
|
|||
* that will display the right components in the editor. The
|
||||
* {@link #addComponent(String, Component)} method can be used to add
|
||||
* a component to the <code>PropertyEditor</code> without automatically
|
||||
* generating the link for it. The {@link #addVisibilityListener(ActionLink, String)} method can
|
||||
* then be used to add an appropriate {@link ActionListener} to any
|
||||
* generating the link for it. The {@link #addVisibilityListener(ActionLink, String)}
|
||||
* method can then be used to add an appropriate {@link ActionListener} to any
|
||||
* {@link ActionLink}. For example:
|
||||
*
|
||||
* <blockquote><pre><code>// Add a form
|
||||
|
|
@ -124,13 +125,13 @@ import java.util.Map;
|
|||
* Therefore, the <code>PropertyEditor</code> is a model-backed component,
|
||||
* as described in the Bebop tutorials. This means that the list
|
||||
* of properties for the editor could be generated dynamically during
|
||||
* each request. The {@link #setModelBuilder(PropertyEditorModelBuilder)} method can be used to set
|
||||
* a specialized {@link PropertyEditorModelBuilder} for the editor. In order
|
||||
* to write the model builder, you may choose to extend the protected
|
||||
* inner classes {@link PropertyEditor.DefaultModelBuilder} and
|
||||
* each request. The {@link #setModelBuilder(PropertyEditorModelBuilder)} method
|
||||
* can be used to set a specialized {@link PropertyEditorModelBuilder} for the
|
||||
* editor. In order to write the model builder, you may choose to extend the
|
||||
* protected inner classes {@link PropertyEditor.DefaultModelBuilder} and
|
||||
* {@link PropertyEditor.DefaultModel}. It is also possible to write the model
|
||||
* builder and the corresponding model from scratch. However, most people won't need to
|
||||
* do this.
|
||||
* builder and the corresponding model from scratch. However, most people won't
|
||||
* need to do this.
|
||||
* <p>
|
||||
* For example, <code>SecurityPropertyEditor</code> uses a custom
|
||||
* {@link PropertyEditorModelBuilder} in order to hide the links for properties
|
||||
|
|
@ -196,6 +197,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
// Should a ComponentSelectionModel be used here instead ? It's tempting,
|
||||
// but there doesn't seem to be a real need for it
|
||||
m_list.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
|
||||
|
|
@ -262,6 +264,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
* Shows the component that is identified by the specified key.
|
||||
*
|
||||
* @param state the page state
|
||||
* @param key
|
||||
*/
|
||||
public void showComponent(PageState state, String key) {
|
||||
m_list.setSelectedKey(state, key);
|
||||
|
|
@ -458,8 +461,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a form to the set of forms that can be used to edit the
|
||||
* properties.
|
||||
* Adds a form to the set of forms that can be used to edit the properties.
|
||||
*
|
||||
* @param key the symbolic key for the form (must be unique
|
||||
* for this <code>PropertyEditor</code>)
|
||||
|
|
@ -529,11 +531,14 @@ public class PropertyEditor extends SimpleContainer {
|
|||
final Submit theButton = cancelButton;
|
||||
|
||||
form.addSubmissionListener(new FormSubmissionListener() {
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
if(theButton.isSelected(state)) {
|
||||
showDisplayPane(state);
|
||||
throw new FormProcessException("Submission Cancelled");
|
||||
throw new FormProcessException(
|
||||
"Submission Cancelled",
|
||||
GlobalizationUtil.globalize("bebop.cancel.msg"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -549,6 +554,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
*/
|
||||
public void addProcessListener(FormSection form) {
|
||||
form.addProcessListener(new FormProcessListener() {
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
showDisplayPane(state);
|
||||
|
|
@ -587,6 +593,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
public void addVisibilityListener(ActionLink l, String key) {
|
||||
final String t_key = key;
|
||||
l.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showComponent(e.getPageState(), t_key);
|
||||
}
|
||||
|
|
@ -697,6 +704,8 @@ public class PropertyEditor extends SimpleContainer {
|
|||
* Return an iterator of all properties of the specified property
|
||||
* editor. These properties should be passed into the constructor
|
||||
* of the {@link PropertyEditor.DefaultModel}
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
protected Iterator getProperties(PropertyEditor p) {
|
||||
return p.getLabelsMap().entrySet().iterator();
|
||||
|
|
@ -706,6 +715,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
* Construct a {@link PropertyEditorModel} for the current
|
||||
* request.
|
||||
*/
|
||||
@Override
|
||||
public PropertyEditorModel makeModel(PropertyEditor p, PageState s) {
|
||||
return new DefaultModel(getProperties(p));
|
||||
}
|
||||
|
|
@ -726,6 +736,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
m_entry = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() {
|
||||
if(!m_iter.hasNext()) {
|
||||
m_entry = null;
|
||||
|
|
@ -740,6 +751,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
* request to ensure proper localization.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
Assert.exists(m_entry);
|
||||
if ( m_entry.getValue() instanceof GlobalizedMessage ) {
|
||||
|
|
@ -755,6 +767,7 @@ public class PropertyEditor extends SimpleContainer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKey() {
|
||||
Assert.exists(m_entry);
|
||||
return m_entry.getKey();
|
||||
|
|
@ -767,13 +780,14 @@ public class PropertyEditor extends SimpleContainer {
|
|||
private static final class BuilderAdapter extends LockableImpl
|
||||
implements ListModelBuilder {
|
||||
|
||||
private PropertyEditor m_parent;
|
||||
private final PropertyEditor m_parent;
|
||||
|
||||
public BuilderAdapter(PropertyEditor parent) {
|
||||
super();
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListModel makeModel(List l, PageState state) {
|
||||
return new ModelAdapter(m_parent.getModel(state));
|
||||
}
|
||||
|
|
@ -784,14 +798,17 @@ public class PropertyEditor extends SimpleContainer {
|
|||
*/
|
||||
private static final class ModelAdapter implements ListModel {
|
||||
|
||||
private PropertyEditorModel m_model;
|
||||
private final PropertyEditorModel m_model;
|
||||
|
||||
public ModelAdapter(PropertyEditorModel model) {
|
||||
m_model = model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() { return m_model.next(); }
|
||||
@Override
|
||||
public Object getElement() { return m_model.getComponent(); }
|
||||
@Override
|
||||
public String getKey() { return m_model.getKey().toString(); }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.arsdigita.bebop.event.ChangeListener;
|
|||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.form.Widget;
|
||||
import static com.arsdigita.bebop.util.GlobalizationUtil.globalize;
|
||||
import com.arsdigita.bebop.util.Traversal;
|
||||
|
||||
/**
|
||||
|
|
@ -115,7 +116,11 @@ public class Wizard extends MultiStepForm {
|
|||
private Component m_first = null;
|
||||
private Component m_last = null;
|
||||
|
||||
private RequestLocal m_hiddenSteps = new RequestLocal() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final RequestLocal m_hiddenSteps = new RequestLocal() {
|
||||
@Override
|
||||
protected Object initialValue(PageState state) {
|
||||
return new HashSet();
|
||||
}
|
||||
|
|
@ -189,8 +194,11 @@ public class Wizard extends MultiStepForm {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
|
||||
|
|
@ -199,9 +207,11 @@ public class Wizard extends MultiStepForm {
|
|||
p.setVisibleDefault(m_finish, false);
|
||||
}
|
||||
Traversal trav = new Traversal () {
|
||||
@Override
|
||||
protected void act(Component c) {
|
||||
if (c instanceof Widget) {
|
||||
((Widget) c).setValidationGuard(new Widget.ValidationGuard() {
|
||||
@Override
|
||||
public boolean shouldValidate(PageState ps) {
|
||||
return m_back.isSelected(ps);
|
||||
}
|
||||
|
|
@ -303,6 +313,7 @@ public class Wizard extends MultiStepForm {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireSubmitted(FormSectionEvent evt)
|
||||
throws FormProcessException {
|
||||
super.fireSubmitted(evt);
|
||||
|
|
@ -311,9 +322,17 @@ public class Wizard extends MultiStepForm {
|
|||
if (m_cancel.isSelected(ps)) {
|
||||
super.fireCancel(evt);
|
||||
ps.reset(this);
|
||||
throw new FormProcessException("cancel hit");
|
||||
throw new FormProcessException("Submission cancelled",
|
||||
globalize("bebop.cancel.msg"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param evt
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
protected void fireProcess(FormSectionEvent evt)
|
||||
throws FormProcessException {
|
||||
PageState ps = evt.getPageState();
|
||||
|
|
@ -332,7 +351,16 @@ public class Wizard extends MultiStepForm {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private class SkipStepListener implements ChangeListener {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
s_log.debug("state of underlying modal container changed - " +
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.bebop.util.BebopConstants;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
import static com.arsdigita.bebop.util.GlobalizationUtil.globalize;
|
||||
import com.arsdigita.bebop.util.Size;
|
||||
import com.arsdigita.dispatcher.Dispatcher;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
|
@ -814,6 +815,7 @@ public class DemoDispatcher extends AutoDispatcher implements BebopConstants {
|
|||
static final String CASH = "cash";
|
||||
static final String CANNON = "cannon";
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
FormData data = e.getFormData();
|
||||
|
|
@ -822,8 +824,8 @@ public class DemoDispatcher extends AutoDispatcher implements BebopConstants {
|
|||
|
||||
if ( ! CASH.equals(payment) && CANNON.equals(shipment)) {
|
||||
throw new FormProcessException(
|
||||
"Must pay cash when shipping via Burger Cannon"
|
||||
);
|
||||
"Must pay cash when shipping via Burger Cannon",
|
||||
globalize("(key missing)") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,13 @@ import com.arsdigita.bebop.PageState;
|
|||
*/
|
||||
public class FormSectionEvent extends PageEvent {
|
||||
|
||||
private transient FormData _formData;
|
||||
private final transient FormData _formData;
|
||||
|
||||
/**
|
||||
* Get the form data for to the form that fired the event in the current
|
||||
* request.
|
||||
*
|
||||
* @return form data
|
||||
*/
|
||||
public final FormData getFormData() {
|
||||
return _formData;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ public interface ParameterListener extends EventListener {
|
|||
* specific parameter. Validate should call
|
||||
* ParameterData.addError() with a message regarding the nature
|
||||
* of the error.
|
||||
* @param e
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
|
||||
void validate(ParameterEvent e) throws FormProcessException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,28 +60,33 @@ public class FileUpload extends Widget {
|
|||
|
||||
/**
|
||||
* Returns a string naming the type of this widget.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isCompound() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback method for rendering this File widget in a visitor.
|
||||
*/
|
||||
/* public void accept(FormVisitor visitor) throws IOException {
|
||||
visitor.visitFile(this);
|
||||
}*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private class FileExistsValidationListener extends GlobalizedParameterListener {
|
||||
|
||||
public FileExistsValidationListener() {
|
||||
setError(new GlobalizedMessage("file_empty_or_not_found", getBundleBaseName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate (ParameterEvent e) {
|
||||
ParameterData data = e.getParameterData();
|
||||
HttpServletRequest request = e.getPageState().getRequest();
|
||||
|
|
@ -93,7 +98,9 @@ public class FileUpload extends Widget {
|
|||
return;
|
||||
}
|
||||
|
||||
if (((MultipartHttpServletRequest) request).getFile(data.getModel().getName()).length()==0) {
|
||||
if (((MultipartHttpServletRequest) request).getFile(data.getModel()
|
||||
.getName())
|
||||
.length()==0) {
|
||||
data.addError(filename + " " + getError().localize());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ public class Option extends BlockStylable {
|
|||
* then this returns the value of the label. This assumes
|
||||
* that the Component is a label
|
||||
*
|
||||
* @return
|
||||
* @exception ClassCastException is thrown if the component is not
|
||||
* a label
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -48,19 +48,22 @@ import com.arsdigita.xml.Element;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* A class representing a widget in the graphical representation of a form.</p>
|
||||
* A class representing a widget in the graphical representation of a form.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* A widget may correspond to a standard HTML form element, or to a more specific element or set of
|
||||
* elements, such as a date widget that allows input of month, day and year (and possibly time as
|
||||
* well).</p>
|
||||
* A widget may correspond to a standard HTML form element, or to a more
|
||||
* specific element or set of elements, such as a date widget that allows
|
||||
* input of month, day and year (and possibly time as well).</p>
|
||||
*
|
||||
* <p>
|
||||
* This class and its subclasses provide methods to set all element attributes except for
|
||||
* <code>VALUE</code>, which is typically dependent on the request. At the time of a request, a
|
||||
* widget object merges a dynamically specified value or set of values with its own set of
|
||||
* persistent attributes to render the final HTML for the widget. Other dynamic attributes may be
|
||||
* associated with the form component via a <code>WidgetPeer</code> associated with the widget.</p>
|
||||
* This class and its subclasses provide methods to set all element attributes
|
||||
* except for <code>VALUE</code>, which is typically dependent on the request.
|
||||
* At the time of a request, a widget object merges a dynamically specified
|
||||
* value or set of values with its own set of persistent attributes to render
|
||||
* the final HTML for the widget. Other dynamic attributes may be associated
|
||||
* with the form component via a <code>WidgetPeer</code> associated with the
|
||||
* widget.</p>
|
||||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
|
|
@ -73,7 +76,7 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
private static final Logger s_log = Logger.getLogger(Widget.class);
|
||||
|
||||
private ParameterModel m_parameterModel;
|
||||
private EventListenerList m_listeners = new EventListenerList();
|
||||
private final EventListenerList m_listeners = new EventListenerList();
|
||||
private ParameterListener m_forwardParameter = null;
|
||||
private PrintListener m_printListener;
|
||||
private Form m_form;
|
||||
|
|
@ -96,17 +99,23 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
/**
|
||||
* Returns true if the widget consists of multiple HTML elements.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean isCompound();
|
||||
|
||||
/**
|
||||
* Returns a string naming the type of this widget. Must be implemented by subclasses
|
||||
* Returns a string naming the type of this widget. Must be implemented by
|
||||
* subclasses!
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getType();
|
||||
|
||||
/**
|
||||
* Constructs a new widget.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
protected Widget(String name) {
|
||||
this(new StringParameter(name));
|
||||
|
|
@ -116,8 +125,10 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
* Constructs a new widget.
|
||||
*
|
||||
* <p>
|
||||
* Each new widget is associated with a ParameterModel describing the data object(s) submitted
|
||||
* from the widget.
|
||||
* Each new widget is associated with a ParameterModel describing the
|
||||
* data object(s) submitted from the widget.
|
||||
*
|
||||
* @param model
|
||||
*/
|
||||
protected Widget(ParameterModel model) {
|
||||
Assert.exists(model, ParameterModel.class);
|
||||
|
|
@ -125,8 +136,13 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
m_parameterModel = model;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected ParameterListener createParameterListener() {
|
||||
return new ParameterListener() {
|
||||
@Override
|
||||
public void validate(ParameterEvent evt)
|
||||
throws FormProcessException {
|
||||
fireValidation(new ParameterEvent(Widget.this, evt.getParameterData()));
|
||||
|
|
@ -149,8 +165,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
PageState ps = evt.getPageState();
|
||||
|
||||
if ((!validateInvisible() && !ps.isVisibleOnPage(this)) || ((m_guard != null) && m_guard.
|
||||
shouldValidate(ps))) {
|
||||
if ( (!validateInvisible() && !ps.isVisibleOnPage(this))
|
||||
|| ((m_guard != null) && m_guard.shouldValidate(ps)) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -191,12 +207,12 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a print listener for this widget. Only one print listener can be set for a widget, since
|
||||
* the <code>PrintListener</code> is expected to modify the target of the
|
||||
* <code>PrintEvent</code>.
|
||||
* Adds a print listener for this widget. Only one print listener can
|
||||
* be set for a widget, since the <code>PrintListener</code> is expected
|
||||
* to modify the target of the <code>PrintEvent</code>.
|
||||
*
|
||||
* @param listener the print listener
|
||||
* @throws IlegalArgumentException <code>listener</code> is null
|
||||
* @throws IllegalArgumentException <code>listener</code> is null
|
||||
* @throws TooManyListenersException a print listener has previously been added
|
||||
* @pre listener != null
|
||||
*/
|
||||
|
|
@ -212,12 +228,13 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the print listener for this widget. Since there can only be one print listener for a
|
||||
* widget, this lets you just set it and avoid writing a try/catch block for
|
||||
* "TooManyListenersException". Any existing listener will be overwritten.
|
||||
* Set the print listener for this widget. Since there can only be one
|
||||
* print listener for a widget, this lets you just set it and avoid
|
||||
* writing a try/catch block for "TooManyListenersException". Any existing
|
||||
* listener will be overwritten.
|
||||
*
|
||||
* @param listener the print listener
|
||||
* @throws IlegalArgumentException <code>listener</code> is null
|
||||
* @throws IllegalArgumentException <code>listener</code> is null
|
||||
* @pre listener != null
|
||||
*/
|
||||
public void setPrintListener(PrintListener listener)
|
||||
|
|
@ -229,13 +246,15 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove a previously added print listener. If <code>listener</code> is not the listener that
|
||||
* has been added with {@link #addPrintListener
|
||||
* addPrintListener}, an IllegalArgumentException will be thrown.
|
||||
* Remove a previously added print listener.
|
||||
* If <code>listener</code> is not the listener that has been added with
|
||||
* {@link #addPrintListener addPrintListener}, an IllegalArgumentException
|
||||
* will be thrown.
|
||||
*
|
||||
* @param listener the listener that had been added with <code>addPrintListener</code>
|
||||
* @throws IllegalArgumentException <code>listener</code> is not the currently registered print
|
||||
* listener or is <code>null</code>.
|
||||
* @param listener the listener that had been added with
|
||||
* <code>addPrintListener</code>
|
||||
* @throws IllegalArgumentException <code>listener</code> is not the
|
||||
* currently registered print listener or is <code>null</code>.
|
||||
* @pre listener != null
|
||||
*/
|
||||
public void removePrintListener(PrintListener listener)
|
||||
|
|
@ -252,7 +271,10 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
/**
|
||||
* Registers the ParameterModel of this Widget with the containing Form. This method is used by
|
||||
* the Bebop framework and should not be used by application developers.
|
||||
* @param form
|
||||
* @param model
|
||||
*/
|
||||
@Override
|
||||
public void register(Form form, FormModel model) {
|
||||
model.addFormParam(getParameterModel());
|
||||
|
||||
|
|
@ -260,8 +282,9 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the Form Object for this Widget. This method will throw an exception if the _form
|
||||
* pointer is already set. To explicity change the m_form pointer the developer must first call
|
||||
* Sets the Form Object for this Widget.
|
||||
* This method will throw an exception if the _form pointer is already set.
|
||||
* To explicity change the m_form pointer the developer must first call
|
||||
* setForm(null)
|
||||
*
|
||||
* @param form The <code>Form</code> Object for this Widget
|
||||
|
|
@ -269,7 +292,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
*/
|
||||
public void setForm(final Form form) {
|
||||
if (m_form != null && form != null) {
|
||||
throw new IllegalStateException("Form " + form.getName() + " already set for "
|
||||
throw new IllegalStateException("Form " + form.getName()
|
||||
+ " already set for "
|
||||
+ getName());
|
||||
}
|
||||
|
||||
|
|
@ -277,8 +301,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the Form Object for this Widget. Throws an exception if the Widget doesn't belong to a
|
||||
* form.
|
||||
* Gets the Form Object for this Widget.
|
||||
* Throws an exception if the Widget doesn't belong to a form.
|
||||
*
|
||||
* @return the {@link Form} Object for this Widget.
|
||||
* @post return != null
|
||||
|
|
@ -293,52 +317,70 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>ONFOCUS</tt> attribute for the HTML tags that compose this element.
|
||||
* Sets the <tt>ONFOCUS</tt> attribute for the HTML tags that compose
|
||||
* this element.
|
||||
*
|
||||
* @param javascriptCode
|
||||
*/
|
||||
public void setOnFocus(String javascriptCode) {
|
||||
setAttribute(ON_FOCUS, javascriptCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>ONBLUR</tt> attribute for the HTML tags that compose this element.
|
||||
* Sets the <tt>ONBLUR</tt> attribute for the HTML tags that compose
|
||||
* this element.
|
||||
*
|
||||
* @param javascriptCode
|
||||
*/
|
||||
public void setOnBlur(String javascriptCode) {
|
||||
setAttribute(ON_BLUR, javascriptCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>ONSELECT</tt> attribute for the HTML tags that compose this element.
|
||||
* Sets the <tt>ONSELECT</tt> attribute for the HTML tags that compose
|
||||
* this element.
|
||||
*
|
||||
* @param javascriptCode
|
||||
*/
|
||||
public void setOnSelect(String javascriptCode) {
|
||||
setAttribute(ON_SELECT, javascriptCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>ONCHANGE</tt> attribute for the HTML tags that compose this element.
|
||||
* Sets the <tt>ONCHANGE</tt> attribute for the HTML tags that compose
|
||||
* this element.
|
||||
*
|
||||
* @param javascriptCode
|
||||
*/
|
||||
public void setOnChange(String javascriptCode) {
|
||||
setAttribute(ON_CHANGE, javascriptCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>ON_KEY_UP</tt> attribute for the HTML tags that compose this element.
|
||||
* Sets the <tt>ON_KEY_UP</tt> attribute for the HTML tags that compose
|
||||
* this element.
|
||||
*
|
||||
* @param javascriptCode
|
||||
*/
|
||||
public void setOnKeyUp(String javascriptCode) {
|
||||
setAttribute(ON_KEY_UP, javascriptCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value in the parameter model for this element. This is a static property and
|
||||
* this method should not be invoked at request time (not even in a PrintListener).
|
||||
* Sets the default value in the parameter model for this element.
|
||||
* This is a static property and this method should not be invoked
|
||||
* at request time (not even in a PrintListener).
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
public void setDefaultValue(Object value) {
|
||||
m_parameterModel.setDefaultValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks this widget as readonly, which has the effect of preventing the user from modifying the
|
||||
* widget's contents. This method can only be called on unlocked widgets.
|
||||
* Marks this widget as readonly, which has the effect of preventing the
|
||||
* user from modifying the widget's contents.
|
||||
* This method can only be called on unlocked widgets.
|
||||
*/
|
||||
public void setReadOnly() {
|
||||
Assert.isUnlocked(this);
|
||||
|
|
@ -346,8 +388,9 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Marks this widget as disabled, which has the effect of preventing the widget's value being
|
||||
* submitted with the form, and will typically cause the widget to be 'grayed out' on the form.
|
||||
* Marks this widget as disabled, which has the effect of preventing the
|
||||
* widget's value being submitted with the form, and will typically cause
|
||||
* the widget to be 'grayed out' on the form.
|
||||
* This method can only be called on unlocked widgets.
|
||||
*/
|
||||
public void setDisabled() {
|
||||
|
|
@ -358,8 +401,9 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
/**
|
||||
* Sets a popup hint for the widget.
|
||||
*
|
||||
* @deprecated refactor to use a GlobalizedMessage instead and use setHint(GlobalizedMessage
|
||||
* hint)
|
||||
* @param hint
|
||||
* @deprecated refactor to use a GlobalizedMessage instead and use
|
||||
* setHint(GlobalizedMessage hint)
|
||||
*/
|
||||
public void setHint(String hint) {
|
||||
Assert.isUnlocked(this);
|
||||
|
|
@ -368,6 +412,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
/**
|
||||
* Sets a popup hint for the widget.
|
||||
*
|
||||
* @param hint
|
||||
*/
|
||||
public void setHint(GlobalizedMessage hint) {
|
||||
Assert.isUnlocked(this);
|
||||
|
|
@ -376,6 +422,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
/**
|
||||
* Sets a Label for the widget.
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
public void setLabel(GlobalizedMessage label) {
|
||||
m_label = label;
|
||||
|
|
@ -383,6 +431,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
/**
|
||||
* Sets a Label for the widget.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public GlobalizedMessage getLabel() {
|
||||
return m_label;
|
||||
|
|
@ -390,6 +440,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
/**
|
||||
* Gets the default value in the parameter model for this element.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
Object o = m_parameterModel.getDefaultValue();
|
||||
|
|
@ -404,28 +456,30 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* The "pass in" property determines whether the value for this parameter is generally passed in
|
||||
* from the outside. If this property is <code>true</code>, the model always tries to get the
|
||||
* parameter value from the request, no matter whether the request is the initial request or a
|
||||
* submission of the form to which the widget belongs.
|
||||
* The "pass in" property determines whether the value for this parameter
|
||||
* is generally passed in from the outside.
|
||||
* If this property is <code>true</code>, the model always tries to get the
|
||||
* parameter value from the request, no matter whether the request is the
|
||||
* initial request or a submission of the form to which the widget belongs.
|
||||
*
|
||||
* <p>
|
||||
* If this property is <code>false</code>, the parameter value is only read from the request if
|
||||
* it is a submission of the form containing the widget.
|
||||
* If this property is <code>false</code>, the parameter value is only read
|
||||
* from the request if it is a submission of the form containing the widget.
|
||||
*
|
||||
* <p>
|
||||
* By default, this property is <code>false</code>.
|
||||
*
|
||||
* @return <code>true</code> if an attempt should always be made to retrieve the parameter value
|
||||
* from the request.
|
||||
* @return <code>true</code> if an attempt should always be made to
|
||||
* retrieve the parameter value from the request.
|
||||
*/
|
||||
public final boolean isPassIn() {
|
||||
return getParameterModel().isPassIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this parameter should be treated as a "pass in" parameter. This is a static
|
||||
* property of the ParameterModel and this method should not be invoked at request-time.
|
||||
* Set whether this parameter should be treated as a "pass in" parameter.
|
||||
* This is a static property of the ParameterModel and this method should
|
||||
* not be invoked at request-time.
|
||||
*
|
||||
* @see #isPassIn
|
||||
* @param v <code>true</code> if this parameter is a pass in parameter.
|
||||
|
|
@ -436,8 +490,12 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* The ParameterModel is normally set via the constructors. This method is only rarely needed.
|
||||
* Please note that the previous ParameterModel and all its listeners will be lost.
|
||||
* The ParameterModel is normally set via the constructors.
|
||||
* This method is only rarely needed.
|
||||
* Please note that the previous ParameterModel and all its listeners
|
||||
* will be lost.
|
||||
*
|
||||
* @param parameterModel
|
||||
*/
|
||||
public final void setParameterModel(ParameterModel parameterModel) {
|
||||
Assert.isUnlocked(this);
|
||||
|
|
@ -445,10 +503,13 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Allows access to underlying parameterModel. The ParameterModel contains static
|
||||
* (request-independent) properties of a Widget such as its name, default value and its
|
||||
* listeners. The ParameterModel can not be modified once Page.lock() has been invoked (not even
|
||||
* in a PrintListener). This is done after the Page has been built, normally at server startup.
|
||||
* Allows access to underlying parameterModel. The ParameterModel contains
|
||||
* static (request-independent) properties of a Widget such as its name,
|
||||
* default value and its listeners. The ParameterModel can not be modified
|
||||
* once Page.lock() has been invoked (not even in a PrintListener).
|
||||
* This is done after the Page has been built, normally at server startup.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final ParameterModel getParameterModel() {
|
||||
return m_parameterModel;
|
||||
|
|
@ -456,14 +517,15 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* This method creates the DOM for the widget. The method is called by the Bebop framework and
|
||||
* should not be invoked by application developers.
|
||||
* This method creates the DOM for the widget. The method is called by the
|
||||
* Bebop framework and should not be invoked by application developers.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The method first fires the print event allowing application developers to set certain
|
||||
* properties of the Widget at request time in a PrintListener. The methods generateWidget and
|
||||
* generateErrors will then be invoked to generate either of the following
|
||||
* The method first fires the print event allowing application developers
|
||||
* to set certain properties of the Widget at request time in a
|
||||
* PrintListener. The methods generateWidget and generateErrors will then
|
||||
* be invoked to generate either of the following
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
|
|
@ -476,7 +538,10 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
* </bebop:formWidget></code>
|
||||
* </p>
|
||||
*
|
||||
* @param state
|
||||
* @param parent
|
||||
*/
|
||||
@Override
|
||||
public void generateXML(final PageState state, final Element parent) {
|
||||
|
||||
if (isVisible(state)) {
|
||||
|
|
@ -507,7 +572,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
/**
|
||||
* The XML tag.
|
||||
*
|
||||
* @return The tag to be used for the top level DOM element generated for this type of Widget.
|
||||
* @return The tag to be used for the top level DOM element generated for
|
||||
* this type of Widget.
|
||||
*/
|
||||
protected String getElementTag() {
|
||||
return BEBOP_FORMWIDGET;
|
||||
|
|
@ -520,6 +586,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
* <p>
|
||||
* <code><bebop:formWidget name=... type=... value=... [onXXX=...]>
|
||||
* </bebop:formWidget></code>
|
||||
* @param state
|
||||
* @param parent
|
||||
*/
|
||||
protected void generateWidget(PageState state, Element parent) {
|
||||
Element widget = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
|
||||
|
|
@ -544,12 +612,15 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates the XML for the given widget
|
||||
* Generates the XML for the given widget.
|
||||
* <p>
|
||||
* Generates XML fragment:
|
||||
* <p>
|
||||
* <code><bebop:formErrors message=... id=name>
|
||||
* </bebop:formErrors></code>
|
||||
* </p>
|
||||
*
|
||||
* @param state
|
||||
* @param parent
|
||||
*/
|
||||
protected void generateErrors(PageState state, Element parent) {
|
||||
Iterator i = getErrors(state);
|
||||
|
|
@ -564,12 +635,15 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the value associated with this widget in the request described by <code>ps</code>. The
|
||||
* type of the returned object depends on the <code>ParameterModel</code> underlying this
|
||||
* widget. This method is typically called in a FormProcessListener to access the value that was
|
||||
* submitted for a Widget in the Form.
|
||||
* Get the value associated with this widget in the request described by
|
||||
* <code>ps</code>.
|
||||
* The type of the returned object depends on the <code>ParameterModel</code>
|
||||
* underlying this widget. This method is typically called in a
|
||||
* FormProcessListener to access the value that was submitted for a Widget
|
||||
* in the Form.
|
||||
*
|
||||
* @param ps describes the request currently being processed
|
||||
* @return
|
||||
* @pre ps != null
|
||||
* @post may return null
|
||||
*/
|
||||
|
|
@ -591,15 +665,19 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the value of the parameter associated with this widget to a new value. The exact type of
|
||||
* <code>value</code> depends on the <code>ParameterModel</code> underlying the widget. This
|
||||
* method is typically called in a FormInitListener to initialize the value of a Widget in the
|
||||
* Set the value of the parameter associated with this widget to a new value.
|
||||
* The exact type of <code>value</code> depends on the
|
||||
* <code>ParameterModel</code> underlying the widget. This method is typically
|
||||
* called in a FormInitListener to initialize the value of a Widget in the
|
||||
* Form at request time.
|
||||
*
|
||||
* @param ps
|
||||
* @param value
|
||||
* @pre ps != null
|
||||
* @post value == getValue(ps)
|
||||
*
|
||||
* @throws IllegalStateExeption the form to which the widget belongs has not been processed yet.
|
||||
* @throws IllegalStateException the form to which the widget belongs has
|
||||
* not been processed yet.
|
||||
*/
|
||||
public void setValue(PageState ps, Object value)
|
||||
throws IllegalStateException {
|
||||
|
|
@ -633,6 +711,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ps
|
||||
* @return the parameter value for this widget
|
||||
* @post returns null if the FormData are missing
|
||||
*/
|
||||
|
|
@ -646,12 +726,13 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Respond to an incoming request by calling <code>respond</code> on the form to which the
|
||||
* widget belongs. This method is called by the Bebop framework and should not be invoked by
|
||||
* application developers. It is somewhat questionable that this method should ever be called,
|
||||
* rather than having {@link
|
||||
* Form#respond Form.respond()} called directly.
|
||||
* Respond to an incoming request by calling <code>respond</code> on the
|
||||
* form to which the widget belongs. This method is called by the Bebop
|
||||
* framework and should not be invoked by application developers. It is
|
||||
* somewhat questionable that this method should ever be called, rather
|
||||
* than having {@link Form#respond Form.respond()} called directly.
|
||||
*
|
||||
* @throws javax.servlet.ServletException
|
||||
* @pre state != null
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -667,8 +748,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Specify a Widget.ValidationGuard implementation to use to determine if this widget should run
|
||||
* its validation listeners.
|
||||
* Specify a Widget. ValidationGuard implementation to use to determine if
|
||||
* this widget should run its validation listeners.
|
||||
*
|
||||
* @param guard the Widget.ValidationGuard.
|
||||
*/
|
||||
|
|
@ -678,8 +759,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Inner interface used to determine if the validation listeners should be run for this widget
|
||||
* or not.
|
||||
* Inner interface used to determine if the validation listeners should be
|
||||
* run for this widget or not.
|
||||
*/
|
||||
public interface ValidationGuard {
|
||||
|
||||
|
|
@ -689,18 +770,18 @@ public abstract class Widget extends BlockStylable implements Cloneable,
|
|||
/**
|
||||
* Adds an error to be displayed with this parameter.
|
||||
*
|
||||
* @param mesg A GlobalizedMessage that will resolve to the error for the user.
|
||||
* @param msg A GlobalizedMessage that will resolve to the error for the user.
|
||||
*/
|
||||
public void addError(GlobalizedMessage mesg) {
|
||||
public void addError(GlobalizedMessage msg) {
|
||||
PageState state = PageState.getPageState();
|
||||
String error = (String) mesg.localize(Kernel.getContext().getLocale());
|
||||
getParameterData(state).addError(error);
|
||||
getParameterData(state).addError(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an error to be displayed with this parameter.
|
||||
*
|
||||
* @param error A string showing the error to the user.
|
||||
* @deprecated refactor to use addError(GlobalizedMessage) instead.
|
||||
*/
|
||||
public void addError(String error) {
|
||||
getParameterData(PageState.getPageState()).addError(error);
|
||||
|
|
|
|||
|
|
@ -23,50 +23,45 @@ import com.arsdigita.globalization.Globalized;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Abstract class to be extended by globalized parameters.
|
||||
* </p>
|
||||
*
|
||||
* @version $Id: GlobalizedParameterListener.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public abstract class GlobalizedParameterListener
|
||||
implements Globalized, ParameterListener {
|
||||
|
||||
/** Name of the resource file to map keys to localized output. */
|
||||
private final static String BUNDLE_NAME =
|
||||
"com.arsdigita.bebop.parameters.ParameterResources";
|
||||
|
||||
/** Property to hold the globalized user information about the error
|
||||
* encountered. */
|
||||
private GlobalizedMessage m_error = null;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Return the base name of the target ResourceBundle.
|
||||
* </p>
|
||||
*
|
||||
* Provide client classes with the ResourceBundle to use. By default that
|
||||
* one contained in this package's ParameterResources.properties.
|
||||
* @return String target ResourceBundle base name.
|
||||
*/
|
||||
public String getBundleBaseName() {
|
||||
return BUNDLE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Get the error message for this parameter.
|
||||
* </p>
|
||||
*
|
||||
* @return GlobalizedMessage The error.
|
||||
*/
|
||||
protected GlobalizedMessage getError() {
|
||||
return m_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Set the error message for this parameter.
|
||||
* </p>
|
||||
*
|
||||
* @param error The error message to use for this parameter.
|
||||
*/
|
||||
protected void setError(GlobalizedMessage error) {
|
||||
m_error = error;
|
||||
}
|
||||
/**
|
||||
* Get the error message for this parameter.
|
||||
*
|
||||
* @return GlobalizedMessage The error.
|
||||
*/
|
||||
protected GlobalizedMessage getError() {
|
||||
return m_error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ import com.arsdigita.bebop.event.ParameterEvent;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* Verifies that the
|
||||
* parameter's value is not null.
|
||||
* Verifies that the parameter's value is not null.
|
||||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
|
|
@ -36,20 +35,41 @@ public class NotNullValidationListener extends GlobalizedParameterListener {
|
|||
|
||||
public static final NotNullValidationListener DEFAULT = new NotNullValidationListener();
|
||||
|
||||
public NotNullValidationListener(String title) {
|
||||
setError(new GlobalizedMessage(title, getBundleBaseName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor, used a default standard message as unser
|
||||
* information.
|
||||
*/
|
||||
public NotNullValidationListener() {
|
||||
setError(new GlobalizedMessage(
|
||||
"parameter_is_required", getBundleBaseName()
|
||||
));
|
||||
setError(new GlobalizedMessage("bebop.parameters.parameter_is_required",
|
||||
getBundleBaseName() ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor, provides the facility to use a custom provided user
|
||||
* information text.
|
||||
*
|
||||
* @param titleKey
|
||||
*/
|
||||
public NotNullValidationListener(String titleKey) {
|
||||
setError(new GlobalizedMessage(titleKey, getBundleBaseName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor, provides the facility to use a custom provided user
|
||||
* information text (as a GlobalizedMessage object).
|
||||
*
|
||||
* @param error
|
||||
*/
|
||||
public NotNullValidationListener(GlobalizedMessage error) {
|
||||
setError(error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the data.
|
||||
*
|
||||
* @param e Parameter event containing the data to validate.
|
||||
*/
|
||||
@Override
|
||||
public void validate (ParameterEvent e) {
|
||||
ParameterData data = e.getParameterData();
|
||||
Object value = data.getValue();
|
||||
|
|
@ -57,7 +77,7 @@ public class NotNullValidationListener extends GlobalizedParameterListener {
|
|||
if (value != null && value.toString().length() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// adds the error globalizedMessage to the ParameterData input object.
|
||||
data.addError(getError());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import com.arsdigita.bebop.FormProcessException;
|
|||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import com.arsdigita.bebop.event.ParameterListener;
|
||||
import com.arsdigita.bebop.event.ParameterEvent;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
|
||||
/**
|
||||
* Verifies that the
|
||||
* parameter's value is within a specified range.
|
||||
* Verifies that the parameter's value is within a specified range.
|
||||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
|
|
@ -39,14 +39,29 @@ public class NumberInRangeValidationListener implements ParameterListener {
|
|||
private final double m_upperBound;
|
||||
private final String m_baseErrorMsg;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
*/
|
||||
public NumberInRangeValidationListener(Number a, Number b) {
|
||||
this(a.doubleValue(),b.doubleValue());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lower
|
||||
* @param upper
|
||||
*/
|
||||
public NumberInRangeValidationListener(long lower, long upper) {
|
||||
this( (double)lower, (double)upper );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lower
|
||||
* @param upper
|
||||
*/
|
||||
public NumberInRangeValidationListener(double lower, double upper) {
|
||||
if ( upper < lower ) {
|
||||
throw new IllegalArgumentException
|
||||
|
|
@ -56,7 +71,7 @@ public class NumberInRangeValidationListener implements ParameterListener {
|
|||
m_lowerBound = lower;
|
||||
m_upperBound = upper;
|
||||
|
||||
StringBuffer msg = new StringBuffer(128);
|
||||
StringBuilder msg = new StringBuilder(128);
|
||||
msg.append("The following values are out of the specified range of (")
|
||||
.append(m_lowerBound)
|
||||
.append(",")
|
||||
|
|
@ -66,6 +81,12 @@ public class NumberInRangeValidationListener implements ParameterListener {
|
|||
m_baseErrorMsg = msg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void validate (ParameterEvent e) throws FormProcessException {
|
||||
// note: The abstract class Number is the superclass of classes
|
||||
// Byte, Double, Float, Integer, Long, and Short.
|
||||
|
|
@ -103,7 +124,10 @@ public class NumberInRangeValidationListener implements ParameterListener {
|
|||
isValid = false;
|
||||
}
|
||||
} else {
|
||||
throw new FormProcessException("Unexpected value type: " + obj.getClass());
|
||||
String[] errorMsg= new String[1];
|
||||
errorMsg[0]=obj.getClass().toString();
|
||||
throw new FormProcessException("Unexpected value type: " + obj.getClass(),
|
||||
GlobalizationUtil.globalize("bebop.parameter.unexpected_value_type",errorMsg));
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import com.arsdigita.bebop.FormProcessException;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* This class is used to manage the data associated with a single
|
||||
* parameter. A ParameterData object contains errors and values
|
||||
* associated with a given parameter.
|
||||
* This class is used to manage the data associated with a single parameter.
|
||||
* A ParameterData object contains errors and values associated with a given
|
||||
* parameter.
|
||||
*
|
||||
* @author Uday Mathur
|
||||
* @version $Id: ParameterData.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
|
|
@ -87,6 +87,7 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
* Construct a new ParameterData object with the specified name and
|
||||
* value.
|
||||
*
|
||||
* @param model
|
||||
* @param name name of the parameter model associated with this
|
||||
* parameter data
|
||||
*
|
||||
|
|
@ -100,7 +101,11 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
|
||||
/**
|
||||
* Clones this object making a new reference to the errors list.
|
||||
*
|
||||
* @return
|
||||
* @throws java.lang.CloneNotSupportedException
|
||||
*/
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ParameterData result = (ParameterData) super.clone();
|
||||
result.m_errors = (LinkedList) m_errors.clone();
|
||||
|
|
@ -114,12 +119,15 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
* @return the value of this parameter. If isArray() is true, then the
|
||||
* return value is an array
|
||||
*/
|
||||
@Override
|
||||
public final Object getValue() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ParameterModel underlying this parameter.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final ParameterModel getModel() {
|
||||
return m_model;
|
||||
|
|
@ -140,6 +148,7 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
*
|
||||
* @return getName()
|
||||
**/
|
||||
@Override
|
||||
public Object getKey() {
|
||||
return getName();
|
||||
}
|
||||
|
|
@ -153,6 +162,7 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
*
|
||||
* @return the previous value of this parameter
|
||||
**/
|
||||
@Override
|
||||
public final Object setValue(Object value) {
|
||||
Object old = m_value;
|
||||
m_value=value;
|
||||
|
|
@ -166,7 +176,6 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
* into the right object <code>o</code> so that
|
||||
* <code>getValue().equals(o)</code>.
|
||||
*
|
||||
* @param data the parameter data holding the value
|
||||
* @return the value as a readable string
|
||||
* @see ParameterModel#marshal
|
||||
*/
|
||||
|
|
@ -190,6 +199,7 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
* FormData.addError and by ParameterListeners.
|
||||
*
|
||||
* @param message The error message to add to this parameter
|
||||
* @deprecated use addError(GlobalizedMessage message) instead.
|
||||
*/
|
||||
public void addError(String message) {
|
||||
if(message != null && message.length() > 0)
|
||||
|
|
@ -197,10 +207,8 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Adds an error to this parameter. This method is called by
|
||||
* FormData.addError and by ParameterListeners.
|
||||
* </p>
|
||||
*
|
||||
* @param message GlobalizedMessage representing the error to add to this
|
||||
* parameter.
|
||||
|
|
@ -244,6 +252,8 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
/**
|
||||
* Revalidate this ParameterData. If transformation failed, and the
|
||||
* value has not been reset, this will be a no-op.
|
||||
*
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
public void validate() throws FormProcessException {
|
||||
if (isTransformed()) {
|
||||
|
|
@ -306,8 +316,9 @@ public final class ParameterData implements Map.Entry, Cloneable {
|
|||
/** Convert to a String.
|
||||
* @return a human-readable representation of <code>this</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer to = new StringBuffer();
|
||||
StringBuilder to = new StringBuilder();
|
||||
to.append("{")
|
||||
.append(m_value)
|
||||
.append(", ").append(m_errors);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
parameter_is_required=This parameter is required
|
||||
bebop.parameters.parameter_is_required=This parameter is required
|
||||
parameter_not_unique=This parameter is not unique
|
||||
string_in_range=This parameter is not between {0} and {1} characters long
|
||||
type_check={0} must be of type {1} but got {2} of type {3}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
parameter_is_required=Dieser Parameter ist erforderlich
|
||||
bebop.parameters.parameter_is_required=Dieser Parameter ist erforderlich
|
||||
parameter_not_unique=Dieser Parameter ist nicht einzigartig
|
||||
string_in_range=Dieser Parameter ist nicht zwischen {0} und {1} Zeichen lang
|
||||
type_check={0} muss vom Typ {1} sein, ist aber {2} vom Typ {3}
|
||||
parameter.only.letters.digits=Dieser Parameter darf nur Buchstaben und/oder Zahlen enthalten
|
||||
file_empty_or_not_found=ist leer oder wurde nicht gefunden.
|
||||
file_too_large=ist zu gro\u00DF
|
||||
file_too_large=ist zu gro\u00df
|
||||
uri_parameter_is_invalid=Dieser Parameter muss ein URI sein, das entsprechend RFC2396 formatiert wird
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
parameter_is_required=This parameter is required
|
||||
bebop.parameters.parameter_is_required=This parameter is required
|
||||
parameter_not_unique=This parameter is not unique
|
||||
string_in_range=This parameter is not between {0} and {1} characters long
|
||||
type_check={0} must be of type {1} but got {2} of type {3}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
parameter_is_required=Este par\u00E1metro es requerido
|
||||
string_in_range=Este par\u00E1metro no tiene entre {0} y {1} caracteres
|
||||
bebop.parameters.parameter_is_required=Este par\u00e1metro es requerido
|
||||
string_in_range=Este par\u00e1metro no tiene entre {0} y {1} caracteres
|
||||
type_check={0} tiene que ser de clase {1} pero el objecto {2} es de clase {3}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
parameter_is_required=Ce paramètre est obligatoire
|
||||
string_in_range=La longueur de ce paramètre n'est pas comprise entre {0} et {1}
|
||||
type_check={0} doit être de type {1} mais possède {2} de type {3}
|
||||
parameter.only.letters.digits=Ce paramètre ne doit contenir que des lettres ou des chiffres
|
||||
bebop.parameters.parameter_is_required=Ce param\u00e8tre est obligatoire
|
||||
string_in_range=La longueur de ce param\u00e8tre n'est pas comprise entre {0} et {1}
|
||||
type_check={0} doit \u00eatre de type {1} mais poss\u00e8de {2} de type {3}
|
||||
parameter.only.letters.digits=Ce param\u00e8tre ne doit contenir que des lettres ou des chiffres
|
||||
|
|
|
|||
|
|
@ -24,29 +24,43 @@ import com.arsdigita.bebop.event.ParameterEvent;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* Verifies that the
|
||||
* parameter's value contains only letters and/or digits.
|
||||
* Verifies that the parameter's value contains only letters and/or digits.
|
||||
*
|
||||
* @author Dennis Gregorovic
|
||||
* @version $Id: StringIsLettersOrDigitsValidationListener.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
**/
|
||||
|
||||
*/
|
||||
public class StringIsLettersOrDigitsValidationListener extends GlobalizedParameterListener {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
public StringIsLettersOrDigitsValidationListener(String title) {
|
||||
setError(new GlobalizedMessage(title, getBundleBaseName()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StringIsLettersOrDigitsValidationListener() {
|
||||
setError(new GlobalizedMessage(
|
||||
"parameter.only.letters.digits", getBundleBaseName()
|
||||
));
|
||||
setError(new GlobalizedMessage( "parameter.only.letters.digits",
|
||||
getBundleBaseName() ));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param error
|
||||
*/
|
||||
public StringIsLettersOrDigitsValidationListener(GlobalizedMessage error) {
|
||||
setError(error);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void validate (ParameterEvent e) throws FormProcessException {
|
||||
ParameterData data = e.getParameterData();
|
||||
Object obj = data.getValue();
|
||||
|
|
|
|||
|
|
@ -22,21 +22,37 @@ import com.arsdigita.globalization.Globalized;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* .
|
||||
* Contains methods to simplify globalizing keys
|
||||
* </p>
|
||||
* Compilation of methods to simplify the handling of globalizing keys.
|
||||
* Basically it adds the name of package's resource bundle files to the
|
||||
* globalize methods and forwards to GlobalizedMessage, shortening the
|
||||
* method invocation in the various application classes.
|
||||
*
|
||||
* @version $Revision: #6 $ $Date: 2004/08/16 $
|
||||
*/
|
||||
|
||||
public class GlobalizationUtil implements Globalized {
|
||||
|
||||
private static final String BUNDLE_NAME = "com.arsdigita.bebop.ui.BebopResources";
|
||||
/** Name of Java resource files to handle CMS's globalisation. */
|
||||
private static final String BUNDLE_NAME = "com.arsdigita.bebop.BebopResources";
|
||||
|
||||
/**
|
||||
* Returns a globalized message using the package specific bundle,
|
||||
* provided by BUNDLE_NAME.
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a globalized message object, using the package specific bundle,
|
||||
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
|
||||
* interpolate into the retrieved message using the MessageFormat class
|
||||
* (i.e. {0}, {1},... for adding variable strings).
|
||||
* @param key
|
||||
* @param args
|
||||
* @return new instance of a globalized message
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key, Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
categorization.cancel=Cancel
|
||||
categorization.cancel.msg=Submission Cancelled
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
categorization.cancel=Abbrechen
|
||||
categorization.cancel.msg=Bearbeitung abgebrochen
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
categorization.cancel=TRANSLATE THIS: Previous (categorization.cancel)
|
||||
categorization.cancel.msg=TRANSLATE THIS: Previous (categorization.cancel.submission.msg)
|
||||
|
|
@ -38,6 +38,7 @@ import com.arsdigita.bebop.parameters.StringParameter;
|
|||
import com.arsdigita.categorization.CategorizedObject;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryCollection;
|
||||
import com.arsdigita.categorization.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
|
|
@ -118,12 +119,10 @@ public abstract class ACSObjectCategoryForm extends Form {
|
|||
}
|
||||
|
||||
BigDecimal[] ids = (BigDecimal[]) m_category.getValue(state);
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
Category cat = (Category) DomainObjectFactory.newInstance(
|
||||
new OID(Category.BASE_DATA_OBJECT_TYPE,
|
||||
ids[i]));
|
||||
|
||||
if(!curSelectedCat.contains(ids[i])) {
|
||||
for (BigDecimal id : ids) {
|
||||
Category cat = (Category) DomainObjectFactory
|
||||
.newInstance(new OID(Category.BASE_DATA_OBJECT_TYPE, id));
|
||||
if (!curSelectedCat.contains(id)) {
|
||||
cat.addChild(object);
|
||||
} else {
|
||||
cat.removeChild(object);
|
||||
|
|
@ -143,7 +142,9 @@ public abstract class ACSObjectCategoryForm extends Form {
|
|||
|
||||
if (m_buttons.getCancelButton().isSelected(state)) {
|
||||
fireCompletionEvent(state);
|
||||
throw new FormProcessException("cancelled");
|
||||
throw new FormProcessException("Submission cancelled",
|
||||
GlobalizationUtil.globalize(
|
||||
"categorization.cancel.msg"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
|||
public class GlobalizationUtil implements Globalized {
|
||||
|
||||
private static final String BUNDLE_NAME =
|
||||
"com.arsdigita.categorization.ui.CategorizationResources";
|
||||
"com.arsdigita.categorization.CategorizationResources";
|
||||
|
||||
private GlobalizationUtil() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,10 @@ import com.arsdigita.globalization.Globalization;
|
|||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
/**
|
||||
* MultipartHttpServletRequest provides
|
||||
* multipart/form-data handling capabilities to facilitate file
|
||||
* uploads for servlets. This request object parses the HTTP request
|
||||
* with MIME type "multipart" and places the encoded object in a
|
||||
* stream.
|
||||
* MultipartHttpServletRequest provides multipart/form-data handling
|
||||
* capabilities to facilitate file uploads for servlets.
|
||||
* This request object parses the HTTP request with MIME type "multipart" and
|
||||
* places the encoded object in a stream.
|
||||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Michael Pih
|
||||
|
|
@ -72,6 +71,8 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
* Create a multipart servlet request object and parse the request.
|
||||
*
|
||||
* @param request The request
|
||||
* @throws javax.mail.MessagingException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public MultipartHttpServletRequest(HttpServletRequest request)
|
||||
throws MessagingException, IOException {
|
||||
|
|
@ -83,7 +84,8 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
/**
|
||||
* Create a multipart servlet request object and parse the request.
|
||||
*
|
||||
* @param request The request
|
||||
* @param original
|
||||
* @param current
|
||||
*/
|
||||
public MultipartHttpServletRequest(MultipartHttpServletRequest original,
|
||||
HttpServletRequest current) {
|
||||
|
|
@ -91,14 +93,31 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
m_parameters = original.m_parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return m_request.getAttribute(name);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Enumeration getAttributeNames() {
|
||||
return m_request.getAttributeNames();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
String[] values = (String[]) m_parameters.get(name);
|
||||
|
||||
|
|
@ -109,18 +128,38 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map getParameterMap() {
|
||||
return m_parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Enumeration getParameterNames() {
|
||||
return Collections.enumeration(m_parameters.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public String getFileName(String name) {
|
||||
return getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public File getFile(String name) {
|
||||
String path = getParameter(name + ".tmpfile");
|
||||
|
||||
|
|
@ -131,16 +170,32 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
return (String[]) m_parameters.get(name);
|
||||
}
|
||||
|
||||
// Additional methods for HttpServletRequest
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return m_request.getAuthType();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Cookie[] getCookies() {
|
||||
return m_request.getCookies();
|
||||
}
|
||||
|
|
@ -214,10 +269,21 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
* of Servlet specification 2.3 which was resolved later. So it should be
|
||||
* save to use it now. (2012-02-06)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StringBuffer getRequestURL() {
|
||||
return m_request.getRequestURL();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return m_request.getServletPath();
|
||||
}
|
||||
|
|
@ -252,6 +318,12 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
|||
return m_request.getCharacterEncoding();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param encoding
|
||||
* @throws java.io.UnsupportedEncodingException
|
||||
*/
|
||||
@Override
|
||||
public void setCharacterEncoding(String encoding)
|
||||
throws java.io.UnsupportedEncodingException {
|
||||
throw new UnsupportedOperationException
|
||||
|
|
|
|||
|
|
@ -64,3 +64,5 @@ formbuilder.ui.form_action.add_button=Add Form Action
|
|||
formbuilder.ui.form_action.delete_confirm=Are you sure you wish to delete this action?
|
||||
formbuilder.ui.move=move
|
||||
formbuilder.ui.delete_confirm=Are you sure you wish to delete this widget?
|
||||
formbuilder.ui.cancel=Cancel
|
||||
formbuilder.ui.cancel_msg=Submission Cancelled
|
||||
|
|
|
|||
|
|
@ -64,3 +64,5 @@ formbuilder.ui.form_action.add_button=Formularaktion hinzuf\u00fcgen
|
|||
formbuilder.ui.form_action.delete_confirm=Sind sie sicher, diese Aktion zu l\u00f6schen?
|
||||
formbuilder.ui.move=verschieben
|
||||
formbuilder.ui.delete_confirm=Sind Sie sicher, dieses Element zu l\u00f6schen?
|
||||
formbuilder.ui.cancel=Abbrechen
|
||||
formbuilder.ui.cancel_msg=Bearbeitung abgebrochen
|
||||
|
|
|
|||
|
|
@ -56,3 +56,5 @@ formbuilder.ui.form_action.add_button=Add Form Action
|
|||
formbuilder.ui.form_action.delete_confirm=Are you sure you wish to delete this action?
|
||||
formbuilder.ui.move=move
|
||||
formbuilder.ui.delete_confirm=Are you sure you wish to delete this widget?
|
||||
formbuilder.ui.cancel=Cancel
|
||||
formbuilder.ui.cancel_msg=Submission Cancelled
|
||||
|
|
|
|||
|
|
@ -29,53 +29,100 @@ import com.arsdigita.bebop.PageState;
|
|||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.formbuilder.util.GlobalizationUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PropertiesForm extends Form {
|
||||
SaveCancelSection m_buttons;
|
||||
String m_app;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public PropertiesForm(String name) {
|
||||
super(name);
|
||||
|
||||
createWidgets();
|
||||
|
||||
addSubmissionListener(new FormSubmissionListener() {
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
if (m_buttons.getCancelButton().isSelected(e.getPageState()))
|
||||
throw new FormProcessException("Cancel pressed");
|
||||
throw new FormProcessException(
|
||||
"Cancel pressed",
|
||||
GlobalizationUtil.globalize("formbuilder.ui.cancel_msg")
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param app
|
||||
*/
|
||||
public void setApplication(String app) {
|
||||
m_app = app;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getApplication() {
|
||||
return m_app;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void createWidgets() {
|
||||
addWidgets(this);
|
||||
addButtons(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param section
|
||||
*/
|
||||
protected void addWidgets(FormSection section) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param section
|
||||
*/
|
||||
protected void addButtons(FormSection section) {
|
||||
m_buttons = new SaveCancelSection();
|
||||
section.add(new Label("")); // Padding
|
||||
section.add(m_buttons);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
public boolean isComplete(PageState state) {
|
||||
return m_buttons.getCancelButton().isSelected(state) ||
|
||||
m_buttons.getSaveButton().isSelected(state);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
public boolean isCancelled(PageState state) {
|
||||
return m_buttons.getCancelButton().isSelected(state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,38 +18,43 @@
|
|||
*/
|
||||
package com.arsdigita.formbuilder.ui.editors;
|
||||
|
||||
import com.arsdigita.formbuilder.WidgetLabel;
|
||||
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.FormSection;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.form.Widget;
|
||||
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
|
||||
import com.arsdigita.formbuilder.PersistentWidget;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.arsdigita.formbuilder.PersistentFormSection;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.formbuilder.PersistentLabel;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.form.Widget;
|
||||
import com.arsdigita.formbuilder.PersistentWidget;
|
||||
import com.arsdigita.formbuilder.PersistentFormSection;
|
||||
import com.arsdigita.formbuilder.WidgetLabel;
|
||||
|
||||
import com.arsdigita.formbuilder.util.GlobalizationUtil ;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class WidgetLabelForm extends WidgetForm {
|
||||
private Widget m_label;
|
||||
|
||||
|
|
@ -60,6 +65,7 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
super(name, form, control);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets(FormSection section) {
|
||||
|
||||
if (wantLabelMultiline()) {
|
||||
|
|
@ -94,6 +100,7 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @deprecated used getGlobalizedLabelText()
|
||||
*/
|
||||
protected String getLabelText() {
|
||||
|
|
@ -117,6 +124,7 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initWidgets(FormSectionEvent e,
|
||||
PersistentWidget widget)
|
||||
throws FormProcessException {
|
||||
|
|
@ -137,6 +145,7 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processWidgets(FormSectionEvent e,
|
||||
PersistentWidget widget)
|
||||
throws FormProcessException {
|
||||
|
|
@ -162,6 +171,13 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
l.save();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @param widget
|
||||
* @throws FormProcessException
|
||||
*/
|
||||
@Override
|
||||
protected void addToForm(FormSectionEvent e,
|
||||
PersistentWidget widget)
|
||||
throws FormProcessException {
|
||||
|
|
@ -198,6 +214,11 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
* this step is ignored if needed.
|
||||
*
|
||||
* This will return null if not label is actually added.
|
||||
*
|
||||
* @param widget
|
||||
* @param label
|
||||
* @param form
|
||||
* @return
|
||||
*/
|
||||
protected WidgetLabel addWidgetLabel(PersistentWidget widget,
|
||||
String label,
|
||||
|
|
@ -211,6 +232,7 @@ public abstract class WidgetLabelForm extends WidgetForm {
|
|||
/**
|
||||
* Added by CS Gupta to make Name Field invisible In EmailFormField.
|
||||
* Should Name Html Control be on the form? Can be overridden by sub classes.
|
||||
* @return
|
||||
*/
|
||||
protected boolean isEmailFormField()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,22 +22,38 @@ import com.arsdigita.globalization.Globalized;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* .
|
||||
* Contains methods to simplify globalizing keys
|
||||
* </p>
|
||||
* Compilation of methods to simplify the handling of globalizing keys.
|
||||
* Basically it adds the name of package's resource bundle files to the
|
||||
* globalize methods and forwards to GlobalizedMessage, shortening the
|
||||
* method invocation in the various application classes.
|
||||
*
|
||||
* @version $Revision: #6 $ $Date: 2004/08/16 $
|
||||
*/
|
||||
|
||||
public class GlobalizationUtil implements Globalized {
|
||||
|
||||
/** Name of Java resource files to handle CMS's globalisation. */
|
||||
private static final String BUNDLE_NAME =
|
||||
"com.arsdigita.formbuilder.FormbuilderResources";
|
||||
|
||||
/**
|
||||
* Returns a globalized message using the package specific bundle,
|
||||
* provided by BUNDLE_NAME.
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a globalized message object, using the package specific bundle,
|
||||
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
|
||||
* interpolate into the retrieved message using the MessageFormat class
|
||||
* (i.e. {0}, {1},... for adding variable strings).
|
||||
* @param key
|
||||
* @param args
|
||||
* @return new instance of a globalized message
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key, Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
toolbox.ui.na=N/A
|
||||
toolbox.ui.no_results=No Results.
|
||||
toolbox.ui.cancel=Cancel
|
||||
toolbox.ui.cancel_msg=Submission Cancel
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
toolbox.ui.na=(nicht eingetragen)
|
||||
toolbox.ui.no_results=Keine Ergebnisse.
|
||||
toolbox.ui.cancel=Abbrechen
|
||||
toolbox.ui.cancel_msg=Bearbeitung abgebrochen
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
toolbox.ui.na=N/A
|
||||
toolbox.ui.no_results=Pas de r\u00e9sultats
|
||||
toolbox.ui.cancel=Cancel
|
||||
toolbox.ui.cancel_msg=Submission Cancel
|
||||
|
|
@ -41,9 +41,10 @@ import com.arsdigita.bebop.parameters.ArrayParameter;
|
|||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
// Stacktraces is a support tool to use in a specifically difficult development
|
||||
// situation. It is abundant in production and for normal development work and
|
||||
// it provved to have funny side effects in a production environment. So it is
|
||||
// it proved to have funny side effects in a production environment. So it is
|
||||
// commented out here but kept for further references.
|
||||
// import com.arsdigita.developersupport.StackTraces;
|
||||
import com.arsdigita.toolbox.util.GlobalizationUtil;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -339,6 +340,7 @@ public class ModalPanel extends ComponentMap {
|
|||
m_target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void process(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
push(e.getPageState(), m_target);
|
||||
|
|
@ -363,6 +365,7 @@ public class ModalPanel extends ComponentMap {
|
|||
m_target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void process(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
final PageState state = e.getPageState();
|
||||
|
|
@ -401,6 +404,7 @@ public class ModalPanel extends ComponentMap {
|
|||
m_model = model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void submitted(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
final PageState state = e.getPageState();
|
||||
|
|
@ -422,7 +426,9 @@ public class ModalPanel extends ComponentMap {
|
|||
m_model.clearSelection(state);
|
||||
}
|
||||
|
||||
throw new FormProcessException("cancelled");
|
||||
throw new FormProcessException("cancelled",
|
||||
GlobalizationUtil.globalize(
|
||||
"toolbox.ui.cancel_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
toolbox.ui.na=N/A
|
||||
toolbox.ui.no_results=No Results.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
toolbox.ui.na=N/A
|
||||
toolbox.ui.no_results=Pas de r\u00e9sultats
|
||||
|
|
@ -136,3 +136,5 @@ ui.admin.user.userinfo.screenname=Username:
|
|||
ui.admin.user.userinfo.primaryemail=Email:
|
||||
ui.admin.groups.name=Name:
|
||||
ui.admin.applications.placeholder=There is no administration panel for instances of this application type yet.
|
||||
ui.admin.cancel=Cancel
|
||||
ui.admin.cancel_msg=Submission cancelled
|
||||
|
|
|
|||
|
|
@ -136,3 +136,5 @@ ui.admin.user.userinfo.screenname=Benutzername:
|
|||
ui.admin.user.userinfo.primaryemail=E-Mail:
|
||||
ui.admin.groups.name=Name:
|
||||
ui.admin.applications.placeholder=F\u00fcr Applikationen dieses Typs gibt es noch keine Verwaltungsoberfl\u00e4che.
|
||||
ui.admin.cancel=Abbrechen
|
||||
ui.admin.cancel_msg=Bearbeitung abgebrochen
|
||||
|
|
|
|||
|
|
@ -136,3 +136,5 @@ ui.admin.user.userinfo.screenname=
|
|||
ui.admin.user.userinfo.primaryemail=
|
||||
ui.admin.groups.name=
|
||||
ui.admin.applications.placeholder=
|
||||
ui.admin.cancel=Cancel
|
||||
ui.admin.cancel_msg=Submission cancelled
|
||||
|
|
|
|||
|
|
@ -122,3 +122,5 @@ ui.admin.user.userinfo.screenname=
|
|||
ui.admin.user.userinfo.primaryemail=
|
||||
ui.admin.groups.name=
|
||||
ui.admin.applications.placeholder=
|
||||
ui.admin.cancel=Cancel
|
||||
ui.admin.cancel_msg=Submission cancelled
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
package com.arsdigita.ui.admin.applications;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
//import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Container;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
|
|
@ -49,16 +49,18 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
import com.arsdigita.web.Application;
|
||||
import com.arsdigita.web.ApplicationCollection;
|
||||
import com.arsdigita.web.ApplicationType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
* Basic form for creating new Application instances. Should be suitable for most applications types. If you have
|
||||
* special needs... $todo
|
||||
* Basic form for creating new Application instances. Should be suitable for
|
||||
* most applications types. If you have special needs... $todo
|
||||
*
|
||||
* This form does not support parent/child application structures. If your app needs this, add a widget for selecting
|
||||
* the parent application and extend the process method.
|
||||
* This form does not support parent/child application structures. If your app
|
||||
* needs this, add a widget for selecting the parent application and extend
|
||||
* the process method.
|
||||
*
|
||||
* @param <T> Type of application
|
||||
*
|
||||
|
|
@ -108,6 +110,7 @@ public class ApplicationCreateForm<T extends Application> extends Form implement
|
|||
parentApp = new SingleSelect(PARENT_APP);
|
||||
try {
|
||||
parentApp.addPrintListener(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
target.addOption(new Option("", ""));
|
||||
|
|
@ -195,6 +198,7 @@ public class ApplicationCreateForm<T extends Application> extends Form implement
|
|||
return saveCancelSection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -229,6 +233,7 @@ public class ApplicationCreateForm<T extends Application> extends Form implement
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -238,23 +243,32 @@ public class ApplicationCreateForm<T extends Application> extends Form implement
|
|||
applicationUrl.setValue(state, "");
|
||||
applicationDesc.setValue(state, "");
|
||||
|
||||
throw new FormProcessException("Canceled");
|
||||
throw new FormProcessException("Cancelled",
|
||||
GlobalizationUtil.globalize(
|
||||
"ui.admin.cancel_msg"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
/** */
|
||||
final PageState state = event.getPageState();
|
||||
/** */
|
||||
final String url = (String) applicationUrl.getValue(state);
|
||||
|
||||
if (url.contains("/")) {
|
||||
throw new FormProcessException((String) GlobalizationUtil.globalize(
|
||||
"ui.admin.applications.url.validation.no_slash_allowed").localize());
|
||||
throw new FormProcessException(
|
||||
"The URL fragement may not contain slashes",
|
||||
GlobalizationUtil.globalize(
|
||||
"ui.admin.applications.url.validation.no_slash_allowed"));
|
||||
}
|
||||
|
||||
if (Application.isInstalled(Application.BASE_DATA_OBJECT_TYPE, url)) {
|
||||
throw new FormProcessException((String) GlobalizationUtil.globalize(
|
||||
"ui.admin.applications.url.validation.url_already_in_use").localize());
|
||||
throw new FormProcessException(
|
||||
"The provided URL is already in use",
|
||||
GlobalizationUtil.globalize(
|
||||
"ui.admin.applications.url.validation.url_already_in_use"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ login.error.duplicateEmail=Some other user has this email address
|
|||
login.error.mismatchPassword=New passwords must match
|
||||
login.error.badPassword=Incorrect password
|
||||
login.error.badAnswer=Incorrect answer
|
||||
login.error.badEmail=Unrecognized email address
|
||||
login.error.badEmail=Unrecognized email address {0}
|
||||
login.error.bannedEmail=User cannot currently access system
|
||||
login.error.loginFail=Login failed
|
||||
login.changePasswortForm.greeting=Welcome {0}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ login.error.duplicateEmail=Ein anderer Nutzer verwendet diese E-Mail Adresse
|
|||
login.error.mismatchPassword=Die neuen Passw\u00f6rter m\u00fcssen gleich sein
|
||||
login.error.badPassword=Falsches Passwort
|
||||
login.error.badAnswer=Falsche Antwort
|
||||
login.error.badEmail=Ung\u00fcltige E-Mail Adresse
|
||||
login.error.badEmail=Ung\u00fcltige E-Mail Adresse: {0}
|
||||
login.error.bannedEmail=Benutzer kann zur Zeit das System nicht nutzen
|
||||
login.error.loginFail=Anmeldung nicht erfolgreich
|
||||
login.changePasswortForm.greeting=Willkommen {0}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ login.error.duplicateEmail=Some other user has this email address
|
|||
login.error.mismatchPassword=New passwords must match
|
||||
login.error.badPassword=Incorrect password
|
||||
login.error.badAnswer=Incorrect answer
|
||||
login.error.badEmail=Unrecognized email address
|
||||
login.error.badEmail=Unrecognized email address {0}
|
||||
login.error.bannedEmail=User cannot currently access system
|
||||
login.error.loginFail=Login failed
|
||||
login.changePasswortForm.greeting=Welcome {0}
|
||||
|
|
|
|||
|
|
@ -269,8 +269,12 @@ public abstract class UserForm extends Form
|
|||
try {
|
||||
address = new InternetAddress(user.getPrimaryEmail().toString());
|
||||
} catch(AddressException e) {
|
||||
throw new FormProcessException("Email address is bad: "
|
||||
+ user.getPrimaryEmail());
|
||||
String[] errorMsg = new String[1];
|
||||
errorMsg[0] = user.getPrimaryEmail().toString();
|
||||
throw new FormProcessException(
|
||||
"Email address is bad: " + user.getPrimaryEmail(),
|
||||
LoginHelper.getMessage("login.error.badEmail",errorMsg)
|
||||
);
|
||||
}
|
||||
|
||||
m_email.setValue(state, address);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ import org.apache.log4j.Logger;
|
|||
public abstract class BaseApplicationServlet extends BaseServlet {
|
||||
|
||||
/** Logger instance for debugging purpose. */
|
||||
private static Logger s_log = Logger.getLogger(BaseApplicationServlet.class);
|
||||
private static final Logger s_log = Logger.getLogger(BaseApplicationServlet.class);
|
||||
|
||||
/**
|
||||
* <p>The ID of the application whose service is requested. This
|
||||
|
|
@ -92,6 +92,8 @@ public abstract class BaseApplicationServlet extends BaseServlet {
|
|||
* <p>Augments the context of the request and delegates to {@link
|
||||
* #doService(HttpServletRequest,HttpServletResponse,Application)}.</p>
|
||||
*
|
||||
* @throws javax.servlet.ServletException
|
||||
* @throws java.io.IOException
|
||||
* @see com.arsdigita.web.BaseServlet#doService(HttpServletRequest,HttpServletResponse)
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -117,6 +119,7 @@ public abstract class BaseApplicationServlet extends BaseServlet {
|
|||
final IOException[] ioException = { null };
|
||||
|
||||
new KernelExcursion() {
|
||||
@Override
|
||||
protected final void excurse() {
|
||||
setLocale(rc.getLocale());
|
||||
setResource(app);
|
||||
|
|
@ -141,12 +144,17 @@ public abstract class BaseApplicationServlet extends BaseServlet {
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>The method that {@link
|
||||
* #doService(HttpServletRequest,HttpServletResponse)} calls.
|
||||
* The method that {@link #doService(HttpServletRequest,HttpServletResponse)}
|
||||
* calls.
|
||||
* Servlet authors should implement this method to perform
|
||||
* application-specific request handling.</p>
|
||||
*
|
||||
* application-specific request handling
|
||||
* @see javax.servlet.http.HttpServlet#service(HttpServletRequest,HttpServletResponse)
|
||||
*
|
||||
* @param sreq
|
||||
* @param sresp
|
||||
* @param app
|
||||
* @throws javax.servlet.ServletException
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
protected abstract void doService(HttpServletRequest sreq,
|
||||
HttpServletResponse sresp,
|
||||
|
|
@ -212,31 +220,6 @@ public abstract class BaseApplicationServlet extends BaseServlet {
|
|||
final KernelRequestContext krc = new KernelRequestContext
|
||||
(irc, sc, uc);
|
||||
|
||||
// SiteNode node = null;
|
||||
// Experimental:
|
||||
// if (node == null) {
|
||||
// return krc;
|
||||
// }
|
||||
|
||||
// try {
|
||||
// node = SiteNode.getSiteNode(app.getPrimaryURL(),
|
||||
// true);
|
||||
// } catch (DataObjectNotFoundException ex) {
|
||||
// throw new UncheckedWrapperException("cannot find root sitenode");
|
||||
// }
|
||||
|
||||
// if (node == null) {
|
||||
// s_log.debug("There is no site node at this URL; storing a " +
|
||||
// "KernelRequestContext");
|
||||
|
||||
return krc;
|
||||
// } else {
|
||||
// s_log.debug("Creating a SiteNodeRequestContext");
|
||||
|
||||
// final SiteNodeRequestContext snrc = new SiteNodeRequestContext
|
||||
// (sreq, krc, node, sreq.getServletPath() + "/");
|
||||
|
||||
// return snrc;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
|
|||
|
||||
private void setup() {
|
||||
addInitListener(new FormInitListener() {
|
||||
@Override
|
||||
public void init(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
|
@ -99,6 +100,7 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
|
|||
|
||||
});
|
||||
addValidationListener(new FormValidationListener() {
|
||||
@Override
|
||||
public void validate(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
|
@ -148,7 +150,9 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection {
|
|||
|
||||
/**
|
||||
* Initialize the form fields
|
||||
* @param state
|
||||
* @param application the application being edited, if any
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
protected void initWidgets(PageState state,
|
||||
Application application)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.london.cms.freeform.ui;
|
||||
|
||||
import com.arsdigita.bebop.form.FormErrorDisplay;
|
||||
|
|
@ -9,38 +28,33 @@ import com.arsdigita.bebop.event.FormInitListener;
|
|||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
|
||||
|
||||
import com.arsdigita.london.cms.freeform.asset.FreeformTextAsset;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.TextAssetBody;
|
||||
import com.arsdigita.london.cms.freeform.FreeformContentItem;
|
||||
import com.arsdigita.london.cms.freeform.asset.FreeformTextAsset;
|
||||
import com.arsdigita.db.Sequences;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import java.math.BigDecimal;
|
||||
import com.arsdigita.cms.TextAsset;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
/**
|
||||
* FreeformTextAssetEdit
|
||||
*
|
||||
* @author slater@arsdigita.com
|
||||
*
|
||||
* This is a fragment, meant for edit/creating FreeformTextAssets.
|
||||
* FreeformTextAssetEdit is a fragment, meant for edit/creating
|
||||
* FreeformTextAssets.
|
||||
* It should ultimately be combined with something that will do the
|
||||
* same for FreeformBinaryAssets
|
||||
*
|
||||
* Modelled after some cms code {@link TextPageBody}
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
* @author slater@arsdigita.com
|
||||
*/
|
||||
public class FreeformTextAssetEdit extends TextAssetBody {
|
||||
|
||||
//Members
|
||||
|
|
@ -53,7 +67,8 @@ public class FreeformTextAssetEdit extends TextAssetBody {
|
|||
private static final String DESCRIPTION = "description";
|
||||
// private TextField m_name;
|
||||
private TextField m_description;
|
||||
//private static final String NAME_ERROR_MESSAGE = "Name must be unique and only have letters and numbers";
|
||||
//private static final String NAME_ERROR_MESSAGE =
|
||||
//"Name must be unique and only have letters and numbers";
|
||||
|
||||
|
||||
// Member/Listeners for the extension of the form from TextAssetBody
|
||||
|
|
@ -61,13 +76,13 @@ public class FreeformTextAssetEdit extends TextAssetBody {
|
|||
private FormProcessListener m_ff_ProcessListener;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param itemModel the item model that represents the FreeformContentItem
|
||||
* @param assetModel the model that represents the asset we are editing
|
||||
**/
|
||||
public FreeformTextAssetEdit(SingleSelectionModel assetModel, ItemSelectionModel itemModel, ViewAssets viewAssets ) {
|
||||
public FreeformTextAssetEdit(SingleSelectionModel assetModel,
|
||||
ItemSelectionModel itemModel,
|
||||
ViewAssets viewAssets ) {
|
||||
|
||||
super(new ItemSelectionModel(assetModel));
|
||||
|
||||
|
|
@ -99,7 +114,8 @@ public class FreeformTextAssetEdit extends TextAssetBody {
|
|||
|
||||
BigDecimal assetID = Sequences.getNextValue();
|
||||
t.setID(assetID);
|
||||
t.setName(((ContentItem)m_FreeformContentItemModel.getSelectedObject(ps)).getName() + "_freeform_text_" + assetID);
|
||||
t.setName(((ContentItem)m_FreeformContentItemModel.getSelectedObject(ps))
|
||||
.getName() + "_freeform_text_" + assetID);
|
||||
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
|
|
@ -115,8 +131,8 @@ public class FreeformTextAssetEdit extends TextAssetBody {
|
|||
|
||||
// Add the new asset to the FreeformContentItem and persist the
|
||||
// changes before returning
|
||||
FreeformContentItem item =
|
||||
(FreeformContentItem)m_FreeformContentItemModel.getSelectedObject(ps);
|
||||
FreeformContentItem item = (FreeformContentItem)m_FreeformContentItemModel
|
||||
.getSelectedObject(ps);
|
||||
t.save();
|
||||
item.addAsset(t, new Integer(0));
|
||||
item.save();
|
||||
|
|
@ -141,7 +157,6 @@ public class FreeformTextAssetEdit extends TextAssetBody {
|
|||
protected void updateTextAsset(PageState ps, TextAsset a) {
|
||||
|
||||
// assign it to the parent FreeformContentItem
|
||||
// (stas says this is unreliable) FreeformContentItem ffci = ((CMSPage) state.getPage()).getContentItem(state);
|
||||
a.setParent((ContentItem)m_FreeformContentItemModel.getSelectedObject(ps));
|
||||
|
||||
//save it.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.london.cms.freeform.ui;
|
||||
|
||||
import com.arsdigita.london.cms.freeform.FreeformContentItem;
|
||||
|
|
@ -33,7 +52,7 @@ import com.arsdigita.bebop.table.TableColumn;
|
|||
*
|
||||
* @author <a href="mailto:phong@arsdigita.com">Phong Nguyen</a>
|
||||
* @version $Revision: #2 $
|
||||
**/
|
||||
*/
|
||||
public class ViewAssets extends ResettableContainer {
|
||||
|
||||
// $Source: /cvsroot/content-types/apps/freeform/src/ui/ViewAssets.java,v $
|
||||
|
|
@ -48,8 +67,8 @@ public class ViewAssets extends ResettableContainer {
|
|||
public static final String TEXT_ASSET_EDIT_KEY = "taek";
|
||||
public static final String BINARY_ASSET_EDIT_KEY = "baek";
|
||||
|
||||
private AuthoringKitWizard m_kitWizard;
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private final AuthoringKitWizard m_kitWizard;
|
||||
private final ItemSelectionModel m_itemModel;
|
||||
private ItemSelectionModel m_assetModel;
|
||||
|
||||
private FreeformAssetTable m_assetTable;
|
||||
|
|
@ -80,7 +99,9 @@ public class ViewAssets extends ResettableContainer {
|
|||
/**
|
||||
* Builds a container which holds a {@link AssetTable} and a link
|
||||
* to add a new {@link Asset}.
|
||||
**/
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected Container buildTablePanel() {
|
||||
ColumnPanel c = new ColumnPanel(1);
|
||||
c.setKey(ASSET_TABLE_KEY);
|
||||
|
|
@ -99,6 +120,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
emptyView.setFontWeight(Label.ITALIC);
|
||||
m_assetTable.setEmptyView(emptyView);
|
||||
m_assetTable.addTableActionListener(new TableActionListener() {
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
TableColumn tc = m_assetTable.getColumnModel()
|
||||
.get(event.getColumn().intValue());
|
||||
|
|
@ -107,6 +129,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
onlyShowComponent(event.getPageState(), ASSET_VIEW_KEY);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void headSelected(TableActionEvent event) {}
|
||||
});
|
||||
|
||||
|
|
@ -123,6 +146,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
ActionLink addLink = new ActionLink("Add text asset");
|
||||
addLink.setClassAttr("actionLink");
|
||||
addLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -136,6 +160,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
addLink = new ActionLink("Add binary asset");
|
||||
addLink.setClassAttr("actionLink");
|
||||
addLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -152,6 +177,8 @@ public class ViewAssets extends ResettableContainer {
|
|||
/**
|
||||
* Builds a container which holds the {@link FreeformAssetView}
|
||||
* and a link to edit the displayed asset.
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
protected Container buildViewPanel() {
|
||||
ColumnPanel c = new ColumnPanel(1);
|
||||
|
|
@ -167,6 +194,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
ActionLink editLink = new ActionLink("Edit asset");
|
||||
editLink.setClassAttr("actionLink");
|
||||
editLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
Asset asset = (Asset)m_assetModel.getSelectedObject(state);
|
||||
|
|
@ -192,9 +220,12 @@ public class ViewAssets extends ResettableContainer {
|
|||
ActionLink viewAllLink = new ActionLink("View all assets");
|
||||
viewAllLink.setClassAttr("actionLink");
|
||||
viewAllLink.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
onlyShowComponent(event.getPageState(), ASSET_TABLE_KEY);
|
||||
}
|
||||
|
||||
});
|
||||
c.add(viewAllLink);
|
||||
|
||||
|
|
@ -204,7 +235,9 @@ public class ViewAssets extends ResettableContainer {
|
|||
|
||||
/**
|
||||
* Builds a container which holds the {@link FreeformTextAssetEdit}.
|
||||
**/
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected Container buildTextEditPanel() {
|
||||
ColumnPanel c = new ColumnPanel(1);
|
||||
c.setKey(TEXT_ASSET_EDIT_KEY);
|
||||
|
|
@ -212,6 +245,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
c.setPadColor("#ffffff");
|
||||
|
||||
c.add(new Label(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(PrintEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
Label label = (Label)event.getTarget();
|
||||
|
|
@ -232,6 +266,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
ActionLink viewAllLink = new ActionLink("View all assets");
|
||||
viewAllLink.setClassAttr("actionLink");
|
||||
viewAllLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
onlyShowComponent(event.getPageState(), ASSET_TABLE_KEY);
|
||||
}
|
||||
|
|
@ -244,6 +279,8 @@ public class ViewAssets extends ResettableContainer {
|
|||
|
||||
/**
|
||||
* Builds a container which holds the {@link FreeformBinaryAssetEdit}.
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
protected Container buildBinaryEditPanel() {
|
||||
ColumnPanel c = new ColumnPanel(1);
|
||||
|
|
@ -252,6 +289,12 @@ public class ViewAssets extends ResettableContainer {
|
|||
c.setPadColor("#ffffff");
|
||||
|
||||
c.add(new Label(new PrintListener() {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void prepare(PrintEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
Label label = (Label)event.getTarget();
|
||||
|
|
@ -270,6 +313,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
|
||||
// Retrieves the newly created or editted asset and updates the item.
|
||||
m_binaryAssetEdit.addSubmissionListener(new FormSubmissionListener() {
|
||||
|
||||
public void submitted(FormSectionEvent event) throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -290,6 +334,7 @@ public class ViewAssets extends ResettableContainer {
|
|||
ActionLink viewAllLink = new ActionLink("View all assets");
|
||||
viewAllLink.setClassAttr("actionLink");
|
||||
viewAllLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
onlyShowComponent(event.getPageState(), ASSET_TABLE_KEY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
shortcuts.ui.invalid_key=Invalid Key
|
||||
shortcuts.ui.duplicate_key=Duplicate Key
|
||||
shortcuts.ui.key_already_exists=That key already exists!
|
||||
shortcuts.ui.invalid_key_descr=URL key must start with the character '/' and only contain characters a-z, A-Z, 0-9, -, ., -
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
shortcuts.ui.invalid_key=ung\u00fcltiger Schl\u00fcssel
|
||||
shortcuts.ui.duplicate_key=Doppelter Schl\u00fcssel
|
||||
shortcuts.ui.key_already_exists=Dieser Schl\u00fcssel existiert bereits!
|
||||
shortcuts.ui.invalid_key_descr=URL muss mit dem Zeichen '/' beginnen und nur die Zeichen a-z, A-Z, 0-9, -, ., - enhalten.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
shortcuts.ui.invalid_key=TRANSLATE: Invalid Key
|
||||
shortcuts.ui.duplicate_key=TRANSLATE: Duplicate Key
|
||||
shortcuts.ui.key_already_exists=That key already exists!
|
||||
shortcuts.ui.invalid_key_descr=URL
|
||||
|
|
@ -21,26 +21,28 @@ package com.arsdigita.shortcuts.ui;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormValidationListener;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.shortcuts.ShortcutUtil;
|
||||
import com.arsdigita.shortcuts.Shortcut;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.ParameterListener;
|
||||
import com.arsdigita.bebop.event.ParameterEvent;
|
||||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import org.apache.log4j.Category;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.shortcuts.ShortcutUtil;
|
||||
import com.arsdigita.shortcuts.Shortcut;
|
||||
import com.arsdigita.shortcuts.util.GlobalizationUtil;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import org.apache.oro.text.perl.Perl5Util;
|
||||
import org.apache.oro.text.perl.MalformedPerl5PatternException;
|
||||
|
||||
|
|
@ -55,7 +57,7 @@ public class ShortcutForm extends Form {
|
|||
|
||||
private TextField m_redirect;
|
||||
|
||||
private Submit m_submit;
|
||||
private final Submit m_submit;
|
||||
|
||||
public ShortcutForm(ACSObjectSelectionModel selected_shortcut) {
|
||||
super("ShortcutForm");
|
||||
|
|
@ -74,6 +76,7 @@ public class ShortcutForm extends Form {
|
|||
m_redirect = new TextField(redirectParameter);
|
||||
|
||||
urlKeyParameter.addParameterListener(new ParameterListener() {
|
||||
@Override
|
||||
public void validate(ParameterEvent e) throws FormProcessException {
|
||||
ParameterData data = e.getParameterData();
|
||||
|
||||
|
|
@ -85,10 +88,12 @@ public class ShortcutForm extends Form {
|
|||
Perl5Util perl = new Perl5Util();
|
||||
try {
|
||||
if (!perl.match("/^(\\/[-a-zA-Z0-9_.]+)+\\/?$/", key)) {
|
||||
data.addError("URL key must start with the "
|
||||
+ "character '/' and only contains "
|
||||
+ "a-z, A-Z, 0-9, -, ., -");
|
||||
throw new FormProcessException("Invalid key");
|
||||
data.addError(GlobalizationUtil.globalize(
|
||||
"shortcuts.ui.invalid_key_descr"));
|
||||
throw new FormProcessException(
|
||||
"Invalid key",
|
||||
GlobalizationUtil.globalize("shortcuts.ui.invalid_key")
|
||||
);
|
||||
}
|
||||
} catch (MalformedPerl5PatternException ex) {
|
||||
throw new UncheckedWrapperException("bad regex", ex);
|
||||
|
|
@ -97,6 +102,7 @@ public class ShortcutForm extends Form {
|
|||
});
|
||||
|
||||
redirectParameter.addParameterListener(new ParameterListener() {
|
||||
@Override
|
||||
public void validate(ParameterEvent e) throws FormProcessException {
|
||||
ParameterData data = e.getParameterData();
|
||||
|
||||
|
|
@ -141,6 +147,7 @@ public class ShortcutForm extends Form {
|
|||
}
|
||||
|
||||
private class ShortcutInitListener implements FormInitListener {
|
||||
@Override
|
||||
public void init(FormSectionEvent ev) throws FormProcessException {
|
||||
PageState state = ev.getPageState();
|
||||
BigDecimal shortcutKey = (BigDecimal) m_selected_shortcut
|
||||
|
|
@ -161,6 +168,7 @@ public class ShortcutForm extends Form {
|
|||
private class ShortcutFormValidationListener implements
|
||||
FormValidationListener {
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||
|
||||
PageState state = e.getPageState();
|
||||
|
|
@ -175,41 +183,23 @@ public class ShortcutForm extends Form {
|
|||
if (shortcutKey == null) {
|
||||
String target = ShortcutUtil.getTarget(key);
|
||||
if (target != null) {
|
||||
m_url.addError("that url key already exists");
|
||||
throw new FormProcessException("duplicate key");
|
||||
m_url.addError(GlobalizationUtil.globalize(
|
||||
"shortcuts.ui.key_already_exists"));
|
||||
throw new FormProcessException(
|
||||
"duplicate key",
|
||||
GlobalizationUtil.globalize("shortcuts.ui.duplicate_key")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
int index = key.indexOf("/", 2);
|
||||
String base = key.substring(0, index + 1);
|
||||
|
||||
return;
|
||||
// disable checking application nodes -- this is not even the
|
||||
// correct thing to
|
||||
// check!
|
||||
// SiteNode node = null;
|
||||
// try {
|
||||
// log.info("checking for site node : " + base);
|
||||
// node = SiteNode.getSiteNode(base, true);
|
||||
// } catch ( DataObjectNotFoundException ex ) {
|
||||
// // node doesn't exist so return
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if ( !base.equals(node.getURL()) ) {
|
||||
// log.info("path does not match: " + node.getURL());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// m_url.addError("an application is already using the key starting
|
||||
// with " +
|
||||
// base);
|
||||
// throw new FormProcessException("clash with sitenode");
|
||||
}
|
||||
}
|
||||
|
||||
private class ShortcutFormProcessListener implements FormProcessListener {
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
|
||||
PageState state = e.getPageState();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package com.arsdigita.shortcuts.util;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* Compilation of methods to simplify the handling of globalizing keys.
|
||||
* Basically it adds the name of package's resource bundle files to the
|
||||
* globalize methods and forwards to GlobalizedMessage, shortening the
|
||||
* method invocation in the various application classes.
|
||||
*
|
||||
* @author <a href="mailto:yon@arsdigita.com">yon@arsdigita.com</a>
|
||||
* @version $Revision: #1 $ $Date: 2003/11/18 $
|
||||
*/
|
||||
public class GlobalizationUtil {
|
||||
|
||||
/** Name of resource files to handle themedirector's globalisation. */
|
||||
public static final String BUNDLE_NAME =
|
||||
"com.arsdigita.shortcuts.ShortcutsResources";
|
||||
|
||||
/**
|
||||
* This returns a globalized message using the package specific bundle,
|
||||
* provided by BUNDLE_NAME.
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a globalized message object, using the package specific bundle,
|
||||
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
|
||||
* interpolate into the retrieved message using the MessageFormat class.
|
||||
*
|
||||
* @param key
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
public static GlobalizedMessage globalize(String key, Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,3 +27,6 @@ subsite.ui.delete.confirm=Are you sure to delete the subsite {0}?
|
|||
subsite.ui.no_subsites=No subites defined
|
||||
subsite.ui.default_app_label=Site Wide Default
|
||||
subsite.ui.default_style_label=Site Wide Default
|
||||
subsite.ui.save.hint=Save the details in the form
|
||||
subsite.ui.cancel.hint=Abort changes & reset the form
|
||||
subsite.ui.other_style_label=Other (type in box below)
|
||||
|
|
@ -27,3 +27,6 @@ subsite.ui.delete.confirm=Sind Sie sicher, dass Sie die Subsite {0} l\u00f6schen
|
|||
subsite.ui.no_subsites=Es sind keine Subsites eingerichtet.
|
||||
subsite.ui.default_app_label=Standard f\u00fcr diese Installation
|
||||
subsite.ui.default_style_label=Standard f\u00fcr diese Installation
|
||||
subsite.ui.save.hint=Speichert die Angaben in dem Formular
|
||||
subsite.ui.cancel.hint=Verwirft die Eintragungen und erzeugt ein neues, leeres Formualar
|
||||
subsite.ui.other_style_label=Anderes (bitte in der Box unterhalb eintragen)
|
||||
|
|
@ -29,7 +29,8 @@ import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
|||
*/
|
||||
public class AppManagerPanel extends SimpleContainer {
|
||||
|
||||
private final SiteSelectionModel selectionModel = new SiteSelectionModel(new BigDecimalParameter("site"));
|
||||
private final SiteSelectionModel selectionModel =
|
||||
new SiteSelectionModel(new BigDecimalParameter("site"));
|
||||
|
||||
public AppManagerPanel() {
|
||||
add(new SiteTable(selectionModel));
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package com.arsdigita.subsite.ui;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.subsite.Subsite;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ import com.arsdigita.persistence.DataCollection;
|
|||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.subsite.Site;
|
||||
import com.arsdigita.subsite.Subsite;
|
||||
import com.arsdigita.subsite.util.SubsiteGlobalizationUtil;
|
||||
import static com.arsdigita.subsite.util.SubsiteGlobalizationUtil.globalize;
|
||||
import com.arsdigita.ui.UI;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.Classes;
|
||||
|
|
@ -65,34 +67,35 @@ import org.apache.log4j.Logger;
|
|||
/**
|
||||
* Class creates the administration input form.
|
||||
*
|
||||
* Used by ControlCenterPanel to construct the 'create new site' and 'edit existing site' input
|
||||
* forms.
|
||||
* Used by ControlCenterPanel to construct the 'create new site' and
|
||||
* 'edit existing site' input forms.
|
||||
*/
|
||||
public class SiteForm extends Form {
|
||||
|
||||
/**
|
||||
* A logger instance.
|
||||
*/
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
|
||||
* and set com.arsdigita.subsite.ui.SiteForm=DEBUG
|
||||
* by uncommenting or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(SiteForm.class);
|
||||
private SiteSelectionModel m_site;
|
||||
private BigDecimal siteDefaultRootPageID;
|
||||
private final SiteSelectionModel m_site;
|
||||
private final BigDecimal siteDefaultRootPageID;
|
||||
/**
|
||||
* Input field subsite title
|
||||
*/
|
||||
private TextField m_title;
|
||||
private TextField m_hostname;
|
||||
private TextArea m_description;
|
||||
private SingleSelect m_customFrontpageApp;
|
||||
private TextField m_styleDir;
|
||||
private CategoryPicker m_rootCategory;
|
||||
private SingleSelect m_themes;
|
||||
private SaveCancelSection m_buttons;
|
||||
private final TextField m_title;
|
||||
private final TextField m_hostname;
|
||||
private final TextArea m_description;
|
||||
private final SingleSelect m_customFrontpageApp;
|
||||
private final TextField m_styleDir;
|
||||
private final CategoryPicker m_rootCategory;
|
||||
private final SingleSelect m_themes;
|
||||
private final SaveCancelSection m_buttons;
|
||||
private final static String DEFAULT_APP = "DEFAULT_APP";
|
||||
private final static String DEFAULT_APP_LABEL = "subsite.ui.default_app_label";
|
||||
private final static String DEFAULT_STYLE = "DEFAULT_STYLE";
|
||||
private final static String DEFAULT_STYLE_LABEL = "subsite.ui.default_style_label";
|
||||
private final static String OTHER_STYLE = "OTHER_STYLE";
|
||||
private final static String OTHER_STYLE_LABEL = "Other (type in box below)";
|
||||
private final static String OTHER_STYLE_LABEL = "subsite.ui.other_style_label";
|
||||
|
||||
/**
|
||||
* Constructor create input widgets and adds them to form.
|
||||
|
|
@ -116,8 +119,7 @@ public class SiteForm extends Form {
|
|||
m_title = new TextField(new StringParameter("title"));
|
||||
m_title.addValidationListener(new NotNullValidationListener());
|
||||
m_title.setMetaDataAttribute("title", "Title");
|
||||
m_title.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.title.hint").
|
||||
localize());
|
||||
m_title.setHint(SubsiteGlobalizationUtil.globalize("subsite.ui.title.hint"));
|
||||
m_title.setSize(40);
|
||||
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.title.label")));
|
||||
add(m_title); // adds title input field to form
|
||||
|
|
@ -129,8 +131,7 @@ public class SiteForm extends Form {
|
|||
m_hostname.addValidationListener(new HostNameValidationListener());
|
||||
m_hostname.setMetaDataAttribute("title", "Hostname");
|
||||
m_hostname.setSize(40);
|
||||
m_hostname.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.hint").
|
||||
localize());
|
||||
m_hostname.setHint(SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.hint"));
|
||||
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.label")));
|
||||
add(m_hostname); // adds hostname input field to form
|
||||
|
||||
|
|
@ -141,8 +142,8 @@ public class SiteForm extends Form {
|
|||
m_description.setMetaDataAttribute("title", "Description");
|
||||
m_description.setCols(45);
|
||||
m_description.setRows(4);
|
||||
m_description.setHint((String) SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.description.hint").localize());
|
||||
m_description.setHint(SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.description.hint"));
|
||||
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.description.label")));
|
||||
add(m_description); // adds description input field to form
|
||||
|
||||
|
|
@ -153,9 +154,8 @@ public class SiteForm extends Form {
|
|||
new StringParameter("customFrontpageApp"));
|
||||
m_customFrontpageApp.setMetaDataAttribute("title", "Front Page (url)");
|
||||
// m_customFrontpageApp.setSize(40);
|
||||
m_customFrontpageApp.setHint((String) SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.customfrontpage.hint").
|
||||
localize());
|
||||
m_customFrontpageApp.setHint(globalize(
|
||||
"subsite.ui.customfrontpage.hint"));
|
||||
try {
|
||||
m_customFrontpageApp.addPrintListener(new FrontpageAppListener());
|
||||
} catch (TooManyListenersException ex) {
|
||||
|
|
@ -168,8 +168,7 @@ public class SiteForm extends Form {
|
|||
/* Setup selection box for themes */
|
||||
m_themes = new SingleSelect(new StringParameter("selectStyleDir"));
|
||||
m_themes.setMetaDataAttribute("title", "XSLT Directory");
|
||||
m_themes.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.theme.hint").
|
||||
localize());
|
||||
m_themes.setHint(SubsiteGlobalizationUtil.globalize("subsite.ui.theme.hint"));
|
||||
try {
|
||||
m_themes.addPrintListener(new ThemesListener());
|
||||
} catch (TooManyListenersException ex) {
|
||||
|
|
@ -183,8 +182,7 @@ public class SiteForm extends Form {
|
|||
m_styleDir = new TextField(new StringParameter("styleDir"));
|
||||
m_styleDir.setMetaDataAttribute("title", "XSLT Directory (Other)");
|
||||
m_styleDir.setSize(40);
|
||||
m_styleDir.setHint(
|
||||
"Enter the directory for the custom XSLT styles, or leave blank for the default styling.");
|
||||
m_styleDir.setHint(globalize("subsite.ui.styledir.hint") );
|
||||
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.styledir.label")));
|
||||
add(m_styleDir); // adds inputfield style dir to form
|
||||
|
||||
|
|
@ -196,8 +194,8 @@ public class SiteForm extends Form {
|
|||
new Object[]{"rootCategory"});
|
||||
if (m_rootCategory instanceof Widget) {
|
||||
((Widget) m_rootCategory).setMetaDataAttribute("title", "Root category");
|
||||
((Widget) m_rootCategory).setHint((String) SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.root_category.hint").localize());
|
||||
((Widget) m_rootCategory).setHint(SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.root_category.hint"));
|
||||
}
|
||||
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.root_category.label")));
|
||||
add(m_rootCategory); // adds domain category selection box to form
|
||||
|
|
@ -205,10 +203,10 @@ public class SiteForm extends Form {
|
|||
m_buttons = new SaveCancelSection();
|
||||
m_buttons.getSaveButton().setButtonLabel(SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.save"));
|
||||
m_buttons.getSaveButton().setHint("Save the details in the form");
|
||||
m_buttons.getSaveButton().setHint(globalize("subsite.ui.save.hint"));
|
||||
m_buttons.getCancelButton().setButtonLabel(SubsiteGlobalizationUtil.globalize(
|
||||
"subsite.ui.cancel"));
|
||||
m_buttons.getCancelButton().setHint("Abort changes & reset the form");
|
||||
m_buttons.getCancelButton().setHint(globalize("subsite.ui.cancel.hint"));
|
||||
add(m_buttons);
|
||||
|
||||
addSubmissionListener(new SiteSubmissionListener());
|
||||
|
|
@ -222,13 +220,17 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class SiteSubmissionListener implements FormSubmissionListener {
|
||||
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
||||
if (m_buttons.getCancelButton().isSelected(state)) {
|
||||
m_site.clearSelection(state);
|
||||
throw new FormProcessException("cancel pressed");
|
||||
throw new FormProcessException(
|
||||
"cancel pressed",
|
||||
globalize("cms.ui.authoring.submission_cancelled")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,6 +241,7 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class SiteValidationListener implements FormValidationListener {
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
if (!m_buttons.getCancelButton().isSelected(state)) {
|
||||
|
|
@ -289,6 +292,7 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class HostNameValidationListener implements ParameterListener {
|
||||
|
||||
@Override
|
||||
public void validate(ParameterEvent e) {
|
||||
ParameterData data = e.getParameterData();
|
||||
String hostname = (String) data.getValue();
|
||||
|
|
@ -318,6 +322,7 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class SiteInitListener implements FormInitListener {
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
|
@ -337,7 +342,6 @@ public class SiteForm extends Form {
|
|||
m_hostname.setValue(state, site.getHostname());
|
||||
m_description.setValue(state, site.getDescription());
|
||||
|
||||
// BigDecimal siteDefaultRootPageID
|
||||
BigDecimal currentFrontpageID = site.getFrontPage().getID();
|
||||
s_log.debug(" Site default frontpage is: " + siteDefaultRootPageID
|
||||
+ ", Current frontpage is: " + currentFrontpageID);
|
||||
|
|
@ -380,6 +384,7 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class SiteProcessListener implements FormProcessListener {
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
|
|
@ -475,22 +480,20 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class FrontpageAppListener implements PrintListener {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent e) {
|
||||
final SingleSelect target = (SingleSelect) e.getTarget();
|
||||
// final PageState state = e.getPageState();
|
||||
ApplicationCollection customApps;
|
||||
|
||||
// target.addOption(new Option(SELECT_APP, SELECT_APP_LABEL));
|
||||
target.addOption(new Option(DEFAULT_APP,
|
||||
(String) SubsiteGlobalizationUtil
|
||||
.globalize(DEFAULT_APP_LABEL).localize()));
|
||||
new Label(SubsiteGlobalizationUtil
|
||||
.globalize(DEFAULT_APP_LABEL))));
|
||||
|
||||
String[] customAppTypes = (String[]) Subsite.getConfig()
|
||||
.getFrontPageApplicationTypes();
|
||||
if (customAppTypes != null) {
|
||||
for (int i = 0; i < customAppTypes.length; i++) {
|
||||
customApps = Application.retrieveAllApplications(
|
||||
customAppTypes[i]);
|
||||
for (String customAppType : customAppTypes) {
|
||||
customApps = Application.retrieveAllApplications(customAppType);
|
||||
while (customApps.next()) {
|
||||
/* Create an entry for each application, consisting
|
||||
* of the (BigDecimal) ID as value and the URL as
|
||||
|
|
@ -513,14 +516,15 @@ public class SiteForm extends Form {
|
|||
*/
|
||||
private class ThemesListener implements PrintListener {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent e) {
|
||||
SingleSelect target = (SingleSelect) e.getTarget();
|
||||
PageState state = e.getPageState();
|
||||
Map themes = Subsite.getConfig().getThemes();
|
||||
Set entrySet = themes.entrySet();
|
||||
target.addOption(new Option(DEFAULT_STYLE,
|
||||
(String) SubsiteGlobalizationUtil.globalize(
|
||||
DEFAULT_STYLE_LABEL).localize()));
|
||||
new Label(SubsiteGlobalizationUtil.globalize(
|
||||
DEFAULT_STYLE_LABEL))));
|
||||
if (entrySet != null) {
|
||||
Iterator entries = entrySet.iterator();
|
||||
while (entries.hasNext()) {
|
||||
|
|
@ -530,7 +534,9 @@ public class SiteForm extends Form {
|
|||
state);
|
||||
}
|
||||
}
|
||||
target.addOption(new Option(OTHER_STYLE, OTHER_STYLE_LABEL));
|
||||
target.addOption(new Option(OTHER_STYLE,
|
||||
new Label(SubsiteGlobalizationUtil.globalize(
|
||||
OTHER_STYLE_LABEL))));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import com.arsdigita.xml.Element;
|
|||
*/
|
||||
public class SiteListing extends SimpleComponent {
|
||||
|
||||
private SiteSelectionModel m_site;
|
||||
private final SiteSelectionModel m_site;
|
||||
|
||||
public SiteListing(SiteSelectionModel site) {
|
||||
m_site = site;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
|||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.subsite.Site;
|
||||
import com.arsdigita.subsite.util.SubsiteGlobalizationUtil;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package com.arsdigita.subsite.ui;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SubsiteGlobalizationUtil {
|
||||
|
||||
public static final String BUNDLE_NAME = "com.arsdigita.subsite.ui.SubsiteResources";
|
||||
|
||||
public static GlobalizedMessage globalize(final String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
public static GlobalizedMessage globalize(final String key,
|
||||
final Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (C) 2013 Jens Pelzetter, Universitaet Bremen. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.subsite.util;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
* Compilation of methods to simplify the handling of globalizing keys.
|
||||
* Basically it adds the name of package's resource bundle files to the
|
||||
* globalize methods and forwards to GlobalizedMessage, shortening the
|
||||
* method invocation in the various application classes.
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SubsiteGlobalizationUtil {
|
||||
|
||||
/** Name of Java resource files to handle CMS's globalisation. */
|
||||
public static final String BUNDLE_NAME = "com.arsdigita.subsite.SubsiteResources";
|
||||
|
||||
/**
|
||||
* Returns a globalized message using the package specific bundle,
|
||||
* provided by BUNDLE_NAME.
|
||||
*/
|
||||
public static GlobalizedMessage globalize(final String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a globalized message object, using the package specific bundle,
|
||||
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
|
||||
* interpolate into the retrieved message using the MessageFormat class
|
||||
* (i.e. parameter as {0}, {1} for handling variable parts).
|
||||
*/
|
||||
public static GlobalizedMessage globalize(final String key,
|
||||
final Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue