diff --git a/ccm-core/src/com/arsdigita/bebop/Label.java b/ccm-core/src/com/arsdigita/bebop/Label.java index 4dd82f03e..279a9ec20 100755 --- a/ccm-core/src/com/arsdigita/bebop/Label.java +++ b/ccm-core/src/com/arsdigita/bebop/Label.java @@ -360,9 +360,13 @@ public class Label extends BlockStylable implements Cloneable { label.addAttribute("escape", "no"); } - String key = getGlobalizedMessage().getKey().substring(getGlobalizedMessage().getKey().lastIndexOf(".") + 1); + String key = getGlobalizedMessage() + .getKey() + .substring(getGlobalizedMessage() + .getKey().lastIndexOf(".") + 1); - // This if clause is needed to prevent printing of keys if the GlobalizedMessage was created from a String by this class + // This if clause is needed to prevent printing of keys if the + // GlobalizedMessage was created from a String by this class if(!key.equals(target.getLabel(state))) { label.addAttribute("key", key); } diff --git a/ccm-core/src/com/arsdigita/bebop/form/TextArea.java b/ccm-core/src/com/arsdigita/bebop/form/TextArea.java index 4e0479060..e950e7181 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/TextArea.java +++ b/ccm-core/src/com/arsdigita/bebop/form/TextArea.java @@ -171,7 +171,7 @@ public class TextArea extends Widget implements BebopConstants { } /** - * Generates the DOM for the textarea widget + * Generates the DOM for the textarea widget. *
Generates DOM fragment: *
<bebop:textarea name=... value=... [onXXX=...]/>
*
@@ -180,6 +180,9 @@ public class TextArea extends Widget implements BebopConstants {
Element textarea = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
textarea.addAttribute("name", getName());
+ if (getLabel() != null)
+ textarea.addAttribute("label",
+ (String)getLabel().localize(state.getRequest()));
ParameterData pData = getParameterData(state);
if( null != pData ) {
diff --git a/ccm-core/src/com/arsdigita/bebop/form/Widget.java b/ccm-core/src/com/arsdigita/bebop/form/Widget.java
index b3b1d2bc7..e9502b751 100755
--- a/ccm-core/src/com/arsdigita/bebop/form/Widget.java
+++ b/ccm-core/src/com/arsdigita/bebop/form/Widget.java
@@ -80,6 +80,8 @@ public abstract class Widget extends BlockStylable implements Cloneable,
private ParameterListener m_forwardParameter = null;
private PrintListener m_printListener;
private Form m_form;
+ /** The optional (localized) label (or title) of this widget. */
+ private GlobalizedMessage m_label;
private ValidationGuard m_guard = null;
@@ -392,6 +394,20 @@ public abstract class Widget extends BlockStylable implements Cloneable,
setAttribute("hint", (String)hint.localize() );
}
+ /**
+ * Sets a Label for the widget.
+ */
+ public void setLabel(GlobalizedMessage label) {
+ m_label = label;
+ }
+
+ /**
+ * Sets a Label for the widget.
+ */
+ public GlobalizedMessage getLabel() {
+ return m_label;
+ }
+
/**
* Gets the default value in the parameter model for this element.
@@ -521,7 +537,7 @@ public abstract class Widget extends BlockStylable implements Cloneable,
}
/**
- * Generates the DOM for the given widget
+ * Generates the DOM for the given widget.
*
Generates DOM fragment: *
<bebop:formWidget name=... type=... value=... [onXXX=...]>
* </bebop:formWidget> */
@@ -530,6 +546,9 @@ public abstract class Widget extends BlockStylable implements Cloneable,
widget.addAttribute("type", getType());
widget.addAttribute("name", getName());
+ if (m_label != null)
+ widget.addAttribute("label",
+ (String)m_label.localize(state.getRequest()));
exportAttributes(widget);
String value = null;
ParameterData p = getParameterData(state);
@@ -553,9 +572,9 @@ public abstract class Widget extends BlockStylable implements Cloneable,
while (i.hasNext()) {
Element errors = parent.newChildElement(BEBOP_FORMERRORS, BEBOP_XML_NS);
- errors.addAttribute(
- "message",
- (String) ((GlobalizedMessage) i.next()).localize(state.getRequest())
+ errors.addAttribute("message",
+ (String) ((GlobalizedMessage)
+ i.next()).localize(state.getRequest())
);
errors.addAttribute("id", getName());
}
@@ -656,10 +675,12 @@ public abstract class Widget extends BlockStylable implements Cloneable,
*
* @pre state != null
*/
+ @Override
public void respond(PageState state) throws javax.servlet.ServletException {
getForm().respond(state);
}
+ @Override
public Object clone() throws CloneNotSupportedException {
Widget cloned = (Widget) super.clone();
cloned.setForm(null);
@@ -705,6 +726,7 @@ public abstract class Widget extends BlockStylable implements Cloneable,
getParameterData(PageState.getPageState()).addError(error);
}
+ @Override
public String toString() {
return super.toString() + " [" + getName() + "]";
}
diff --git a/ccm-forum/src/com/arsdigita/forum/ui/admin/SetupView.java b/ccm-forum/src/com/arsdigita/forum/ui/admin/SetupView.java
index 34c9549e9..3bb40ab58 100644
--- a/ccm-forum/src/com/arsdigita/forum/ui/admin/SetupView.java
+++ b/ccm-forum/src/com/arsdigita/forum/ui/admin/SetupView.java
@@ -129,26 +129,31 @@ public class SetupView extends Form
m_saveCancel = new SaveCancelSection();
m_saveCancel.getSaveButton().setButtonLabel(GlobalizationUtil.gz(
"forum.ui.settings.save"));
-
- // ////////////////////////////////////////////////////////////////////
- // Create the pane
- // ////////////////////////////////////////////////////////////////////
- /* Introductory text fiel */
+ // preliminary step 4: Create Introductory text area
m_introduction = new TextArea("introduction", 8, 60, TextArea.SOFT);
m_introduction.addValidationListener(
new StringInRangeValidationListener(0, 4000,
GlobalizationUtil.gz(
"forum.ui.validation.introduction_too_long")
));
- m_introduction.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
- "forum.ui.settings.introduction").localize());
+ // m_introduction.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
+ // "forum.ui.settings.introduction").localize());
+ m_introduction.setLabel(GlobalizationUtil.gz(
+ "forum.ui.settings.introduction"));
+ // preliminary step 5: Create title text field
m_title = new TextField("title");
- m_title.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
- "forum.ui.settings.title").localize());
+ // m_title.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
+ // "forum.ui.settings.title").localize());
+ m_title.setLabel(GlobalizationUtil.gz(
+ "forum.ui.settings.title"));
m_title.setSize(70);
+
+ // ////////////////////////////////////////////////////////////////////
+ // Create the pane
+ // ////////////////////////////////////////////////////////////////////
add(m_title);
add(m_introduction);
add(m_settings);