List of usage examples for org.apache.wicket.ajax.form OnChangeAjaxBehavior OnChangeAjaxBehavior
public OnChangeAjaxBehavior()
From source file:org.geoserver.web.catalogstresstool.CatalogStressTester.java
License:Open Source License
public CatalogStressTester() { super();// w w w . j av a 2 s . c o m setDefaultModel(new Model()); Form form = new Form("form", new Model()); add(form); IModel<List<Tuple>> wsModel = new LoadableDetachableModel<List<Tuple>>() { private static final long serialVersionUID = 1L; @Override protected List<Tuple> load() { Catalog catalog = GeoServerApplication.get().getCatalog(); Filter filter = Predicates.acceptAll(); CloseableIterator<WorkspaceInfo> list = catalog.list(WorkspaceInfo.class, filter, null, 4000, null); List<Tuple> workspaces; try { workspaces = Lists.newArrayList(Iterators.transform(list, new Function<WorkspaceInfo, Tuple>() { @Override public Tuple apply(WorkspaceInfo input) { return new Tuple(input.getId(), input.getName()); } })); } finally { list.close(); } Collections.sort(workspaces); return workspaces; } }; workspace = new DropDownChoice<Tuple>("workspace", new Model<Tuple>(), wsModel, new TupleChoiceRenderer()); workspace.setNullValid(true); workspace.setOutputMarkupId(true); workspace.setRequired(true); form.add(workspace); workspace.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5613056077847641106L; @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(store); target.addComponent(resourceAndLayer); } }); IModel<List<Tuple>> storesModel = new LoadableDetachableModel<List<Tuple>>() { private static final long serialVersionUID = 1L; @Override protected List<Tuple> load() { Catalog catalog = GeoServerApplication.get().getCatalog(); Tuple ws = workspace.getModelObject(); if (ws == null) { return Lists.newArrayList(); } Filter filter = Predicates.equal("workspace.id", ws.id); int limit = 100; CloseableIterator<StoreInfo> iter = catalog.list(StoreInfo.class, filter, null, limit, null); List<Tuple> stores; try { stores = Lists.newArrayList(Iterators.transform(iter, new Function<StoreInfo, Tuple>() { @Override public Tuple apply(StoreInfo input) { return new Tuple(input.getId(), input.getName()); } })); } finally { iter.close(); } Collections.sort(stores); return stores; } }; store = new DropDownChoice<Tuple>("store", new Model<Tuple>(), storesModel, new TupleChoiceRenderer()); store.setNullValid(true); store.setOutputMarkupId(true); store.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5333344688588590014L; @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(resourceAndLayer); } }); form.add(store); IModel<List<Tuple>> resourcesModel = new LoadableDetachableModel<List<Tuple>>() { private static final long serialVersionUID = 1L; @Override protected List<Tuple> load() { Catalog catalog = getCatalog(); Tuple storeInfo = store.getModelObject(); if (storeInfo == null) { return Lists.newArrayList(); } Integer limit = 100; Filter filter = Predicates.equal("store.id", storeInfo.id); CloseableIterator<ResourceInfo> iter = catalog.list(ResourceInfo.class, filter, null, limit, null); List<Tuple> resources; try { resources = Lists.newArrayList(Iterators.transform(iter, new Function<ResourceInfo, Tuple>() { @Override public Tuple apply(ResourceInfo input) { return new Tuple(input.getId(), input.getName()); } })); } finally { iter.close(); } Collections.sort(resources); return resources; } }; resourceAndLayer = new DropDownChoice<Tuple>("resourceAndLayer", new Model<Tuple>(), resourcesModel, new TupleChoiceRenderer()); resourceAndLayer.setNullValid(true); resourceAndLayer.setOutputMarkupId(true); form.add(resourceAndLayer); duplicateCount = new TextField<Integer>("duplicateCount", new Model<Integer>(100), Integer.class); duplicateCount.setRequired(true); duplicateCount.add(new RangeValidator<Integer>(1, 100000)); form.add(duplicateCount); sufix = new TextField<String>("sufix", new Model<String>("copy-")); sufix.setRequired(true); form.add(sufix); progress = new Label("progress", new Model<String>("0/0")); progress.setOutputMarkupId(true); form.add(progress); form.add(new AjaxButton("cancel") { private static final long serialVersionUID = 5767430648099432407L; protected void onSubmit(AjaxRequestTarget target, Form<?> form) { setResponsePage(ToolPage.class); } }); startLink = new AjaxButton("submit", form) { private static final long serialVersionUID = -4087484089208211355L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { progress.setDefaultModelObject(""); startLink.setVisible(false); target.addComponent(startLink); target.addComponent(progress); try { startCopy(target, form); } catch (Exception e) { form.error(e.getMessage()); target.addComponent(form); } finally { startLink.setVisible(true); target.addComponent(startLink); target.addComponent(progress); } } }; form.add(startLink); startLink.setOutputMarkupId(true); }
From source file:org.geoserver.web.data.layergroup.AbstractLayerGroupPage.java
License:Open Source License
/** * Subclasses must call this method to initialize the UI for this page * @param layerGroup// w w w. j av a 2 s . com */ protected void initUI(LayerGroupInfo layerGroup) { this.returnPageClass = LayerGroupPage.class; lgModel = new LayerGroupDetachableModel(layerGroup); layerGroupId = layerGroup.getId(); Form form = new Form("form", new CompoundPropertyModel(lgModel)) { @Override public IConverter getConverter(Class<?> type) { if (LayerInfo.class.isAssignableFrom(type)) { return new LayerInfoConverter(); } else if (StyleInfo.class.isAssignableFrom(type)) { return new StyleInfoConverter(); } else { return super.getConverter(type); } } }; add(form); final WebMarkupContainer rootLayerPanelContainer = new WebMarkupContainer("rootLayerContainer"); rootLayerPanelContainer.setOutputMarkupId(true); form.add(rootLayerPanelContainer); rootLayerPanel = new RootLayerEntryPanel("rootLayer", form, layerGroup.getWorkspace()); rootLayerPanelContainer.add(rootLayerPanel); updateRootLayerPanel(layerGroup.getMode()); TextField name = new TextField("name"); name.setRequired(true); //JD: don't need this, this is validated at the catalog level //name.add(new GroupNameValidator()); form.add(name); final DropDownChoice<LayerGroupInfo.Mode> modeChoice = new DropDownChoice<LayerGroupInfo.Mode>("mode", new LayerGroupModeModel(), new LayerGroupModeChoiceRenderer()); modeChoice.setNullValid(false); modeChoice.setRequired(true); modeChoice.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { LayerGroupInfo.Mode mode = modeChoice.getModelObject(); updateRootLayerPanel(mode); target.addComponent(rootLayerPanelContainer); } }); form.add(modeChoice); form.add(new TextField("title")); form.add(new TextArea("abstract")); DropDownChoice<WorkspaceInfo> wsChoice = new DropDownChoice("workspace", new WorkspacesModel(), new WorkspaceChoiceRenderer()); wsChoice.setNullValid(true); if (!isAuthenticatedAsAdmin()) { wsChoice.setNullValid(false); wsChoice.setRequired(true); } form.add(wsChoice); //bounding box form.add(envelopePanel = new EnvelopePanel("bounds")/*.setReadOnly(true)*/); envelopePanel.setRequired(true); envelopePanel.setCRSFieldVisible(true); envelopePanel.setCrsRequired(true); envelopePanel.setOutputMarkupId(true); form.add(new GeoServerAjaxFormLink("generateBounds") { @Override public void onClick(AjaxRequestTarget target, Form form) { // build a layer group with the current contents of the group LayerGroupInfo lg = getCatalog().getFactory().createLayerGroup(); for (LayerGroupEntry entry : lgEntryPanel.getEntries()) { lg.getLayers().add(entry.getLayer()); lg.getStyles().add(entry.getStyle()); } try { // grab the eventually manually inserted CoordinateReferenceSystem crs = envelopePanel.getCoordinateReferenceSystem(); if (crs != null) { //ensure the bounds calculated in terms of the user specified crs new CatalogBuilder(getCatalog()).calculateLayerGroupBounds(lg, crs); } else { //calculate from scratch new CatalogBuilder(getCatalog()).calculateLayerGroupBounds(lg); } envelopePanel.setModelObject(lg.getBounds()); target.addComponent(envelopePanel); } catch (Exception e) { throw new WicketRuntimeException(e); } } }); form.add(lgEntryPanel = new LayerGroupEntryPanel("layers", layerGroup)); //Add panels contributed through extension point form.add(extensionPanels = extensionPanels()); form.add(saveLink()); form.add(cancelLink()); }
From source file:org.geoserver.web.data.layergroup.LayerGroupEntryPanel.java
License:Open Source License
Component defaultStyleCheckbox(String id, IModel itemModel) { final LayerGroupEntry entry = (LayerGroupEntry) itemModel.getObject(); Fragment f = new Fragment(id, "defaultStyle", this); CheckBox ds = new CheckBox("checkbox", new Model(entry.isDefaultStyle())); ds.add(new OnChangeAjaxBehavior() { @Override// w w w .ja v a 2 s . co m protected void onUpdate(AjaxRequestTarget target) { Boolean useDefault = (Boolean) getComponent().getDefaultModelObject(); entry.setDefaultStyle(useDefault); target.addComponent(layerTable); } }); f.add(ds); return f; }
From source file:org.geoserver.web.data.store.AbstractDataAccessPage.java
License:Open Source License
/** * Make the {@link #namespacePanel} model to synch up with the workspace whenever the * {@link #workspacePanel} option changes. * <p>/*from w w w . j a v a 2s.co m*/ * This is so to maintain namespaces in synch with workspace while the resource/publish split is * not finalized, as per GEOS-3149. * </p> * <p> * Removing this method and the call to it on * {@link #getInputComponent(String, IModel, ParamInfo)} is all that's needed to let the * namespace be selectable independently of the workspace once the resource/publish split is * done. * </p> */ private void makeNamespaceSyncUpWithWorkspace(final Form paramsForm) { // do not allow the namespace choice to be manually changed final DropDownChoice wsDropDown = (DropDownChoice) workspacePanel.getFormComponent(); // add an ajax onchange behaviour that keeps ws and ns in synch wsDropDown.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; private NamespaceParamModel namespaceModel; private NamespacePanel namespacePanel; private boolean namespaceLookupOccurred; @Override protected void onUpdate(AjaxRequestTarget target) { // see if the namespace param is tied to a NamespacePanel and save it if (!namespaceLookupOccurred) { // search for the panel Component paramsPanel = AbstractDataAccessPage.this.get("dataStoreForm:parametersPanel"); namespacePanel = findNamespacePanel((MarkupContainer) paramsPanel); // if the panel is not there search for the parameter and build a model around it if (namespacePanel == null) { final IModel model = paramsForm.getModel(); final DataStoreInfo info = (DataStoreInfo) model.getObject(); final Catalog catalog = getCatalog(); final ResourcePool resourcePool = catalog.getResourcePool(); DataAccessFactory dsFactory; try { dsFactory = resourcePool.getDataStoreFactory(info); } catch (IOException e) { throw new RuntimeException(e); } final Param[] dsParams = dsFactory.getParametersInfo(); for (Param p : dsParams) { if ("namespace".equals(p.getName())) { final IModel paramsModel = new PropertyModel(model, "connectionParameters"); namespaceModel = new NamespaceParamModel(paramsModel, "namespace"); break; } } } namespaceLookupOccurred = true; } // get the namespace WorkspaceInfo ws = (WorkspaceInfo) wsDropDown.getModelObject(); String prefix = ws.getName(); NamespaceInfo namespaceInfo = getCatalog().getNamespaceByPrefix(prefix); if (namespacePanel != null) { // update the GUI namespacePanel.setDefaultModelObject(namespaceInfo); target.addComponent(namespacePanel.getFormComponent()); } else if (namespaceModel != null) { // update the model directly namespaceModel.setObject(namespaceInfo); // target.addComponent(AbstractDataAccessPage.this); } } }); }
From source file:org.geoserver.web.data.store.AbstractWMSStorePage.java
License:Open Source License
void initUI(final WMSStoreInfo store) { IModel model = new Model(store); add(dialog = new GeoServerDialog("dialog")); // build the form form = new Form("form", model); add(form);/*from www . ja va2s . c om*/ // name PropertyModel nameModel = new PropertyModel(model, "name"); final TextParamPanel namePanel = new TextParamPanel("namePanel", nameModel, new ResourceModel("AbstractWMSStorePage.dataSrcName", "Data Source Name"), true); form.add(namePanel); // description and enabled form.add(new TextParamPanel("descriptionPanel", new PropertyModel(model, "description"), new ResourceModel("AbstractWMSStorePage.description", "Description"), false)); form.add(new CheckBoxParamPanel("enabledPanel", new PropertyModel(model, "enabled"), new ResourceModel("enabled", "Enabled"))); // a custom converter will turn this into a namespace url workspacePanel = new WorkspacePanel("workspacePanel", new PropertyModel(model, "workspace"), new ResourceModel("workspace", "Workspace"), true); form.add(workspacePanel); capabilitiesURL = new TextParamPanel("capabilitiesURL", new PropertyModel(model, "capabilitiesURL"), new ParamResourceModel("capabilitiesURL", AbstractWMSStorePage.this), true); form.add(capabilitiesURL); // user name PropertyModel userModel = new PropertyModel(model, "username"); usernamePanel = new TextParamPanel("userNamePanel", userModel, new ResourceModel("AbstractWMSStorePage.userName"), false); form.add(usernamePanel); // password PropertyModel passwordModel = new PropertyModel(model, "password"); form.add(password = new PasswordParamPanel("passwordPanel", passwordModel, new ResourceModel("AbstractWMSStorePage.password"), false)); // max concurrent connections final PropertyModel<Boolean> useHttpConnectionPoolModel = new PropertyModel<Boolean>(model, "useConnectionPooling"); CheckBoxParamPanel useConnectionPooling = new CheckBoxParamPanel("useConnectionPoolingPanel", useHttpConnectionPoolModel, new ResourceModel("AbstractWMSStorePage.useHttpConnectionPooling")); form.add(useConnectionPooling); PropertyModel<String> connectionsModel = new PropertyModel<String>(model, "maxConnections"); final TextParamPanel maxConnections = new TextParamPanel("maxConnectionsPanel", connectionsModel, new ResourceModel("AbstractWMSStorePage.maxConnections"), true, new RangeValidator<Integer>(1, 128)); maxConnections.setOutputMarkupId(true); maxConnections.setEnabled(useHttpConnectionPoolModel.getObject()); form.add(maxConnections); useConnectionPooling.getFormComponent().add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { boolean enabled = useHttpConnectionPoolModel.getObject(); maxConnections.setEnabled(enabled); target.addComponent(maxConnections); } }); // connect timeout PropertyModel<Integer> connectTimeoutModel = new PropertyModel<Integer>(model, "connectTimeout"); form.add(new TextParamPanel("connectTimeoutPanel", connectTimeoutModel, new ResourceModel("AbstractWMSStorePage.connectTimeout"), true, new RangeValidator<Integer>(1, 240))); // read timeout PropertyModel<Integer> readTimeoutModel = new PropertyModel<Integer>(model, "readTimeout"); form.add(new TextParamPanel("readTimeoutPanel", readTimeoutModel, new ResourceModel("AbstractWMSStorePage.readTimeout"), true, new RangeValidator<Integer>(1, 360))); // cancel/submit buttons form.add(new BookmarkablePageLink("cancel", StorePage.class)); form.add(saveLink()); form.setDefaultButton(saveLink()); // feedback panel for error messages form.add(new FeedbackPanel("feedback")); StoreNameValidator storeNameValidator = new StoreNameValidator(workspacePanel.getFormComponent(), namePanel.getFormComponent(), store.getId()); form.add(storeNameValidator); }
From source file:org.geoserver.web.data.store.AbstractWMTSStorePage.java
License:Open Source License
void initUI(final WMTSStoreInfo store) { IModel model = new Model(store); add(dialog = new GeoServerDialog("dialog")); // build the form form = new Form("form", model); add(form);//from www . ja va 2 s . c o m // name PropertyModel nameModel = new PropertyModel(model, "name"); final TextParamPanel namePanel = new TextParamPanel("namePanel", nameModel, new ResourceModel("AbstractWMTSStorePage.dataSrcName", "Data Source Name"), true); form.add(namePanel); // description and enabled form.add(new TextParamPanel("descriptionPanel", new PropertyModel(model, "description"), new ResourceModel("AbstractWMTSStorePage.description", "Description"), false)); form.add(new CheckBoxParamPanel("enabledPanel", new PropertyModel(model, "enabled"), new ResourceModel("enabled", "Enabled"))); // a custom converter will turn this into a namespace url workspacePanel = new WorkspacePanel("workspacePanel", new PropertyModel(model, "workspace"), new ResourceModel("workspace", "Workspace"), true); form.add(workspacePanel); capabilitiesURL = new TextParamPanel("capabilitiesURL", new PropertyModel(model, "capabilitiesURL"), new ParamResourceModel("capabilitiesURL", AbstractWMTSStorePage.this), true); form.add(capabilitiesURL); // user name PropertyModel userModel = new PropertyModel(model, "username"); usernamePanel = new TextParamPanel("userNamePanel", userModel, new ResourceModel("AbstractWMTSStorePage.userName"), false); form.add(usernamePanel); // password PropertyModel passwordModel = new PropertyModel(model, "password"); form.add(password = new PasswordParamPanel("passwordPanel", passwordModel, new ResourceModel("AbstractWMTSStorePage.password"), false)); // http header PropertyModel headerNameModel = new PropertyModel(model, "headerName"); headerNamePanel = new TextParamPanel("headerNamePanel", headerNameModel, new ResourceModel("AbstractWMTSStorePage.headerName"), false); form.add(headerNamePanel); PropertyModel headerValueModel = new PropertyModel(model, "headerValue"); headerValuePanel = new TextParamPanel("headerValuePanel", headerValueModel, new ResourceModel("AbstractWMTSStorePage.headerValue"), false); form.add(headerValuePanel); // max concurrent connections final PropertyModel<Boolean> useHttpConnectionPoolModel = new PropertyModel<Boolean>(model, "useConnectionPooling"); CheckBoxParamPanel useConnectionPooling = new CheckBoxParamPanel("useConnectionPoolingPanel", useHttpConnectionPoolModel, new ResourceModel("AbstractWMTSStorePage.useHttpConnectionPooling")); form.add(useConnectionPooling); PropertyModel<String> connectionsModel = new PropertyModel<String>(model, "maxConnections"); final TextParamPanel maxConnections = new TextParamPanel("maxConnectionsPanel", connectionsModel, new ResourceModel("AbstractWMTSStorePage.maxConnections"), true, new RangeValidator<Integer>(1, 128)); maxConnections.setOutputMarkupId(true); maxConnections.setEnabled(useHttpConnectionPoolModel.getObject()); form.add(maxConnections); useConnectionPooling.getFormComponent().add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { boolean enabled = useHttpConnectionPoolModel.getObject(); maxConnections.setEnabled(enabled); target.add(maxConnections); } }); // connect timeout PropertyModel<Integer> connectTimeoutModel = new PropertyModel<Integer>(model, "connectTimeout"); form.add(new TextParamPanel("connectTimeoutPanel", connectTimeoutModel, new ResourceModel("AbstractWMTSStorePage.connectTimeout"), true, new RangeValidator<Integer>(1, 240))); // read timeout PropertyModel<Integer> readTimeoutModel = new PropertyModel<Integer>(model, "readTimeout"); form.add(new TextParamPanel("readTimeoutPanel", readTimeoutModel, new ResourceModel("AbstractWMTSStorePage.readTimeout"), true, new RangeValidator<Integer>(1, 360))); // cancel/submit buttons form.add(new BookmarkablePageLink("cancel", StorePage.class)); form.add(saveLink()); form.setDefaultButton(saveLink()); // feedback panel for error messages form.add(new FeedbackPanel("feedback")); StoreNameValidator storeNameValidator = new StoreNameValidator(workspacePanel.getFormComponent(), namePanel.getFormComponent(), store.getId()); form.add(storeNameValidator); }
From source file:org.geoserver.web.data.store.arcsde.ArcSDECoverageStoreEditPanel.java
License:Open Source License
private void addConnectionPrototypePanel(final CoverageStoreInfo storeInfo) { final String resourceKey = RESOURCE_KEY_PREFIX + ".prototype"; Label label = new Label("prototypeLabel", new ResourceModel(resourceKey)); final String title = String.valueOf(new ResourceModel(resourceKey + ".title").getObject()); final SimpleAttributeModifier titleSetter = new SimpleAttributeModifier("title", title); label.add(titleSetter);//from w ww . java 2 s . c om add(label); final DropDownChoice existingArcSDECoverages; existingArcSDECoverages = new DropDownChoice("connectionPrototype", new Model(), new ArcSDEStoreListModel(), new ArcSDEStoreListChoiceRenderer()); existingArcSDECoverages.add(titleSetter); add(existingArcSDECoverages); existingArcSDECoverages.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { final String storeId = existingArcSDECoverages.getValue(); final List<StoreInfo> choices = existingArcSDECoverages.getChoices(); for (StoreInfo store : choices) { if (store.getId().equals(storeId)) { Map<String, String> connParams = parseConnectionParameters(store); server.setModelObject(connParams.get(SERVER_NAME_PARAM_NAME)); port.setModelObject(connParams.get(PORT_NUMBER_PARAM_NAME)); instance.setModelObject(connParams.get(INSTANCE_NAME_PARAM_NAME)); user.setModelObject(connParams.get(USER_NAME_PARAM_NAME)); password.setModelObject(connParams.get(PASSWORD_PARAM_NAME)); target.addComponent(server); target.addComponent(port); target.addComponent(instance); target.addComponent(user); target.addComponent(password); break; } } } }); }
From source file:org.geoserver.web.translator.view.NewTranslationPage.java
License:Open Source License
private Component newLanguageChoice() { // GeoServerDialog dialog = new GeoServerDialog("dialog"); // add(dialog); // return new NewLanguageLink("newLanguage", dialog, translateForm.getModel()); IModel userInterfaceLocaleModel = new Model(getLocale()); IModel selectedLocaleModel = new Model(getLocale()); IModel choices = new NonTranslatedLocalesDetachableModel(); final LocaleDropDown localeDropDown = new LocaleDropDown("newTranslationLanguage", userInterfaceLocaleModel, selectedLocaleModel, choices); localeDropDown.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override/*from www .j ava 2s. com*/ protected void onUpdate(final AjaxRequestTarget target) { Locale newTranslation = (Locale) newLanguageChoice.getModelObject(); localeInput.setValue(newTranslation); target.addComponent(localeInput); } }); // localeDropDown.add(new AjaxFormSubmitBehavior(newTranslationForm, "onchange") { // private static final long serialVersionUID = 1L; // // @Override // protected void onSubmit(final AjaxRequestTarget target) { // } // // @Override // protected void onError(AjaxRequestTarget arg0) { // // TODO Auto-generated method stub // // } // }); return localeDropDown; }
From source file:org.geoserver.wms.web.publish.WMSLayerConfig.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" }) public WMSLayerConfig(String id, IModel layerModel) { super(id, layerModel); add(new CheckBox("queryableEnabled", new PropertyModel(layerModel, "queryable"))); add(new CheckBox("opaqueEnabled", new PropertyModel(layerModel, "opaque"))); // styles block container WebMarkupContainer styleContainer = new WebMarkupContainer("styles"); add(styleContainer);//from w ww .j av a 2 s .c om ResourceInfo resource = ((LayerInfo) layerModel.getObject()).getResource(); styleContainer.setVisible(resource instanceof CoverageInfo || resource instanceof FeatureTypeInfo); // default style chooser. A default style is required StylesModel styles = new StylesModel(); final PropertyModel defaultStyleModel = new PropertyModel(layerModel, "defaultStyle"); final DropDownChoice defaultStyle = new DropDownChoice("defaultStyle", defaultStyleModel, styles, new StyleChoiceRenderer()); defaultStyle.setRequired(true); styleContainer.add(defaultStyle); final Image defStyleImg = new Image("defaultStyleLegendGraphic"); defStyleImg.setOutputMarkupId(true); styleContainer.add(defStyleImg); // the wms url is build without qualification to allow usage of global styles, // the style name and layer name will be ws qualified instead String wmsURL = getRequest().getRelativePathPrefixToContextRoot(); wmsURL += wmsURL.endsWith("/") ? "wms?" : "/wms?"; final LegendGraphicAjaxUpdater defaultStyleUpdater; defaultStyleUpdater = new LegendGraphicAjaxUpdater(wmsURL, defStyleImg, defaultStyleModel); defaultStyle.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { defaultStyleUpdater.updateStyleImage(target); } }); // build a palette with no reordering allowed, since order doesn't affect anything IModel stylesModel = LiveCollectionModel.set(new PropertyModel(layerModel, "styles")); Palette extraStyles = new Palette("extraStyles", stylesModel, styles, new StyleNameRenderer(), 10, false) { /** * Override otherwise the header is not i18n'ized */ @Override public Component newSelectedHeader(final String componentId) { return new Label(componentId, new ResourceModel("ExtraStylesPalette.selectedHeader")); } /** * Override otherwise the header is not i18n'ized */ @Override public Component newAvailableHeader(final String componentId) { return new Label(componentId, new ResourceModel("ExtraStylesPalette.availableHeader")); } }; styleContainer.add(extraStyles); TextField renderingBuffer = new TextField("renderingBuffer", new MapModel(new PropertyModel(layerModel, "metadata"), LayerInfo.BUFFER), Integer.class); renderingBuffer.add(NumberValidator.minimum(0)); styleContainer.add(renderingBuffer); add(new TextField("wmsPath", new PropertyModel(layerModel, "path"))); // authority URLs and identifiers for this layer LayerAuthoritiesAndIdentifiersPanel authAndIds; authAndIds = new LayerAuthoritiesAndIdentifiersPanel("authoritiesAndIds", false, layerModel); add(authAndIds); }
From source file:org.headsupdev.agile.web.components.configuration.SQLURLField.java
License:Open Source License
private void layout() { final SQLURLField self = this; final TextField urlField = new TextField<String>("url", new PropertyModel<String>(this, "url") { public void setObject(String o) { super.setObject(o); updateModelObject();//from w ww. jav a 2 s . co m } }); urlField.setMarkupId("sqlurl").setOutputMarkupId(true); final DropDownChoice types = new DropDownChoice<String>("type", new PropertyModel<String>(this, "type"), DatabaseRegistry.getTypes()); types.add(new OnChangeAjaxBehavior() { protected void onUpdate(final AjaxRequestTarget target) { String newType = (String) types.getModelObject(); url = DatabaseRegistry.getDefaultUrl(newType); target.addComponent(urlField); updateModelObject(); target.appendJavascript("document.getElementById('sqlurl').onblur()"); } }); add(types); urlField.add(new AjaxFormComponentUpdatingBehavior("onblur") { protected void onUpdate(AjaxRequestTarget target) { self.onUpdate(target); } }); add(urlField); }