/** * Adds attribute onchange="javascript:submit();" * @return This for chaining. */ public DropDownChoicePanel<T> setAutoSubmit() { dropDownChoice.add(AttributeModifier.replace("onchange", "javascript:submit();")); return this; }
public BooleanFilterPanel(String id, final IModel<Boolean> valueModel) { super(id, valueModel); List<Boolean> list = Lists.newArrayList(); list.add(Boolean.TRUE); list.add(Boolean.FALSE); final DropDownChoice<Boolean> choice = new DropDownChoice<>("booleanChoice", valueModel, list); choice.add(new AjaxFormSubmitBehavior("change") {}); choice.setNullValid(true); add(choice); this.choiceComponent = choice; }
private void addUsersDropDownChoice() { IModel<List<Actor>> actorsModel = $m.get(() -> moduleDriver.findEligibleUsers(moduleEntity.getObject(), dataModel.getObject(), itemAction.getConfirmation())); usersDropDownChoice = new DropDownChoice<>("usersDropDownChoice", new Model<>(), actorsModel, new ChoiceRenderer<>("nome", "codUsuario")); usersDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(confirmButton); } }); border.add(usersDropDownChoice); }
public DropDownListWidget(final String id, final DropDownList dropDownList, final IModel<String> model, IChoiceRenderer<String> renderer) { super(id); List<String> options = Arrays.asList(dropDownList.value()); final DropDownChoice<String> dropDown = new DropDownChoice("dropdownlist", model, options, renderer); if (options.contains(null)) { dropDown.setNullValid(true); } dropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.add(DropDownListWidget.this); } }); add(dropDown); setOutputMarkupId(true); }
private void addUsersDropDownChoice() { IModel<List<Actor>> actorsModel = $m.get(() -> moduleDriver.findEligibleUsers(moduleEntity.getObject(), dataModel.getObject(), itemAction.getConfirmation())); usersDropDownChoice = new DropDownChoice<>("usersDropDownChoice", new Model<>(), actorsModel, new ChoiceRenderer<>("nome", "codUsuario")); usersDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(confirmButton); } }); border.add(usersDropDownChoice); }
/** * @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); }
private void addUsersDropDownChoice() { IModel<List<Actor>> actorsModel = $m.get(() -> moduleService.findEligibleUsers(dataModel.getObject(), itemAction.getConfirmation())); usersDropDownChoice = new DropDownChoice<>("usersDropDownChoice", new Model<>(), actorsModel, new ChoiceRenderer<>("nome", "codUsuario")); usersDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(confirmButton); } }); border.add(usersDropDownChoice); }
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; }
private void initPageSizeChoice(final IPageableItems pageable, final PagerConfigurator configurator) { final DropDownChoice<Long> choice = new DropDownChoice<>("pageSize", CHOICES); choice.setDefaultModel(new PropertyModel<Long>(pageable, "itemsPerPage")); add(choice); choice.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { reset(); onAjaxEvent(target); configurator.onItemsPerPageChanged(target, pageable.getItemsPerPage()); } }); } }
private DropDownChoice<StoredQuery> storedQueriesDropDown() { final DropDownChoice<StoredQuery> dropdown = new DropDownChoice<>( "storedQueriesDropDown", new Model<>(), new StoredQueryListModel(), new StoredQueryListRenderer()); dropdown.setRequired(true); dropdown.add( new AjaxFormComponentUpdatingBehavior("change") { /** serialVersionUID */ private static final long serialVersionUID = -7195159596309736905L; @Override protected void onUpdate(AjaxRequestTarget target) { StoredQuery selection = (StoredQuery) dropdown.getDefaultModelObject(); parameterProvider.refreshItems(selection.storedQueryId); target.add(parameters); } }); return dropdown; }
@Override protected void populateItem(Item<RolePermission> item) { item.add(new Label("registrant", item.getModelObject().getRegistrant().getObject().getName())); final DropDownChoice<PermissionSetting> permissionChoice = new DropDownChoice<PermissionSetting>("permission", Arrays.asList(PermissionSetting .values()), new PermissionSettingRenderer()); permissionChoice.setOutputMarkupId(true); permissionChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.add(permissionChoice); } }); item.add(permissionChoice); }
public WorkspaceSwitcher(String id, IModel<Workspace> model) { super(id, model); IModel<List<? extends Workspace>> workspaceModel = new LoadableDetachableModel<List<? extends Workspace>>() { @Override protected List<? extends Workspace> load() { return getWorkspaces(); } }; DropDownChoice<Workspace> choice = new DropDownChoice<Workspace>("workspaces", model, workspaceModel, new Renderer()); choice.add(new FormComponentUpdatingBehavior(){ @Override protected void onUpdate() { getFormComponent().detach(); } }); choice.setNullValid(false); add(choice); }
private DropDownChoice<AddressType> newModbusAddressTypeDropdown( final ModbusConfigurationEntry configEntry) { final DropDownChoice<AddressType> dropDown = new DropDownChoice<AddressType>( "type", new PropertyModel<AddressType>(configEntry, "modbusRange.modbusAddressType"), modbusTypes, new ModbusAddressTypeChoiceRenderer()); dropDown.setRequired(true); dropDown.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { configEntry.getModbusRange().setModbusAddressType(dropDown.getModelObject()); } }); return dropDown; }
private DropDownChoice<AnnotationLayer> createDefaultAnnotationLayerSelector() { DropDownChoice<AnnotationLayer> selector = new BootstrapSelect<>("defaultAnnotationLayer"); selector.setChoices(new PropertyModel<>(this, "annotationLayers")); selector.setChoiceRenderer(new ChoiceRenderer<>("uiName")); selector.setOutputMarkupId(true); selector.add(LambdaAjaxFormComponentUpdatingBehavior.onUpdate("change", this::actionChangeDefaultLayer)); return selector; }
@Override protected void populateItem(Item<UserPermission> item) { // item.add(new Label("registrant", item.getModelObject().getRegistrant().getObject().getName())); item.add(new UserImagePanel("registrant", item.getModelObject().getRegistrant())); final DropDownChoice<PermissionSetting> permissionChoice = new DropDownChoice<PermissionSetting>("permission", Arrays.asList(PermissionSetting .values()), new PermissionSettingRenderer()); permissionChoice.setOutputMarkupId(true); permissionChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.add(permissionChoice); } }); item.add(permissionChoice); }
public DocumentRepositorySelectionForm(String aId) { super(aId); DropDownChoice<DocumentRepository> repositoryCombo = new BootstrapSelect<DocumentRepository>("repositoryCombo", new PropertyModel<DocumentRepository>(ExternalSearchAnnotationSidebar.this, "currentRepository"), repositoriesModel); repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name")); repositoryCombo.setNullValid(false); // Just update the selection repositoryCombo.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); add(repositoryCombo); } }
public PreAuthenticatedUserNameFilterPanel(String id, IModel<T> model) { super(id, model); add(new HelpLink("roleSourceHelp", this).setDialog(dialog)); createRoleSourceDropDown(); roleSourceChoice.setNullValid(false); roleSourceChoice.add( new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { Panel p = getRoleSourcePanel(roleSourceChoice.getModelObject()); WebMarkupContainer c = (WebMarkupContainer) get("container"); c.addOrReplace(p); target.add(c); } }); WebMarkupContainer container = new WebMarkupContainer("container"); add(container.setOutputMarkupId(true)); // show correct panel for existing configuration RoleSource rs = model.getObject().getRoleSource(); addRoleSourceDropDown(container, rs); }
public DocumentMetadataAnnotationSelectionPanel(String aId, IModel<Project> aProject, IModel<SourceDocument> aDocument, IModel<String> aUsername, JCasProvider aJCasProvider, DocumentMetadataAnnotationDetailPanel aDetails, AnnotationPage aAnnotationPage) { super(aId, aProject); setOutputMarkupPlaceholderTag(true); annotationPage = aAnnotationPage; sourceDocument = aDocument; username = aUsername; jcasProvider = aJCasProvider; detailPanel = aDetails; selectedLayer = Model.of(); add(createAnnotationList()); DropDownChoice<AnnotationLayer> layer = new BootstrapSelect<>("layer"); layer.setModel(selectedLayer); layer.setChoices(this::listMetadataLayers); layer.setChoiceRenderer(new ChoiceRenderer<>("uiName")); layer.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); add(layer); add(new LambdaAjaxLink("create", this::actionCreate)); }
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; }
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; }