Java Code Examples for org.apache.wicket.markup.html.form.FormComponent#setLabel()

The following examples show how to use org.apache.wicket.markup.html.form.FormComponent#setLabel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractFieldsetPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
private void checkLabelFor(final Component... components)
{
  if (labelFor == true) {
    return;
  }
  final Component component = components[0];
  if (component instanceof ComponentWrapperPanel) {
    this.label.add(AttributeModifier.replace("for", ((ComponentWrapperPanel) component).getComponentOutputId()));
    labelFor = true;
  }
  for (final Component comp : components) {
    if (comp instanceof LabeledWebMarkupContainer) {
      final LabeledWebMarkupContainer labeledComponent = (LabeledWebMarkupContainer) comp;
      if (labeledComponent.getLabel() == null) {
        labeledComponent.setLabel(new Model<String>(labelText));
      }
    } else if (component instanceof ComponentWrapperPanel) {
      final FormComponent<?> formComponent = ((ComponentWrapperPanel)component).getFormComponent();
      if (formComponent != null && formComponent.getLabel() == null) {
        formComponent.setLabel(new Model<String>(labelText));
      }
    }
  }
}
 
Example 2
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void setLabel(final FormComponent< ? > component, final Label label)
{
  final IModel<String> labelModel = (IModel<String>) label.getDefaultModel();
  if (component instanceof DatePanel) {
    ((DatePanel) component).getDateField().setLabel(labelModel);
  } else {
    component.setLabel(labelModel);
  }
}
 
Example 3
Source File: AdvancedFormComponentLabel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AdvancedFormComponentLabel(String id, FormComponent<?> component) {
	super(id, component);
	
	component.setLabel(new ResourceModel(component.getId()));
	if (component.isRequired()) {
		add(AttributeModifier.replace("class", "requiredHint"));
	}
}