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