/** Constructor. */ public ChoicePage() { modelsMap.put("AUDI", Arrays.asList("A4", "A6", "TT")); modelsMap.put("CADILLAC", Arrays.asList("CTS", "DTS", "ESCALADE", "SRX", "DEVILLE")); modelsMap.put("FORD", Arrays.asList("CROWN", "ESCAPE", "EXPEDITION", "EXPLORER", "F-150")); IModel<List<? extends String>> makeChoices = new AbstractReadOnlyModel<List<? extends String>>() { private static final long serialVersionUID = 3083223353505563226L; @Override public List<String> getObject() { return new ArrayList<String>(modelsMap.keySet()); } }; IModel<List<? extends String>> modelChoices = new AbstractReadOnlyModel<List<? extends String>>() { private static final long serialVersionUID = -582253860769928261L; @Override public List<String> getObject() { List<String> models = modelsMap.get(selectedMake); if (models == null) { models = Collections.emptyList(); } return models; } }; Form<?> form = new Form("formid"); add(form); final DropDownChoice<String> makes = new DropDownChoice<String>( "makes", new PropertyModel<String>(this, "selectedMake"), makeChoices); final DropDownChoice<String> models = new DropDownChoice<String>("models", new Model<String>(), modelChoices); models.setOutputMarkupId(true); final DropDownChoice<String> models2 = new DropDownChoice<String>("models2", new Model<String>(), modelChoices); models2.setOutputMarkupId(true); form.add(makes); form.add(models); form.add(models2); makes.add( new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -4971073888222316420L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(models); target.add(models2); } }); }
private void addProcessSelect(Form<Void> layoutForm) { processNameList = new ArrayList<String>(); for (SushiProcess process : SushiProcess.findAll()) { processNameList.add(process.getName()); } processSelect = new DropDownChoice<String>("processSelect", new Model<String>(), processNameList); processSelect.setOutputMarkupId(true); processSelect.add( new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { process = SushiProcess.findByName( processSelect.getChoices().get(Integer.parseInt(processSelect.getValue()))) .get(0); createProcessInstanceMonitoringProvider(); target.add(dataTable); } }); layoutForm.add(processSelect); }
public BranchSelectionPanel( String id, IModel<String> repositoryUriModel, IModel<String> branchNameModel, Form<DataStoreInfo> storeEditForm) { super(id, branchNameModel); this.repositoryUriModel = repositoryUriModel; final List<String> choices = new ArrayList<String>(); choice = new DropDownChoice<String>("branchDropDown", branchNameModel, choices); choice.setOutputMarkupId(true); choice.setNullValid(true); choice.setRequired(false); add(choice); updateChoices(false, null); final AjaxSubmitLink refreshLink = new AjaxSubmitLink("refresh", storeEditForm) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { onSubmit(target, form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { updateChoices(true, form); target.add(BranchSelectionPanel.this.choice); } }; add(refreshLink); }
private void buildCountryInput() { countryInput = new DropDownChoice<Country>( "country", Arrays.asList(Country.values()), new EnumChoiceRenderer<Country>(this)); countryInput.setNullValid(true); countryInput.setOutputMarkupId(true); form.add(countryInput); }
private void buildGenderInput() { genderInput = new DropDownChoice<Gender>( "gender", Arrays.asList(Gender.values()), new EnumChoiceRenderer<Gender>(this)); genderInput.setNullValid(true); genderInput.setOutputMarkupId(true); form.add(genderInput); }
private void buildNationalityInput() { nationalityInput = new DropDownChoice<Nationality>( "nationality", Arrays.asList(Nationality.values()), new EnumChoiceRenderer<Nationality>(this)); nationalityInput.setNullValid(true); nationalityInput.setOutputMarkupId(true); form.add(nationalityInput); }
private void initLayout() { final Form searchForm = new Form(ID_SEARCH_FORM); add(searchForm); searchForm.setOutputMarkupId(true); final IModel<ReportOutputSearchDto> model = (IModel) getDefaultModel(); BasicSearchPanel<ReportOutputSearchDto> basicSearch = new BasicSearchPanel<ReportOutputSearchDto>(ID_BASIC_SEARCH, model) { @Override protected IModel<String> createSearchTextModel() { return new PropertyModel<String>(model, UsersDto.F_TEXT); } @Override protected void searchPerformed(AjaxRequestTarget target) { PageCreatedReports page = (PageCreatedReports) getPage(); page.searchPerformed(target); } @Override protected void clearSearchPerformed(AjaxRequestTarget target) { PageCreatedReports page = (PageCreatedReports) getPage(); page.clearSearchPerformed(target); } }; searchForm.add(basicSearch); DropDownChoice reportTypeSelect = new DropDownChoice( ID_REPORT_TYPE_SELECT, new PropertyModel(model, ReportOutputSearchDto.F_REPORT_TYPE), new PropertyModel(model, ReportOutputSearchDto.F_REPORT_TYPES), new ChoiceRenderer()) { @Override protected String getNullValidDisplayValue() { return getString("pageCreatedReports.filter.reportType"); } }; reportTypeSelect.add( new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { PageCreatedReports page = (PageCreatedReports) getPage(); page.searchPerformed(target); } }); reportTypeSelect.setOutputMarkupId(true); reportTypeSelect.setNullValid(true); searchForm.add(reportTypeSelect); }
private void initLayout() { IModel data = new PropertyModel(getModel(), SearchValue.F_VALUE); final DisplayableRenderer renderer = new DisplayableRenderer(choices); final DropDownChoice input = new DropDownChoice(ID_COMBO_INPUT, data, choices, renderer) { @Override public IConverter getConverter(Class type) { return renderer; } }; input.setNullValid(true); input.setOutputMarkupId(true); add(input); }
public GridSubsetsEditor(final String id, final IModel<Set<XMLGridSubset>> model) { super(id, model); add(validator = new GridSubsetListValidator()); // container for ajax updates final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); // the link list table = new WebMarkupContainer("table"); table.setOutputMarkupId(true); container.add(table); grids = new ListView<XMLGridSubset>( "gridSubsets", new ArrayList<XMLGridSubset>(model.getObject())) { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { super.onBeforeRender(); } @Override protected void populateItem(final ListItem<XMLGridSubset> item) { // odd/even style final int index = item.getIndex(); item.add(new SimpleAttributeModifier("class", index % 2 == 0 ? "even" : "odd")); final XMLGridSubset gridSubset = item.getModelObject(); GridSetBroker gridSetBroker = GWC.get().getGridSetBroker(); String gridsetDescription = null; int gridsetLevels; boolean gridsetExists; { final GridSet gridSet = gridSetBroker.get(gridSubset.getGridSetName()); gridsetExists = gridSet != null; if (gridsetExists) { gridsetLevels = gridSet.getNumLevels(); gridsetDescription = gridSet.getDescription(); } else { gridsetLevels = gridSubset.getZoomStop() == null ? 1 : gridSubset.getZoomStop().intValue(); } } final Label gridSetLabel; final Component gridSetBounds; gridSetLabel = new Label("gridSet", new PropertyModel<String>(item.getModel(), "gridSetName")); if (!gridsetExists) { gridSetLabel.add( new AttributeModifier( "style", true, new Model<String>("color:red;text-decoration:line-through;"))); getPage().warn("GridSet " + gridSubset.getGridSetName() + " does not exist"); } item.add(gridSetLabel); if (null != gridsetDescription) { gridSetLabel.add( new AttributeModifier("title", true, new Model<String>(gridsetDescription))); } final Component removeLink; final int maxZoomLevel = gridsetLevels - 1; final ArrayList<Integer> zoomLevels = new ArrayList<Integer>(maxZoomLevel + 1); for (int z = 0; z <= maxZoomLevel; z++) { zoomLevels.add(Integer.valueOf(z)); } // zoomStart has all zoom levels as choices // zoomStop choices start at zoomStart's selection // minCachedLevel start at zoomStart's selection and ends at zoomStop's selection // maxCachedLevel start at minCachedLevels' and ends at zoomStop's selection final IModel<Integer> zoomStartModel; final IModel<Integer> zoomStopModel; final IModel<Integer> minCachedLevelModel; final IModel<Integer> maxCachedLevelModel; final ZoomLevelDropDownChoice zoomStart; final ZoomLevelDropDownChoice zoomStop; final ZoomLevelDropDownChoice minCachedLevel; final ZoomLevelDropDownChoice maxCachedLevel; zoomStartModel = new PropertyModel<Integer>(item.getModel(), "zoomStart"); zoomStopModel = new PropertyModel<Integer>(item.getModel(), "zoomStop"); minCachedLevelModel = new PropertyModel<Integer>(item.getModel(), "minCachedLevel"); maxCachedLevelModel = new PropertyModel<Integer>(item.getModel(), "maxCachedLevel"); @SuppressWarnings({"rawtypes", "unchecked"}) final IModel<List<Integer>> allLevels = new Model(zoomLevels); zoomStart = new ZoomLevelDropDownChoice("zoomStart", zoomStartModel, allLevels); zoomStart.setEnabled(gridsetExists); item.add(zoomStart); zoomStop = new ZoomLevelDropDownChoice("zoomStop", zoomStopModel, allLevels); zoomStop.setEnabled(gridsetExists); item.add(zoomStop); minCachedLevel = new ZoomLevelDropDownChoice("minCachedLevel", minCachedLevelModel, allLevels); minCachedLevel.setEnabled(gridsetExists); item.add(minCachedLevel); maxCachedLevel = new ZoomLevelDropDownChoice("maxCachedLevel", maxCachedLevelModel, allLevels); maxCachedLevel.setEnabled(gridsetExists); item.add(maxCachedLevel); for (ZoomLevelDropDownChoice dropDown : Arrays.asList(zoomStart, zoomStop, minCachedLevel, maxCachedLevel)) { dropDown.add( new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; // cascades to zoomStop, min and max cached levels @Override protected void onUpdate(AjaxRequestTarget target) { updateValidZoomRanges( zoomStart, zoomStop, minCachedLevel, maxCachedLevel, target); } }); } updateValidZoomRanges(zoomStart, zoomStop, minCachedLevel, maxCachedLevel, null); // gridSetBounds = new EnvelopePanel("bounds"); // gridSetBounds.setCRSFieldVisible(false); // gridSetBounds.setCrsRequired(false); // gridSetBounds.setLabelsVisibility(false); // gridSetBounds.setModel(new Model<ReferencedEnvelope>(new ReferencedEnvelope())); gridSetBounds = new Label("bounds", new ResourceModel("GridSubsetsEditor.bounds.dynamic")); item.add(gridSetBounds); removeLink = new ImageAjaxLink("removeLink", GWCIconFactory.DELETE_ICON) { private static final long serialVersionUID = 1L; @Override protected void onClick(AjaxRequestTarget target) { List<XMLGridSubset> list; list = new ArrayList<XMLGridSubset>(grids.getModelObject()); final XMLGridSubset subset = (XMLGridSubset) getDefaultModelObject(); list.remove(subset); grids.setModelObject(list); List<String> choices = new ArrayList<String>(availableGridSets.getChoices()); choices.add(subset.getGridSetName()); Collections.sort(choices); availableGridSets.setChoices(choices); target.addComponent(container); target.addComponent(availableGridSets); } }; removeLink.setDefaultModel(item.getModel()); removeLink.add( new AttributeModifier( "title", true, new ResourceModel("GridSubsetsEditor.removeLink"))); item.add(removeLink); } }; grids.setOutputMarkupId(true); // this is necessary to avoid loosing item contents on edit/validation checks grids.setReuseItems(true); table.add(grids); List<String> gridSetNames = new ArrayList<String>(GWC.get().getGridSetBroker().getNames()); for (XMLGridSubset gs : model.getObject()) { gridSetNames.remove(gs.getGridSetName()); } Collections.sort(gridSetNames); GeoServerAjaxFormLink addGridsubsetLink = new GeoServerAjaxFormLink("addGridSubset") { private static final long serialVersionUID = 1L; @Override protected void onClick(AjaxRequestTarget target, Form form) { availableGridSets.processInput(); final String selectedGridset = availableGridSets.getModelObject(); if (null == selectedGridset) { return; } List<String> choices = new ArrayList<String>(availableGridSets.getChoices()); choices.remove(selectedGridset); availableGridSets.setChoices(choices); availableGridSets.setEnabled(!choices.isEmpty()); XMLGridSubset newSubset = new XMLGridSubset(); newSubset.setGridSetName(selectedGridset); grids.getModelObject().add(newSubset); target.addComponent(table); target.addComponent(availableGridSets); } }; addGridsubsetLink.add(new Icon("addIcon", GWCIconFactory.ADD_ICON)); add(addGridsubsetLink); availableGridSets = new DropDownChoice<String>("availableGridsets", new Model<String>(), gridSetNames); availableGridSets.setOutputMarkupId(true); add(availableGridSets); }
public AdminOrderPageForm(String id) { super(id); errorPanel = new FeedbackPanel("feedback"); username = new TextField<String>("username", Model.of("")); email = new TextField<String>("email", Model.of("")); countryCostModel = Model.of(""); hotelCostModel = Model.of(""); tourCostModel = Model.of(""); countryCost = new Label("countryCostLabel", countryCostModel); hotelCost = new Label("hotelCostLabel", hotelCostModel); tourCost = new Label("tourCostLabel", tourCostModel); order = new Order(); orderDao = new OrderDao(); hotelOptions = new HashMap<String, List<String>>(); tourOptions = new HashMap<String, List<String>>(); countries = orderDao.getCountries(); hotels = orderDao.getHotels(); tours = orderDao.getTours(); for (OrderObject country : countries) { hotelOptions.put(country.getName(), getNames(hotels, country.getName())); tourOptions.put(country.getName(), getNames(tours, country.getName())); } IModel<List<? extends String>> makeCountryChoises = new AbstractReadOnlyModel<List<? extends String>>() { @Override public List<String> getObject() { return new ArrayList<String>(hotelOptions.keySet()); } }; IModel<List<? extends String>> modelTownChoices = new AbstractReadOnlyModel<List<? extends String>>() { @Override public List<String> getObject() { List<String> models = hotelOptions.get(selectedOption); if (models == null) { models = Collections.emptyList(); } return models; } }; IModel<List<? extends String>> modelTourChoices = new AbstractReadOnlyModel<List<? extends String>>() { @Override public List<String> getObject() { List<String> models = tourOptions.get(selectedOption); if (models == null) { models = Collections.emptyList(); } return models; } }; countryDropDown = new DropDownChoice<String>( "countryDropDown", new PropertyModel<String>(this, "selectedOption"), makeCountryChoises); hotelDropDown = new DropDownChoice<String>( "hotelDropDown", new PropertyModel<String>(this, "selectedHotel"), modelTownChoices); tourDropDown = new DropDownChoice<String>( "tourDropDown", new PropertyModel<String>(this, "selectedTour"), modelTourChoices); totalCostSumModel = new PropertyModel<String>(this, "calculatedTotalCostSum"); totalCostSum = new TextField("totalCostSumLabel", totalCostSumModel); hotelDropDown.setOutputMarkupId(true); tourDropDown.setOutputMarkupId(true); countryCost.setOutputMarkupId(true); hotelCost.setOutputMarkupId(true); tourCost.setOutputMarkupId(true); totalCostSum.setOutputMarkupId(true); countryDropDown.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(hotelDropDown); target.add(tourDropDown); String cost = getCost(countries, selectedOption); countryCostModel.setObject(cost); hotelCostModel.setObject(getCost(hotels, selectedHotel)); tourCostModel.setObject(getCost(tours, selectedTour)); totalCostSumModel.setObject(getTotalCostSum()); target.add(countryCost); target.add(hotelCost); target.add(tourCost); target.add(totalCostSum); } }); hotelDropDown.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { hotelCostModel.setObject(getCost(hotels, selectedHotel)); totalCostSumModel.setObject(getTotalCostSum()); target.add(hotelCost); target.add(totalCostSum); } }); tourDropDown.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { tourCostModel.setObject(getCost(tours, selectedTour)); totalCostSumModel.setObject(getTotalCostSum()); target.add(tourCost); target.add(totalCostSum); } }); add(new Label("feedBack", feedBack)); add(errorPanel); add(username); add(email); add(countryDropDown); add(hotelDropDown); add(tourDropDown); add(countryCost); add(hotelCost); add(tourCost); add(totalCostSum); }
protected void initUI(StyleInfo style) { IModel<StyleInfo> styleModel = new CompoundPropertyModel( style != null ? new StyleDetachableModel(style) : getCatalog().getFactory().createStyle()); styleForm = new Form("form", styleModel) { @Override protected void onSubmit() { super.onSubmit(); onStyleFormSubmit(); } }; styleForm.setMarkupId("mainForm"); add(styleForm); styleForm.add(nameTextField = new TextField("name")); nameTextField.setRequired(true); DropDownChoice<WorkspaceInfo> wsChoice = new DropDownChoice("workspace", new WorkspacesModel(), new WorkspaceChoiceRenderer()); wsChoice.setNullValid(true); if (!isAuthenticatedAsAdmin()) { wsChoice.setNullValid(false); wsChoice.setRequired(true); } styleForm.add(wsChoice); styleForm.add(editor = new CodeMirrorEditor("SLD", new PropertyModel(this, "rawSLD"))); // force the id otherwise this blasted thing won't be usable from other forms editor.setTextAreaMarkupId("editor"); editor.setOutputMarkupId(true); editor.setRequired(true); styleForm.add(editor); if (style != null) { try { setRawSLD(readFile(style)); } catch (IOException e) { // ouch, the style file is gone! Register a generic error message Session.get() .error(new ParamResourceModel("sldNotFound", this, style.getFilename()).getString()); } } // style copy functionality styles = new DropDownChoice( "existingStyles", new Model(), new StylesModel(), new StyleChoiceRenderer()); styles.setOutputMarkupId(true); styles.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { styles.validate(); copyLink.setEnabled(styles.getConvertedInput() != null); target.addComponent(copyLink); } }); styleForm.add(styles); copyLink = copyLink(); copyLink.setEnabled(false); styleForm.add(copyLink); uploadForm = uploadForm(styleForm); uploadForm.setMultiPart(true); uploadForm.setMaxSize(Bytes.megabytes(1)); uploadForm.setMarkupId("uploadForm"); add(uploadForm); uploadForm.add(fileUploadField = new FileUploadField("filename")); add(validateLink()); Link cancelLink = new Link("cancel") { @Override public void onClick() { setResponsePage(StylePage.class); } }; add(cancelLink); }
public AdvancedCorrelationPanel(String id) { super(id); Form<Void> advancedCorrelationForm = new WarnOnExitForm("advancedCorrelationForm"); add(advancedCorrelationForm); timeCorrelationCheckBox = new AjaxCheckBox("timeCheckBox", Model.of(Boolean.FALSE)) { @Override protected void onUpdate(AjaxRequestTarget target) { timeCorrelationSelected = timeCorrelationSelected ? false : true; } }; timeCorrelationCheckBox.setOutputMarkupId(true); advancedCorrelationForm.add(timeCorrelationCheckBox); timeCorrelationEventTypeSelect = new DropDownChoice<SushiEventType>( "timeEventTypeSelect", new PropertyModel<SushiEventType>(this, "selectedEventType"), new ArrayList<SushiEventType>()); timeCorrelationEventTypeSelect.setOutputMarkupId(true); timeCorrelationEventTypeSelect.add( new AjaxFormComponentUpdatingBehavior("onChange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (selectedEventType != null) { conditionPanel.setSelectedEventTypes(Arrays.asList((selectedEventType))); conditionPanel.updateAttributesValues(); } else { conditionPanel.getConditionAttributeSelect().setChoices(new ArrayList<String>()); conditionPanel.getConditionValueSelect().setChoices(new ArrayList<Serializable>()); } target.add(conditionPanel.getConditionAttributeSelect()); target.add(conditionPanel.getConditionValueSelect()); } }); advancedCorrelationForm.add(timeCorrelationEventTypeSelect); timeCorrelationMinutesInput = new TextField<String>("timeMinutesInput", Model.of("")); timeCorrelationMinutesInput.setOutputMarkupId(true); timeCorrelationMinutesInput.add( new AjaxFormComponentUpdatingBehavior("onChange") { @Override protected void onUpdate(AjaxRequestTarget target) { timeCorrelationMinutes = timeCorrelationMinutesInput.getValue(); } }); advancedCorrelationForm.add(timeCorrelationMinutesInput); timeCorrelationAfterOrBeforeType = new RadioChoice<String>( "afterOrBeforeRadioGroup", new PropertyModel<String>(this, "selectedTimeRadioOption"), timeCorrelationRadioValues) { public String getSuffix() { return " "; } }; advancedCorrelationForm.add(timeCorrelationAfterOrBeforeType); conditionPanel = new ConditionInputPanel("conditionInput", true); advancedCorrelationForm.add(conditionPanel); multipleConditionsTextField = new TextField<String>("multipleConditionsTextField", new Model<String>()); multipleConditionsTextField.setOutputMarkupId(true); OnChangeAjaxBehavior onChangeAjaxBehavior = new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5737941362786901904L; @Override protected void onUpdate(AjaxRequestTarget target) { if (isMultipleConditionsTextFieldFilled()) { conditionPanel.disableAllComponents(target); } else { conditionPanel.enableAllComponents(target); } } }; multipleConditionsTextField.add(onChangeAjaxBehavior); advancedCorrelationForm.add(multipleConditionsTextField); }