List of usage examples for org.apache.wicket.markup.html.form SubmitLink SubmitLink
public SubmitLink(String id)
From source file:org.brixcms.plugin.site.resource.managers.text.EditTextResourcePanel.java
License:Apache License
public EditTextResourcePanel(String id, IModel<BrixNode> node) { super(id, node); add(new FeedbackPanel("feedback")); Form<?> form = new Form<Void>("form"); add(form);//w w w .j a v a2s . c o m final ModelBuffer model = new ModelBuffer(node); form.add(new TextResourceEditor("editor", model)); form.add(new SubmitLink("save") { @Override public void onSubmit() { model.apply(); getNode().save(); // done getSession().info(getString("saved")); done(); } }); form.add(new Link<Void>("cancel") { @Override public void onClick() { getSession().info(getString("cancelled")); done(); } }); }
From source file:org.brixcms.plugin.snapshot.ManageSnapshotsPanel.java
License:Apache License
public ManageSnapshotsPanel(String id, final IModel<Workspace> model) { super(id, model); add(new FeedbackPanel("feedback")); IModel<List<Workspace>> snapshotsModel = new LoadableDetachableModel<List<Workspace>>() { @Override// w w w . ja v a2 s . c om protected List<Workspace> load() { List<Workspace> list = SnapshotPlugin.get().getSnapshotsForWorkspace(getModelObject()); return getBrix().filterVisibleWorkspaces(list, Context.ADMINISTRATION); } }; add(new ListView<Workspace>("snapshots", snapshotsModel) { @Override protected IModel<Workspace> getListItemModel(IModel<? extends List<Workspace>> listViewModel, int index) { return new WorkspaceModel(listViewModel.getObject().get(index)); } @Override protected void populateItem(final ListItem<Workspace> item) { Workspace workspace = item.getModelObject(); final String name = SnapshotPlugin.get().getUserVisibleName(workspace, true); final String comment = SnapshotPlugin.get().getComment(workspace); Link<Object> link = new Link<Object>("browse") { @Override public void onClick() { Workspace workspace = item.getModelObject(); model.setObject(workspace); } }; item.add(link); Link restoreLink = new Link<Void>("restore") { @Override public void onClick() { Workspace target = ManageSnapshotsPanel.this.getModelObject(); SnapshotPlugin.get().restoreSnapshot(item.getModelObject(), target); getSession().info(ManageSnapshotsPanel.this.getString("restoreSuccessful")); } /** * Take care that restoring is only allowed in case the workspaces aren't the same */ @Override public boolean isEnabled() { if (item.getModelObject().getId() .equals(ManageSnapshotsPanel.this.getModelObject().getId())) { return false; } return true; } @Override public boolean isVisible() { Workspace target = ManageSnapshotsPanel.this.getModelObject(); Action action = new RestoreSnapshotAction(Context.ADMINISTRATION, item.getModelObject(), target); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }; /* * in case the link is enabled, make sure it is intended... */ if (restoreLink.isEnabled()) { restoreLink.add(new SimpleAttributeModifier("onClick", "return confirm('" + getLocalizer().getString("restoreOnClick", this) + "')")); } item.add(restoreLink); item.add(new Link<Void>("delete") { @Override public void onClick() { Workspace snapshot = item.getModelObject(); snapshot.delete(); } @Override public boolean isVisible() { Action action = new DeleteSnapshotAction(Context.ADMINISTRATION, item.getModelObject()); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }); item.add(new Label("label", name)); item.add(new Label("commentlabel", comment)); } }); add(new Link<Object>("downloadWorkspace") { @Override public void onClick() { getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() { public void detach(IRequestCycle requestCycle) { } public void respond(IRequestCycle requestCycle) { WebResponse resp = (WebResponse) requestCycle.getResponse(); resp.setAttachmentHeader("workspace.xml"); String id = ManageSnapshotsPanel.this.getModelObject().getId(); Brix brix = getBrix(); JcrSession session = brix.getCurrentSession(id); HttpServletResponse containerResponse = (HttpServletResponse) resp.getContainerResponse(); ServletOutputStream containerResponseOutputStream = null; try { containerResponseOutputStream = containerResponse.getOutputStream(); } catch (IOException e) { throw new RuntimeException(e); } session.exportSystemView(brix.getRootPath(), containerResponseOutputStream, false, false); } }); } }); /** * Form to create a new Snapshot and put any comment to it */ Form<Object> commentForm = new Form<Object>("commentForm") { @Override public boolean isVisible() { Workspace target = ManageSnapshotsPanel.this.getModelObject(); Action action = new CreateSnapshotAction(Context.ADMINISTRATION, target); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }; final TextArea<String> area = new TextArea<String>("area", new Model<String>()); commentForm.add(area); commentForm.add(new SubmitLink("createSnapshot") { /** * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit() */ @Override public void onSubmit() { String comment = area.getModelObject(); SnapshotPlugin.get().createSnapshot(ManageSnapshotsPanel.this.getModelObject(), comment); area.setModelObject(""); } }); add(commentForm); Form<Object> uploadForm = new Form<Object>("uploadForm") { @Override public boolean isVisible() { Workspace target = ManageSnapshotsPanel.this.getModelObject(); Action action = new RestoreSnapshotAction(Context.ADMINISTRATION, target); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }; final FileUploadField upload = new FileUploadField("upload", new Model<FileUpload>()); uploadForm.add(upload); uploadForm.add(new SubmitLink("submit") { @Override public void onSubmit() { List<FileUpload> uploadList = upload.getModelObject(); if (uploadList != null) { for (FileUpload u : uploadList) { try { InputStream s = u.getInputStream(); String id = ManageSnapshotsPanel.this.getModelObject().getId(); Brix brix = getBrix(); JcrSession session = brix.getCurrentSession(id); if (session.itemExists(brix.getRootPath())) { session.getItem(brix.getRootPath()).remove(); } session.importXML("/", s, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING); session.save(); brix.initWorkspace(ManageSnapshotsPanel.this.getModelObject(), session); getSession().info(ManageSnapshotsPanel.this.getString("restoreSuccessful")); } catch (IOException e) { throw new BrixException(e); } } } } }); add(uploadForm); }
From source file:org.cast.cwm.admin.EditUserPanel.java
License:Open Source License
/** * Returns a link that will be used to submit the form. * This can be overridden to use a button or other component. * //from ww w. j ava 2 s .co m * TODO: This "operation" thing is hidden and can cause confusion when subclasses * override this method. Should just expect a single Component, which may be a panel/fragment. * * @param id The wicket ID for the component * @return a Component, or null if there should be none. */ protected Component getSubmitComponent(String id) { SubmitLink link = new SubmitLink(id); link.add(new Label("operation", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return userForm.getModelObject().isTransient() ? "Create User" : "Update User"; } })); return link; }
From source file:org.cast.isi.component.QuickFlipForm.java
License:Open Source License
public QuickFlipForm(String id, boolean addLabel, Integer currentPage) { super(id);/*from w w w.j av a 2s . c o m*/ Model<String> numberModel; if (currentPage != null) numberModel = new Model<String>(currentPage.toString()); else numberModel = new Model<String>(""); TextField<String> numberField = new TextField<String>("numberField", numberModel); add(numberField); if (addLabel) { FormComponentLabel numberFieldLabel = new FormComponentLabel("numberFieldLabel", numberField); add(numberFieldLabel); } add(new SubmitLink("goLink")); }
From source file:org.geoserver.backuprestore.web.BackupRestorePage.java
License:Open Source License
void initComponents(final IModel<T> model) { add(new Label("id", new PropertyModel(model, "id"))); add(new Label("clazz", new Model( this.clazz.getSimpleName().substring(0, this.clazz.getSimpleName().indexOf("Execution"))))); BackupRestoreExecutionsProvider provider = new BackupRestoreExecutionsProvider(getType()) { @Override/* ww w. j a v a2 s .c om*/ protected List<Property<AbstractExecutionAdapter>> getProperties() { return Arrays.asList(ID, STATE, STARTED, PROGRESS, ARCHIVEFILE, OPTIONS); } @Override protected List<T> getItems() { return Collections.singletonList(model.getObject()); } }; final BackupRestoreExecutionsTable headerTable = new BackupRestoreExecutionsTable("header", provider, getType()); headerTable.setOutputMarkupId(true); headerTable.setFilterable(false); headerTable.setPageable(false); add(headerTable); final T bkp = model.getObject(); boolean selectable = bkp.getStatus() != BatchStatus.COMPLETED; add(new Icon("icon", COMPRESS_ICON)); add(new Label("title", new DataTitleModel(bkp)) .add(new AttributeModifier("title", new DataTitleModel(bkp, false)))); @SuppressWarnings("rawtypes") Form<?> form = new Form("form"); add(form); try { if (params != null && params.getNamedKeys().contains(DETAILS_LEVEL)) { if (params.get(DETAILS_LEVEL).toInt() > 0) { expand = params.get(DETAILS_LEVEL).toInt(); } } } catch (Exception e) { LOGGER.log(Level.WARNING, "Error parsing the 'details level' parameter: ", params.get(DETAILS_LEVEL).toString()); } form.add(new SubmitLink("refresh") { @Override public void onSubmit() { setResponsePage(BackupRestorePage.class, new PageParameters().add("id", params.get("id").toLong()) .add("clazz", getType().getSimpleName()).add(DETAILS_LEVEL, expand)); } }); NumberTextField<Integer> expand = new NumberTextField<Integer>("expand", new PropertyModel<Integer>(this, "expand")); expand.add(RangeValidator.minimum(0)); form.add(expand); TextArea<String> details = new TextArea<String>("details", new BKErrorDetailsModel(bkp)); details.setOutputMarkupId(true); details.setMarkupId("details"); add(details); String location = bkp.getArchiveFile().path(); if (location == null) { location = getGeoServerApplication().getGeoServer().getLogging().getLocation(); } backupFile = new File(location); if (!backupFile.isAbsolute()) { // locate the geoserver.log file GeoServerDataDirectory dd = getGeoServerApplication().getBeanOfType(GeoServerDataDirectory.class); backupFile = dd.get(Paths.convert(backupFile.getPath())).file(); } if (!backupFile.exists()) { error("Could not find the Backup Archive file: " + backupFile.getAbsolutePath()); } /*** * DOWNLOAD LINK */ final Link<Object> downLoadLink = new Link<Object>("download") { @Override public void onClick() { IResourceStream stream = new FileResourceStream(backupFile) { public String getContentType() { return "application/zip"; } }; ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(stream, backupFile.getName()); handler.setContentDisposition(ContentDisposition.ATTACHMENT); RequestCycle.get().scheduleRequestHandlerAfterCurrent(handler); } }; add(downLoadLink); /*** * PAUSE LINK */ final AjaxLink pauseLink = new AjaxLink("pause") { @Override protected void disableLink(ComponentTag tag) { super.disableLink(tag); tag.setName("a"); tag.addBehavior(AttributeModifier.replace("class", "disabled")); } @Override public void onClick(AjaxRequestTarget target) { AbstractExecutionAdapter bkp = model.getObject(); if (bkp.getStatus() == BatchStatus.STOPPED) { setLinkEnabled((AjaxLink) downLoadLink.getParent().get("pause"), false, target); } else { try { backupFacade().stopExecution(bkp.getId()); setResponsePage(BackupRestoreDataPage.class); } catch (NoSuchJobExecutionException | JobExecutionNotRunningException e) { LOGGER.log(Level.WARNING, "", e); getSession().error(e); setResponsePage(BackupRestoreDataPage.class); } } } }; pauseLink.setEnabled(doSelectReady(bkp) && bkp.getStatus() != BatchStatus.STOPPED); add(pauseLink); /*** * RESUME LINK */ final AjaxLink resumeLink = new AjaxLink("resume") { @Override protected void disableLink(ComponentTag tag) { super.disableLink(tag); tag.setName("a"); tag.addBehavior(AttributeModifier.replace("class", "disabled")); } @Override public void onClick(AjaxRequestTarget target) { AbstractExecutionAdapter bkp = model.getObject(); if (bkp.getStatus() != BatchStatus.STOPPED) { setLinkEnabled((AjaxLink) downLoadLink.getParent().get("pause"), false, target); } else { try { Long id = backupFacade().restartExecution(bkp.getId()); PageParameters pp = new PageParameters(); pp.add("id", id); if (bkp instanceof BackupExecutionAdapter) { pp.add("clazz", BackupExecutionAdapter.class.getSimpleName()); } else if (bkp instanceof RestoreExecutionAdapter) { pp.add("clazz", RestoreExecutionAdapter.class.getSimpleName()); } setResponsePage(BackupRestorePage.class, pp); } catch (NoSuchJobExecutionException | JobInstanceAlreadyCompleteException | NoSuchJobException | JobRestartException | JobParametersInvalidException e) { LOGGER.log(Level.WARNING, "", e); getSession().error(e); setResponsePage(BackupRestoreDataPage.class); } } } }; resumeLink.setEnabled(bkp.getStatus() == BatchStatus.STOPPED); add(resumeLink); /*** * ABANDON LINK */ final AjaxLink cancelLink = new AjaxLink("cancel") { @Override protected void disableLink(ComponentTag tag) { super.disableLink(tag); tag.setName("a"); tag.addBehavior(AttributeModifier.replace("class", "disabled")); } @Override public void onClick(AjaxRequestTarget target) { AbstractExecutionAdapter bkp = model.getObject(); if (!doSelectReady(bkp)) { setLinkEnabled((AjaxLink) downLoadLink.getParent().get("cancel"), false, target); } else { try { backupFacade().abandonExecution(bkp.getId()); PageParameters pp = new PageParameters(); pp.add("id", bkp.getId()); if (bkp instanceof BackupExecutionAdapter) { pp.add("clazz", BackupExecutionAdapter.class.getSimpleName()); } else if (bkp instanceof RestoreExecutionAdapter) { pp.add("clazz", RestoreExecutionAdapter.class.getSimpleName()); } setResponsePage(BackupRestorePage.class, pp); } catch (NoSuchJobExecutionException | JobExecutionAlreadyRunningException e) { error(e); LOGGER.log(Level.WARNING, "", e); } } } }; cancelLink.setEnabled(doSelectReady(bkp)); add(cancelLink); /*** * DONE LINK */ final AjaxLink doneLink = new AjaxLink("done") { @Override protected void disableLink(ComponentTag tag) { super.disableLink(tag); tag.setName("a"); tag.addBehavior(AttributeModifier.replace("class", "disabled")); } @Override public void onClick(AjaxRequestTarget target) { setResponsePage(BackupRestoreDataPage.class); return; } }; add(doneLink); /** * FINALIZE */ add(dialog = new GeoServerDialog("dialog")); }
From source file:org.geoserver.backuprestore.web.ResourceFilePanel.java
License:Open Source License
SubmitLink submitLink() { return new SubmitLink("submit") { @Override public void onSubmit() { } }; }
From source file:org.geoserver.geofence.web.GeofenceAdminRulePage.java
License:Open Source License
public GeofenceAdminRulePage(final ShortAdminRule rule, final GeofenceAdminRulesModel rules) { final Form<ShortAdminRule> form = new Form<>("form", new CompoundPropertyModel<ShortAdminRule>(rule)); add(form);/*ww w .j ava 2 s . c om*/ form.add(new TextField<Integer>("priority").setRequired(true)); form.add(roleChoice = new DropDownChoice<>("roleName", getRoleNames())); roleChoice.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -8846522500239968004L; @Override protected void onUpdate(AjaxRequestTarget target) { userChoice.setChoices(getUserNames(roleChoice.getConvertedInput())); form.getModelObject().setUserName(null); userChoice.modelChanged(); target.add(userChoice); } }); roleChoice.setNullValid(true); form.add(userChoice = new DropDownChoice<>("userName", getUserNames(rule.getRoleName()))); userChoice.setOutputMarkupId(true); userChoice.setNullValid(true); form.add(workspaceChoice = new DropDownChoice<>("workspace", getWorkspaceNames())); workspaceChoice.setNullValid(true); form.add(grantTypeChoice = new DropDownChoice<>("access", Arrays.asList(AdminGrantType.values()), new AdminGrantTypeRenderer())); grantTypeChoice.setRequired(true); form.add(new SubmitLink("save") { private static final long serialVersionUID = -6524151967046867889L; @Override public void onSubmit() { ShortAdminRule rule = (ShortAdminRule) getForm().getModelObject(); try { rules.save(rule); doReturn(GeofenceServerAdminPage.class); } catch (DuplicateKeyException e) { error(new ResourceModel("GeofenceRulePage.duplicate").getObject()); } catch (Exception exception) { error(exception); } } }); form.add(new BookmarkablePageLink<ShortAdminRule>("cancel", GeofenceServerPage.class)); }
From source file:org.geoserver.geofence.web.GeofenceRulePage.java
License:Open Source License
public GeofenceRulePage(final ShortRule rule, final GeofenceRulesModel rules) { // build the form final Form<ShortRule> form = new Form<ShortRule>("form", new CompoundPropertyModel<ShortRule>(rule)); add(form);/*from w w w . j a v a2 s .com*/ form.add(new TextField<Integer>("priority").setRequired(true)); form.add(roleChoice = new DropDownChoice<String>("roleName", getRoleNames())); roleChoice.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -2880886409750911044L; @Override protected void onUpdate(AjaxRequestTarget target) { userChoice.setChoices(getUserNames(roleChoice.getConvertedInput())); ((ShortRule) form.getModelObject()).setUserName(null); userChoice.modelChanged(); target.addComponent(userChoice); } }); roleChoice.setNullValid(true); form.add(userChoice = new DropDownChoice<String>("userName", getUserNames(rule.getRoleName()))); userChoice.setOutputMarkupId(true); userChoice.setNullValid(true); form.add(serviceChoice = new DropDownChoice<String>("service", getServiceNames())); serviceChoice.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5925784823433092831L; @Override protected void onUpdate(AjaxRequestTarget target) { requestChoice.setChoices(getOperationNames(serviceChoice.getConvertedInput())); ((ShortRule) form.getModelObject()).setRequest(null); requestChoice.modelChanged(); target.addComponent(requestChoice); } }); serviceChoice.setNullValid(true); form.add(requestChoice = new DropDownChoice<String>("request", getOperationNames(rule.getService()), new CaseConversionRenderer())); requestChoice.setOutputMarkupId(true); requestChoice.setNullValid(true); form.add(workspaceChoice = new DropDownChoice<String>("workspace", getWorkspaceNames())); workspaceChoice.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 732177308220189475L; @Override protected void onUpdate(AjaxRequestTarget target) { layerChoice.setChoices(getLayerNames(workspaceChoice.getConvertedInput())); ((ShortRule) form.getModelObject()).setLayer(null); layerChoice.modelChanged(); target.addComponent(layerChoice); } }); workspaceChoice.setNullValid(true); form.add(layerChoice = new DropDownChoice<String>("layer", getLayerNames(rule.getWorkspace()))); layerChoice.setOutputMarkupId(true); layerChoice.setNullValid(true); form.add(grantTypeChoice = new DropDownChoice<GrantType>("access", Arrays.asList(GrantType.values()), new GrantTypeRenderer())); grantTypeChoice.setRequired(true); // build the submit/cancel form.add(new SubmitLink("save") { private static final long serialVersionUID = 3735176778941168701L; @Override public void onSubmit() { ShortRule rule = (ShortRule) getForm().getModelObject(); try { rules.save(rule); doReturn(GeofenceServerPage.class); } catch (DuplicateKeyException e) { error(new ResourceModel("GeofenceRulePage.duplicate").getObject()); } catch (Exception e) { error(e); } } }); form.add(new BookmarkablePageLink<ShortRule>("cancel", GeofenceServerPage.class)); }
From source file:org.geoserver.importer.web.SpatialFilePanel.java
License:Open Source License
SubmitLink submitLink() { return new SubmitLink("submit") { @Override//from w ww . j a v a2 s . co m public void onSubmit() { // try { // // check there is not another store with the same name // WorkspaceInfo workspace = generalParams.getWorkpace(); // NamespaceInfo namespace = getCatalog() // .getNamespaceByPrefix(workspace.getName()); // StoreInfo oldStore = getCatalog().getStoreByName(workspace, generalParams.name, // StoreInfo.class); // if (oldStore != null) { // error(new ParamResourceModel("ImporterError.duplicateStore", // DirectoryPage.this, generalParams.name, workspace.getName()).getString()); // return; // } // // // build/reuse the store // String storeType = new ShapefileDataStoreFactory().getDisplayName(); // Map<String, Serializable> params = new HashMap<String, Serializable>(); // params.put(ShapefileDataStoreFactory.URLP.key, new File(directory).toURI() // .toURL().toString()); // params.put(ShapefileDataStoreFactory.NAMESPACEP.key, new URI(namespace.getURI()).toString()); // // DataStoreInfo si; // StoreInfo preExisting = getCatalog().getStoreByName(workspace, generalParams.name, // StoreInfo.class); // boolean storeNew = false; // if (preExisting != null) { // if (!(preExisting instanceof DataStoreInfo)) { // error(new ParamResourceModel("storeExistsNotVector", this, generalParams.name)); // return; // } // si = (DataStoreInfo) preExisting; // if (!si.getType().equals(storeType) // || !si.getConnectionParameters().equals(params)) { // error(new ParamResourceModel("storeExistsNotSame", this, generalParams.name)); // return; // } // // make sure it's enabled, we just verified the directory exists // si.setEnabled(true); // } else { // storeNew = true; // CatalogBuilder builder = new CatalogBuilder(getCatalog()); // builder.setWorkspace(workspace); // si = builder.buildDataStore(generalParams.name); // si.setDescription(generalParams.description); // si.getConnectionParameters().putAll(params); // si.setEnabled(true); // si.setType(storeType); // // getCatalog().add(si); // } // // // redirect to the layer chooser // PageParameters pp = new PageParameters(); // pp.put("store", si.getName()); // pp.put("workspace", workspace.getName()); // pp.put("storeNew", storeNew); // pp.put("workspaceNew", false); // setResponsePage(VectorLayerChooserPage.class, pp); // } catch (Exception e) { // LOGGER.log(Level.SEVERE, "Error while setting up mass import", e); // } } }; }
From source file:org.geoserver.params.extractor.web.ParamsExtractorConfigPage.java
License:Open Source License
public ParamsExtractorConfigPage() { setHeaderPanel(headerPanel());/*from w ww . j a v a2s. c om*/ add(rulesPanel = new GeoServerTablePanel<RuleModel>("rulesPanel", new RulesModel(), true) { @Override protected Component getComponentForProperty(String id, IModel<RuleModel> itemModel, GeoServerDataProvider.Property<RuleModel> property) { if (property == RulesModel.EDIT_BUTTON) { return new EditButtonPanel(id, itemModel.getObject()); } if (property == RulesModel.ACTIVATE_BUTTON) { return new ActivateButtonPanel(id, itemModel.getObject()); } return null; } }); rulesPanel.setOutputMarkupId(true); RuleTestModel ruleTestModel = new RuleTestModel(); Form<RuleTestModel> form = new Form<>("form", new CompoundPropertyModel<>(ruleTestModel)); add(form); TextArea<String> input = new TextArea<>("input", new PropertyModel<>(ruleTestModel, "input")); form.add(input); input.setDefaultModelObject( "/geoserver/tiger/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&CQL_FILTER=CFCC%3D%27H11%27"); TextArea<String> output = new TextArea<>("output", new PropertyModel<>(ruleTestModel, "output")); output.setEnabled(false); form.add(output); form.add(new SubmitLink("test") { @Override public void onSubmit() { if (rulesPanel.getSelection().isEmpty()) { output.setModelObject("NO RULES SELECTED !"); return; } String outputText; try { RuleTestModel ruleTestModel = (RuleTestModel) getForm().getModelObject(); String[] urlParts = ruleTestModel.getInput().split("\\?"); String requestUri = urlParts[0]; Optional<String> queryRequest = urlParts.length > 1 ? Optional.ofNullable(urlParts[1]) : Optional.empty(); UrlTransform urlTransform = new UrlTransform(requestUri, Utils.parseParameters(queryRequest)); rulesPanel.getSelection().stream().filter(rule -> !rule.isEchoOnly()).map(RuleModel::toRule) .forEach(rule -> rule.apply(urlTransform)); if (urlTransform.haveChanged()) { outputText = urlTransform.toString(); } else { outputText = "NO RULES APPLIED !"; } } catch (Exception exception) { outputText = "Exception: " + exception.getMessage(); } output.setModelObject(outputText); } }); }