Java Code Examples for org.apache.wicket.markup.html.form.DropDownChoice

The following examples show how to use org.apache.wicket.markup.html.form.DropDownChoice. These examples are extracted from open source projects. 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 Project: inception   Source File: ActiveLearningSidebar.java    License: Apache License 2.0 6 votes vote down vote up
private Form<Void> createSessionControlForm()
{
    Form<Void> form = new Form<>(CID_SESSION_CONTROL_FORM);

    DropDownChoice<AnnotationLayer> layersDropdown = new BootstrapSelect<>(CID_SELECT_LAYER);
    layersDropdown.setModel(alStateModel.bind("layer"));
    layersDropdown.setChoices(LoadableDetachableModel.of(this::listLayersWithRecommenders));
    layersDropdown.setChoiceRenderer(new LambdaChoiceRenderer<>(AnnotationLayer::getUiName));
    layersDropdown.add(LambdaBehavior.onConfigure(it -> it.setEnabled(!alStateModel
        .getObject().isSessionActive())));
    layersDropdown.setOutputMarkupId(true);
    layersDropdown.setRequired(true);
    form.add(layersDropdown);
    
    form.add(new LambdaAjaxSubmitLink(CID_START_SESSION_BUTTON, this::actionStartSession)
            .add(visibleWhen(() -> !alStateModel.getObject().isSessionActive())));
    form.add(new LambdaAjaxLink(CID_STOP_SESSION_BUTTON, this::actionStopSession)
        .add(visibleWhen(() -> alStateModel.getObject().isSessionActive())));
    form.add(visibleWhen(() -> alStateModel.getObject().isDoExistRecommenders()));

    return form;
}
 
Example 2
Source Project: inception   Source File: KnowledgeBaseIriPanel.java    License: Apache License 2.0 6 votes vote down vote up
private DropDownChoice<Reification> selectReificationStrategy(String id, String property)
{
    DropDownChoice<Reification> reificationDropDownChoice = new BootstrapSelect<>(id,
        kbModel.bind(property), asList(Reification.values()));
    reificationDropDownChoice.setRequired(true);
    reificationDropDownChoice.setOutputMarkupPlaceholderTag(true);
    
    // The current reification implementation only really does something useful when the
    // Wikidata schema is used on the actual Wikidata knowledge base (or a mirror). 
    // Thus, we enable the option to activate reification only in this case.
    reificationDropDownChoice.add(visibleWhen(() -> 
            WIKIDATASCHEMA.equals(selectedSchemaProfile.getObject()) &&
            kbModel.getObject().getKb().isReadOnly() &&
            REMOTE.equals(kbModel.getObject().getKb().getType())));
    
    return reificationDropDownChoice;
}
 
Example 3
Source Project: inception   Source File: StatementGroupPanel.java    License: Apache License 2.0 6 votes vote down vote up
public NewStatementGroupFragment(String aId) {
    super(aId, "newStatementGroup", StatementGroupPanel.this, groupModel);
                
    IModel<KBProperty> property = Model.of();
    
    Form<KBProperty> form = new Form<>("form", property);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setModel(property);
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));            
    type.setChoices(getUnusedProperties());
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    focusComponent = type;
    
    form.add(new LambdaAjaxButton<>("create", this::actionNewProperty));
    form.add(new LambdaAjaxLink("cancel", this::actionCancelNewProperty));
    add(form);
}
 
Example 4
Source Project: inception   Source File: SearchAnnotationSidebar.java    License: Apache License 2.0 6 votes vote down vote up
private DropDownChoice<AnnotationLayer> createLayerDropDownChoice(String aId,
    List<AnnotationLayer> aChoices)
{
    DropDownChoice<AnnotationLayer> layerChoice = new BootstrapSelect<>(aId, aChoices,
            new ChoiceRenderer<>("uiName"));

    layerChoice.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6095969211884063787L;

        @Override protected void onUpdate(AjaxRequestTarget aTarget)
        {
            //update the choices for the feature selection dropdown
            groupingFeature.setChoices(annotationService
                .listAnnotationFeature(searchOptions.getObject().getGroupingLayer()));
            lowLevelPagingCheckBox.setModelObject(false);
            aTarget.add(groupingFeature, lowLevelPagingCheckBox);
        }
    });
    layerChoice.setNullValid(true);
    return layerChoice;
}
 
Example 5
Source Project: yes-cart   Source File: SingleChoiceEditor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct drop down box to select single value.
 *
 * @param id         editor id.
 * @param markupProvider markup object.
 * @param model      model.
 * @param labelModel label model
 * @param attrValue  {@link org.yes.cart.domain.entity.AttrValue}
 * @param choices    list of strings {@link org.yes.cart.domain.misc.Pair}, that represent options to select one
 * @param readOnly  if true this component is read only
 */
public SingleChoiceEditor(final String id,
                          final MarkupContainer markupProvider,
                          final IModel model,
                          final IModel<String> labelModel,
                          final IModel choices,
                          final AttrValueWithAttribute attrValue,
                          final boolean readOnly) {

    super(id, "singleChoiceEditor", markupProvider);

    final DropDownChoice<Pair<String, String>> dropDownChoice =
            new DropDownChoice<Pair<String, String>>(EDIT, model, choices);
    dropDownChoice.setLabel(labelModel);
    dropDownChoice.setEnabled(!readOnly);
    dropDownChoice.setRequired(attrValue.getAttribute().isMandatory());
    dropDownChoice.setChoiceRenderer(new PairChoiceRenderer());
    add(dropDownChoice);

}
 
Example 6
Source Project: openmeetings   Source File: PollResultsDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	add(chartDiv.setOutputMarkupId(true));
	chartSimple = getString("1414");
	chartPie = getString("1415");
	add(name, question, count);
	chartType = new DropDownChoice<>("chartType", Model.of(chartSimple), List.of(chartSimple, chartPie));
	add(chartType.add(new AjaxFormComponentUpdatingBehavior("change") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			redraw(target, false);
		}
	}));
	super.onInitialize();
}
 
Example 7
Source Project: openmeetings   Source File: PagingNavigatorPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	dataView.setItemsPerPage(entitiesPerPage);
	final Form<Void> f = new Form<>("pagingForm");
	f.add(new OmPagingNavigator("navigator", dataView).setOutputMarkupId(true))
		.add(new DropDownChoice<>("entitiesPerPage", new PropertyModel<Integer>(this, "entitiesPerPage"), numbers)
			.add(new AjaxFormComponentUpdatingBehavior("change") {
				private static final long serialVersionUID = 1L;

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					long newPage = dataView.getCurrentPage() * dataView.getItemsPerPage() / entitiesPerPage;
					dataView.setItemsPerPage(entitiesPerPage);
					dataView.setCurrentPage(newPage);
					target.add(f);
					PagingNavigatorPanel.this.onEvent(target);
				}
			}));
	add(f.setOutputMarkupId(true));
}
 
Example 8
Source Project: webanno   Source File: ProjectDetailPanel.java    License: Apache License 2.0 6 votes vote down vote up
private DropDownChoice<String> makeProjectTypeChoice()
{
    List<String> types = projectService.listProjectTypes().stream().map(t -> t.id())
            .collect(Collectors.toList());

    DropDownChoice<String> projTypes = new BootstrapSelect<>("mode", types);
    projTypes.setRequired(true);
    projTypes.add(LambdaBehavior.onConfigure(_this -> {
        // If there is only a single project type and the project mode has not been set yet,
        // then we can simply select that and do not need to show the choice at all.
        Project project = projectModel.getObject();
        if (projectTypes.getChoices().size() == 1 && project.getMode() == null) {
            project.setMode(projectTypes.getChoices().get(0));
        }
        
        _this.setEnabled(
                nonNull(projectModel.getObject()) && isNull(projectModel.getObject().getId()));
        
        // If there is only a single project type, then we can simply select that and do not
        // need to show the choice at all.
        _this.setVisible(projTypes.getChoices().size() > 1);
    }));
    
    return projTypes;
}
 
Example 9
Source Project: syncope   Source File: SchemasITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void readPlainSchema() {
    browsingToPlainSchemas();
    TESTER.assertLabel(
            PLAIN_DATATABLE_PATH
            + ":tablePanel:groupForm:"
            + "checkgroup:dataTable:body:rows:1:cells:1:cell", "aLong");

    TESTER.executeAjaxEvent(
            PLAIN_DATATABLE_PATH + ":tablePanel:groupForm:checkgroup:dataTable:body:rows:1",
            Constants.ON_CLICK);

    TESTER.clickLink(
            "body:content:tabbedPanel:panel:accordionPanel:tabs:0:body:content:outerObjectsRepeater:1:outer:"
            + "container:content:togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");

    TESTER.assertComponent(
            "body:content:tabbedPanel:"
            + "panel:accordionPanel:tabs:0:body:content:outerObjectsRepeater:0:outer:"
            + "form:content:form:view:kind:dropDownChoiceField", DropDownChoice.class);
}
 
Example 10
Source Project: tutorials   Source File: CafeAddress.java    License: MIT License 6 votes vote down vote up
public CafeAddress(final PageParameters parameters) {
    super(parameters);
    initCafes();

    ArrayList<String> cafeNames = new ArrayList<>(cafeNamesAndAddresses.keySet());
    selectedCafe = cafeNames.get(0);
    address = new Address(cafeNamesAndAddresses.get(selectedCafe).getAddress());

    final Label addressLabel = new Label("address", new PropertyModel<String>(this.address, "address"));
    addressLabel.setOutputMarkupId(true);

    final DropDownChoice<String> cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel<>(this, "selectedCafe"), cafeNames);
    cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String name = (String) cafeDropdown.getDefaultModel().getObject();
            address.setAddress(cafeNamesAndAddresses.get(name).getAddress());
            target.add(addressLabel);
        }
    });

    add(addressLabel);
    add(cafeDropdown);

}
 
Example 11
Source Project: syncope   Source File: LogsITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void updateCoreLogs() {
    TESTER.clickLink("body:content:tabbedPanel:tabs-container:tabs:0:link");
    TESTER.assertComponent(CONTAINER_PATH, WebMarkupContainer.class);

    Component result = searchLog(KEY, CONTAINER_PATH, "io.swagger");
    assertNotNull(result);

    TESTER.getRequest().setMethod(Form.METHOD_GET);
    TESTER.getRequest().addParameter(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", "6");
    TESTER.assertComponent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", DropDownChoice.class);
    TESTER.executeAjaxEvent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", Constants.ON_CHANGE);

    assertSuccessMessage();
}
 
Example 12
Source Project: syncope   Source File: LogsITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void updateConsoleLogs() {
    TESTER.clickLink("body:content:tabbedPanel:tabs-container:tabs:1:link");
    TESTER.assertComponent(CONTAINER_PATH, WebMarkupContainer.class);

    Component result = searchLog(KEY, CONTAINER_PATH, "org.apache.wicket");
    assertNotNull(result);

    TESTER.getRequest().setMethod(Form.METHOD_GET);
    TESTER.getRequest().addParameter(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", "6");
    TESTER.assertComponent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", DropDownChoice.class);
    TESTER.executeAjaxEvent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", Constants.ON_CHANGE);

    assertSuccessMessage();
}
 
Example 13
Source Project: Orienteer   Source File: OClusterMetaPanel.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected Component resolveComponent(String id, DisplayMode mode, String critery) {

    if(DisplayMode.EDIT.equals(mode) && !OSecurityHelper.isAllowed(ORule.ResourceGeneric.SCHEMA, null, OrientPermission.UPDATE))
    {
        mode = DisplayMode.VIEW;
    }
    if(DisplayMode.VIEW.equals(mode))
    {
        return new Label(id, getModel());
    }
    else if(DisplayMode.EDIT.equals(mode)) {
        if (OClustersWidget.COMPRESSION.equals(critery)) {
            return new DropDownChoice<String>(id, (IModel<String>)getModel(), COMPRESSIONS);
        }
        else if(OClustersWidget.COUNT.equals(critery) || OClustersWidget.ID.equals(critery)){
            return resolveComponent(id, DisplayMode.VIEW, critery);
        } else {
            return new TextField<V>(id, getModel()).setType(String.class);
        }
    }
    return null;
}
 
Example 14
Source Project: oodt   Source File: TypeBrowser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param id
 *          The wicket:id component ID of this form.
 */
public AddCriteriaForm(String id) {
  super(id, new CompoundPropertyModel<ElementCrit>(new ElementCrit()));
  List<Element> ptypeElements = fm.safeGetElementsForProductType(type);
  Collections.sort(ptypeElements, new Comparator<Element>() {
    public int compare(Element e1, Element e2) {
      return e1.getElementName().compareTo(e2.getElementName());
    }
  });

  add(new DropDownChoice<Element>("criteria_list", new PropertyModel(
      getDefaultModelObject(), "elem"), new ListModel<Element>(
      ptypeElements), new ChoiceRenderer<Element>("elementName",
      "elementId")));
  add(new TextField<TermQueryCriteria>(
      "criteria_form_add_element_value",
      new PropertyModel<TermQueryCriteria>(getDefaultModelObject(), "value")));
  add(new Button("criteria_elem_add"));
}
 
Example 15
private void addParameterSettings(final int idx)
{
  final FieldsetPanel fs = gridBuilder.newFieldset(getString("scripting.script.parameterName") + " " + idx);

  final String parameterType = "parameter" + idx + "Type";
  final String parameterName = "parameter" + idx + "Name";
  final MaxLengthTextField name = new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, parameterName));
  WicketUtils.setSize(name, 20);
  fs.add(name);
  // DropDownChoice type
  final LabelValueChoiceRenderer<ScriptParameterType> typeChoiceRenderer = new LabelValueChoiceRenderer<ScriptParameterType>(this,
      ScriptParameterType.values());
  final DropDownChoice<ScriptParameterType> typeChoice = new DropDownChoice<ScriptParameterType>(fs.getDropDownChoiceId(),
      new PropertyModel<ScriptParameterType>(data, parameterType), typeChoiceRenderer.getValues(), typeChoiceRenderer);
  typeChoice.setNullValid(true);
  typeChoice.setRequired(false);
  fs.add(typeChoice);
}
 
Example 16
/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel, org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel)
{
  // DropDownChoice listType
  final LabelValueChoiceRenderer<String> typeChoiceRenderer = new LabelValueChoiceRenderer<String>();
  typeChoiceRenderer.addValue("all", getString("filter.all"));
  typeChoiceRenderer.addValue("active", getString("fibu.kost.status.active"));
  typeChoiceRenderer.addValue("nonactive", getString("fibu.kost.status.nonactive"));
  typeChoiceRenderer.addValue("notEnded", getString("notEnded"));
  typeChoiceRenderer.addValue("ended", getString("ended"));
  final DropDownChoice<String> typeChoice = new DropDownChoice<String>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<String>(this,
      "searchFilter.listType"), typeChoiceRenderer.getValues(), typeChoiceRenderer);
  typeChoice.setNullValid(false);
  optionsFieldsetPanel.add(typeChoice, true);
}
 
Example 17
private static void addDateFormatCombobox(final GridBuilder gridBuilder, final PFUserDO user, final String labelKey,
    final String property, final String[] dateFormats, final boolean convertExcelFormat)
{
  final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString(labelKey));
  final LabelValueChoiceRenderer<String> dateFormatChoiceRenderer = new LabelValueChoiceRenderer<String>();
  for (final String str : dateFormats) {
    String dateString = "???";
    final String pattern = convertExcelFormat == true ? str.replace('Y', 'y').replace('D', 'd') : str;
    try {
      final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
      dateString = dateFormat.format(new Date());
    } catch (final Exception ex) {
      log.warn("Invalid date format in config.xml: " + pattern);
    }
    dateFormatChoiceRenderer.addValue(str, str + ": " + dateString);
  }
  final DropDownChoice<String> dateFormatChoice = new DropDownChoice<String>(fs.getDropDownChoiceId(), new PropertyModel<String>(user,
      property), dateFormatChoiceRenderer.getValues(), dateFormatChoiceRenderer);
  dateFormatChoice.setNullValid(true);
  fs.add(dateFormatChoice);
}
 
Example 18
Source Project: inception   Source File: AccessSettingsPanel.java    License: Apache License 2.0 5 votes vote down vote up
private DropDownChoice<RepositoryType> createTypeSelection(String id, String property)
{
    DropDownChoice<RepositoryType> typeChoice = new BootstrapSelect<>(id,
            kbModel.bind(property), asList(RepositoryType.values()),
            new EnumChoiceRenderer<>(this));
    typeChoice.setRequired(true);
    return typeChoice;
}
 
Example 19
Source Project: inception   Source File: QualifierEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new fragement for editing a qualifier.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewQualifier}:
 * <ul>
 * <li>{@code !isNewQualifier}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the qualifier from the statement.</li>
 * <li>{@code isNewQualifier}: Save button commits changes (creates a new qualifier in the
 * statement), cancel button removes the qualifier from the UI, delete button is not visible
 * .</li>
 * </ul>
 *
 * @param aId
 *            markup ID
 * @param aQualifier
 *            qualifier model
 * @param isNewQualifier
 *            whether the qualifier being edited is new, meaning it has no corresponding
 *            qualifier in the KB backend
 */
public EditMode(String aId, IModel<KBQualifier> aQualifier, boolean isNewQualifier)
{
    super(aId, "editMode", QualifierEditor.this, aQualifier);

    IModel<KBQualifier> compoundModel = CompoundPropertyModel.of(aQualifier);

    Form<KBQualifier> form = new Form<>("form", compoundModel);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    type.setChoices(kbService.listProperties(kbModel.getObject(), false));
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    initialFocusComponent = type;

    form.add(new TextField<>("language"));

    Component valueTextArea = new TextArea<String>("value");
    form.add(valueTextArea);

    form.add(new LambdaAjaxButton<>("create", QualifierEditor.this::actionSave));
    form.add(new LambdaAjaxLink("cancel", t -> {
        if (isNewQualifier) {
            QualifierEditor.this.actionCancelNewQualifier(t);
        } else {
            QualifierEditor.this.actionCancelExistingQualifier(t);
        }
    }));
    form.add(new LambdaAjaxLink("delete", QualifierEditor.this::actionDelete)
        .setVisibilityAllowed(!isNewQualifier));

    add(form);
}
 
Example 20
/**
 * @param dropDownChoice
 */
public void replaceWithDropDownChoice(final DropDownChoice<T> dropDownChoice)
{
  if (this.dropDownChoice != null) {
    remove(this.dropDownChoice);
  }
  this.dropDownChoice = dropDownChoice;
  add(dropDownChoice);
}
 
Example 21
Source Project: inception   Source File: MetricSelectDropDownPanel.java    License: Apache License 2.0 5 votes vote down vote up
private static void hide(AjaxRequestTarget target, Component component)
{
    component.add(new DisplayNoneBehavior());
    String js = "$('#" + component.getMarkupId()
            + "').animate({'width': '-=100'},  100); $('#"
            + ((DropDownChoice) component).getMarkupId() + "').hide();";
    target.appendJavaScript(js);
}
 
Example 22
Source Project: inception   Source File: MetricSelectDropDownPanel.java    License: Apache License 2.0 5 votes vote down vote up
private static void show(AjaxRequestTarget target, Component component)
{
    component.add(new DisplayNoneBehavior());

    String js = "$('#" + component.getMarkupId()
            + "').animate({'width': '+=100'},  100); $('#"
            + ((DropDownChoice) component).getMarkupId() + "').show();";
    target.appendJavaScript(js);
}
 
Example 23
public DocumentMetadataAnnotationSelectionPanel(String aId, IModel<Project> aProject,
        IModel<SourceDocument> aDocument, IModel<String> aUsername,
        CasProvider aCasProvider, AnnotationPage aAnnotationPage,
        AnnotationActionHandler aActionHandler, AnnotatorState aState)
{
    super(aId, aProject);

    setOutputMarkupPlaceholderTag(true);
    
    annotationPage = aAnnotationPage;
    sourceDocument = aDocument;
    username = aUsername;
    jcasProvider = aCasProvider;
    project = aProject;
    selectedLayer = Model.of();
    actionHandler = aActionHandler;
    state = aState;

    annotationsContainer = new WebMarkupContainer(CID_ANNOTATIONS_CONTAINER);
    annotationsContainer.setOutputMarkupId(true);
    annotationsContainer.add(createAnnotationList());
    add(annotationsContainer);
    
    DropDownChoice<AnnotationLayer> layer = new BootstrapSelect<>(CID_LAYER);
    layer.setModel(selectedLayer);
    layer.setChoices(this::listMetadataLayers);
    layer.setChoiceRenderer(new ChoiceRenderer<>("uiName"));
    layer.add(new LambdaAjaxFormComponentUpdatingBehavior("change"));
    add(layer);
    
    add(new LambdaAjaxLink(CID_CREATE, this::actionCreate));
}
 
Example 24
/**
 * @param id
 * @param label see {@link FormComponent#setLabel(IModel)}
 * @param dropDownChoice
 * @param submitOnChange
 */
public DropDownChoicePanel(final String id, final DropDownChoice<T> dropDownChoice, final boolean submitOnChange)
{
  super(id);
  this.dropDownChoice = dropDownChoice;
  add(dropDownChoice);
  if (submitOnChange == true) {
    dropDownChoice.add(AttributeModifier.replace("onchange", "javascript:submit();"));
  }
  setRenderBodyOnly(true);
}
 
Example 25
Source Project: onedev   Source File: NullableBooleanPropertyEditor.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	String stringValue;
	if (getModelObject() != null) {
		if (getModelObject())
			stringValue = "yes";
		else
			stringValue = "no";
	} else {
		stringValue = null;
	}
	input = new DropDownChoice<String>("input", Model.of(stringValue), Lists.newArrayList("yes", "no"));
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	
	input.setNullValid(true);
	
	add(input);

	input.add(new AjaxFormComponentUpdatingBehavior("change"){

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example 26
public void component(Component object, IVisit<Void> visit) {
	if (!visited.contains(object) && (object instanceof FormComponent) && !(object instanceof Button)) {
		final FormComponent<?> fc = (FormComponent<?>) object;
		visited.add(fc);
		if (!found && fc.isEnabled() && fc.isVisible()
				&& (fc instanceof DropDownChoice || fc instanceof AbstractTextComponent)) {
			found = true;
			fc.add(new DefaultFocusBehavior());
		}
	}
}
 
Example 27
Source Project: openmeetings   Source File: OAuthForm.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	add(new CheckBox("isEnabled"));
	add(new RequiredTextField<String>("name").setLabel(new ResourceModel("165")));
	add(new TextField<String>("iconUrl").setLabel(new ResourceModel("1575")));
	add(new RequiredTextField<String>("clientId").setLabel(Model.of("client_id")));
	add(new RequiredTextField<String>("clientSecret").setLabel(Model.of("client_secret")));
	add(redirectUriText = (TextField<String>) new TextField<>("redirectUri", Model.of("")).setLabel(new ResourceModel("1587")));
	add(new RequiredTextField<String>("requestKeyUrl").setLabel(new ResourceModel("1578")));
	add(new DropDownChoice<>("requestTokenMethod", List.of(RequestTokenMethod.values()), new ChoiceRenderer<RequestTokenMethod>("name", "name")));
	add(new RequiredTextField<String>("requestTokenUrl").setLabel(new ResourceModel("1579")));
	add(new RequiredTextField<String>("requestTokenAttributes").setLabel(new ResourceModel("1586")));
	add(new RequiredTextField<String>("requestInfoUrl").setLabel(new ResourceModel("1580")));
	add(new DropDownChoice<>("requestInfoMethod", List.of(RequestInfoMethod.values()), new ChoiceRenderer<RequestInfoMethod>("name", "name")));
	Form<Void> mappingForm = new Form<>("mappingForm");
	final TextField<String> omAttr = new TextField<>("omAttr", Model.of(""));
	final TextField<String> oauthAttr = new TextField<>("oauthAttr", Model.of(""));
	add(mappingForm.add(omAttr, oauthAttr
			, new BootstrapAjaxButton("addMapping", new ResourceModel("1261"), mappingForm, Buttons.Type.Outline_Primary) {
				private static final long serialVersionUID = 1L;

				@Override
				protected void onSubmit(AjaxRequestTarget target) {
					if (Strings.isEmpty(omAttr.getModelObject()) || Strings.isEmpty(oauthAttr.getModelObject())) {
						return;
					}
					OAuthServer s = OAuthForm.this.getModelObject();
					s.addMapping(omAttr.getModelObject(), oauthAttr.getModelObject());
					updateMapping();
					target.add(attrsContainer, mappingForm);
				}
			}).setOutputMarkupId(true));
	add(attrsContainer.add(updateMapping()).setOutputMarkupId(true));
	super.onInitialize();
}
 
Example 28
Source Project: openmeetings   Source File: VoteDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(feedback.setOutputMarkupId(true));
	add(new Label("user", user));
	add(new Label("roomPoll.question"));
	add(typeBool.add(new RadioGroup<Boolean>("answer").setRequired(true)
				.add(new Radio<>("true", Model.of(Boolean.TRUE))).add(new Radio<>("false", Model.of(Boolean.FALSE)))
		).setOutputMarkupPlaceholderTag(true).setVisible(false));
	add(typeInt.add(new DropDownChoice<>("pointList", answers).setRequired(true))
			.setOutputMarkupPlaceholderTag(true).setVisible(false));
}
 
Example 29
public static DropDownChoice<Integer> getPageSizeDropDownChoice(final String id, final Locale locale, final IModel<Integer> model,
  final int minValue, final int maxValue)
  {
final LabelValueChoiceRenderer<Integer> pageSizeChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
final NumberFormat nf = NumberFormat.getInstance(locale);
for (final int size : PAGE_SIZES) {
  if (size >= minValue && size <= maxValue) {
    pageSizeChoiceRenderer.addValue(size, nf.format(size));
  }
}
final DropDownChoice<Integer> pageSizeChoice = new DropDownChoice<Integer>(id, model, pageSizeChoiceRenderer.getValues(),
    pageSizeChoiceRenderer);
pageSizeChoice.setNullValid(false);
return pageSizeChoice;
  }
 
Example 30
Source Project: webanno   Source File: ImportDocumentsPanel.java    License: Apache License 2.0 5 votes vote down vote up
public ImportDocumentsPanel(String aId, IModel<Project> aProject)
{
    super(aId);

    projectModel = aProject;
    
    Form<Void> form = new Form<>("form");
    add(form);
    
    format = Model.of();
    List<String> readableFormats = listReadableFormats();
    if (!readableFormats.isEmpty()) {
        if (readableFormats.contains("Plain text")) {
            format.setObject("Plain text");
        }
        else {
            format.setObject(readableFormats.get(0));
        }
    }
    
    form.add(fileUpload = new BootstrapFileInputField("documents"));
    fileUpload.getConfig().showPreview(false);
    fileUpload.getConfig().showUpload(false);
    fileUpload.getConfig().showRemove(false);
    fileUpload.setRequired(true);

    DropDownChoice<String> formats = new BootstrapSelect<>("format");
    formats.setModel(format);
    formats.setChoices(LambdaModel.of(this::listReadableFormats));
    form.add(formats);
    
    form.add(new LambdaAjaxButton<>("import", this::actionImport));
}