Erster Versuch, ein Tag Label in Widgets zu integrieren.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2391 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
fd1f651621
commit
e917176d17
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* <p>Generates DOM fragment:
|
||||
* <p><code><bebop:textarea name=... value=... [onXXX=...]/>
|
||||
* </code>
|
||||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* <p>Generates DOM fragment:
|
||||
* <p><code><bebop:formWidget name=... type=... value=... [onXXX=...]>
|
||||
* </bebop:formWidget></code> */
|
||||
|
|
@ -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() + "]";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue