List of usage examples for org.apache.wicket.util.string.interpolator MapVariableInterpolator interpolate
public static String interpolate(final String string, final Map<?, ?> variables)
String with the arguments defined in the given Map. From source file:com.doculibre.constellio.wicket.panels.admin.connector.ConnectorListPanel.java
License:Open Source License
@Override protected IModel getTitleModel() { return new LoadableDetachableModel() { @Override/* w w w . ja v a 2 s.co m*/ protected Object load() { AdminCollectionPanel collectionAdminPanel = (AdminCollectionPanel) findParent( AdminCollectionPanel.class); RecordCollection collection = collectionAdminPanel.getCollection(); Locale displayLocale = collection.getDisplayLocale(getLocale()); String title = MapVariableInterpolator.interpolate( getLocalizer().getString("panelTitle", ConnectorListPanel.this), new MicroMap("collectionName", collection.getTitle(displayLocale))); return title; } }; }
From source file:org.bindgen.wicket.phonebook.web.page.DeleteContactPage.java
License:Apache License
private void addConfimButton() { /*/*from ww w. ja va 2 s . c o m*/ * notice in mark-up this link is attached to <input type='button'/> * tag, the link is smart enough to know to generate an onclick instead * of href */ Link<String> confirmLink = new Link<String>("confirm") { private static final long serialVersionUID = 1L; @Override public void onClick() { final Contact deleted = getContact(); contactDao.delete(deleted.getId()); String msg = MapVariableInterpolator.interpolate(getLocalizer().getString("status.deleted", this), new MicroMap<String, String>("name", deleted.getFullName())); getSession().info(msg); setResponsePage(DeleteContactPage.this.backPage); } }; confirmLink.add(new AttributeModifier("value", true, new ResourceModel("confirm"))); add(confirmLink); }
From source file:org.bindgen.wicket.phonebook.web.page.DeleteContactPage.java
License:Apache License
private void addCancelButton() { Link<String> cancelLink = new Link<String>("cancel") { private static final long serialVersionUID = 1L; @Override//from w w w .j a va2s . c om public void onClick() { String msg = MapVariableInterpolator.interpolate(getLocalizer().getString("status.cancelled", this), new MicroMap<String, String>("name", getContact().getFullName())); getSession().info(msg); setResponsePage(DeleteContactPage.this.backPage); } }; cancelLink.add(new AttributeModifier("value", true, new ResourceModel("cancel"))); add(cancelLink); }
From source file:org.bindgen.wicket.phonebook.web.page.EditContactPage.java
License:Apache License
private void onSave() { contactDao.save(contact);/*from w ww. j a va 2 s . co m*/ String msg = MapVariableInterpolator.interpolate(getLocalizer().getString("status.save", this), new MicroMap<String, String>("name", contact.getFullName())); getSession().info(msg); setResponsePage(EditContactPage.this.backPage); }
From source file:org.cipango.ims.hss.web.adminuser.DeleteAdminUserPage.java
License:Apache License
@SuppressWarnings("unchecked") public DeleteAdminUserPage(PageParameters pageParameters) { super(pageParameters); final String key = pageParameters.getString("id"); AdminUser adminUser = _dao.findById(key); if (adminUser == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("name", key))); goToBackPage(AdminUserBrowserPage.class); return;//from w ww . j a v a2 s. c o m } add(new Label("delete.confirm", getString(getPrefix() + ".delete.confirm", new DaoDetachableModel(adminUser)))); /* * Use a form to hold the buttons, but set the default form processing * off as there's no point it trying to do anything, as all we're * interested in are the button clicks. */ Form form = new Form("confirmForm"); form.add(new Button("delete") { public void onSubmit() { AdminUser id = _dao.findById(key); _dao.delete(id); getSession().info(getString(getPrefix() + ".delete.done", new DaoDetachableModel(id))); goToBackPage(AdminUserBrowserPage.class); } }.setDefaultFormProcessing(false)); form.add(new Button("cancel") { public void onSubmit() { getSession().info(getString(getPrefix() + ".delete.canceled", new DaoDetachableModel(key))); goToBackPage(AdminUserBrowserPage.class); } }.setDefaultFormProcessing(false)); add(form); if (adminUser != null) setContextMenu(new ContextPanel(adminUser)); }
From source file:org.cipango.ims.hss.web.adminuser.EditAdminUserPage.java
License:Apache License
@SuppressWarnings("unchecked") public EditAdminUserPage(PageParameters pageParameters) { super(pageParameters); _key = pageParameters.getString("id"); AdminUser adminUser = null;//from w w w. j av a 2 s.c o m if (_key != null) { adminUser = _dao.findById(_key); if (adminUser == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("id", _key))); _key = null; } } IModel model = new DaoDetachableModel(adminUser); if (isAdding()) { _title = getString(getPrefix() + ".add.title"); } else { _title = getString(getPrefix() + ".edit.title", model); } Form form = new Form("form", new CompoundPropertyModel(model)); add(form); form.add(new Label("title", adminUser == null ? "" : adminUser.getLogin())); form.add(new RequiredTextField<String>("login", String.class)); final PasswordTextField password1 = new PasswordTextField("password1", new Model<String>()); form.add(password1); final PasswordTextField password2 = new PasswordTextField("password2", new Model<String>()); form.add(password2); if (isAdding()) form.add(new EqualPasswordInputValidator(password1, password2)); else { password1.setVisible(false); password2.setVisible(false); } form.add(new Button("submit") { @Override public void onSubmit() { try { AdminUser admin = (AdminUser) getForm().getModelObject(); if (isAdding()) { if (!Strings.isEmpty(password1.getModelObject()) && password1.getModelObject().equals(password2.getModelObject())) { _dao.save(admin); admin.setClearPassword(password1.getModelObject()); } else { getSession() .warn(getString("adminUser.error.passwordsDontMatch", getForm().getModel())); return; } } _dao.save(admin); getSession().info(getString("modification.success")); if (!admin.getLogin().equals(_key)) setResponsePage(EditAdminUserPage.class, new PageParameters("id=" + admin.getLogin())); } catch (Exception e) { getSession().error(getString(getPrefix() + ".error.duplicate", getForm().getModel())); } } }); form.add(new Button("cancel") { @Override public void onSubmit() { getSession().info(getString("modification.cancel")); goToBackPage(AdminUserBrowserPage.class); } }.setDefaultFormProcessing(false)); if (adminUser != null) setContextMenu(new ContextPanel(adminUser)); }
From source file:org.cipango.ims.hss.web.adminuser.SetPasswordPage.java
License:Apache License
@SuppressWarnings("unchecked") public SetPasswordPage(PageParameters pageParameters) { super(pageParameters); _key = pageParameters.getString("id"); AdminUser adminUser = null;/* w w w . java2 s . c o m*/ if (_key != null) { adminUser = _dao.findById(_key); if (adminUser == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("id", _key))); _key = null; } } IModel model = new DaoDetachableModel(adminUser); _title = getString(getPrefix() + ".setPassword.title", model); Form form = new Form("form", new CompoundPropertyModel(model)); add(form); form.add(new Label("title", adminUser == null ? "" : adminUser.getLogin())); final PasswordTextField password1 = new PasswordTextField("password1", new Model<String>()); form.add(password1); final PasswordTextField password2 = new PasswordTextField("password2", new Model<String>()); form.add(password2); form.add(new EqualPasswordInputValidator(password1, password2)); form.add(new Button("submit") { @Override public void onSubmit() { if (!Strings.isEmpty(password1.getModelObject()) && password1.getModelObject().equals(password2.getModelObject())) { AdminUser admin = (AdminUser) getForm().getModelObject(); admin.setClearPassword(password1.getModelObject()); _dao.save(admin); getSession().info(getString("adminUser.passwordUpdated", getForm().getModel())); setResponsePage(EditAdminUserPage.class, new PageParameters("id=" + admin.getLogin())); } else getSession().warn(getString("adminUser.error.passwordsDontMatch", getForm().getModel())); } }); form.add(new Button("cancel") { @Override public void onSubmit() { getSession().info(getString("modification.cancel")); AdminUser admin = (AdminUser) getForm().getModelObject(); setResponsePage(EditAdminUserPage.class, new PageParameters("id=" + admin.getLogin())); } }.setDefaultFormProcessing(false)); if (adminUser != null) setContextMenu(new ContextPanel(adminUser)); }
From source file:org.cipango.ims.hss.web.as.DeleteAsPage.java
License:Apache License
@SuppressWarnings("unchecked") public DeleteAsPage(PageParameters pageParameters) { super(pageParameters); final String key = pageParameters.getString("id"); ApplicationServer applicationServer = _dao.findById(key); if (applicationServer == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("name", key))); goToBackPage(AsBrowserPage.class); return;/*from www . j a v a 2 s. c o m*/ } add(new Label("delete.confirm", getString(getPrefix() + ".delete.confirm", new DaoDetachableModel(applicationServer)))); /* * Use a form to hold the buttons, but set the default form processing * off as there's no point it trying to do anything, as all we're * interested in are the button clicks. */ Form form = new Form("confirmForm"); form.add(new Button("delete") { public void onSubmit() { ApplicationServer id = _dao.findById(key); _dao.delete(id); getSession().info(getString(getPrefix() + ".delete.done", new DaoDetachableModel(id))); goToBackPage(AsBrowserPage.class); } }.setDefaultFormProcessing(false)); form.add(new Button("cancel") { public void onSubmit() { getSession().info(getString(getPrefix() + ".delete.canceled", new DaoDetachableModel(key))); goToBackPage(AsBrowserPage.class); } }.setDefaultFormProcessing(false)); add(form); if (applicationServer != null) setContextMenu(new ContextPanel(applicationServer)); }
From source file:org.cipango.ims.hss.web.as.EditAsPage.java
License:Apache License
@SuppressWarnings("unchecked") public EditAsPage(PageParameters pageParameters) { super(pageParameters); _key = pageParameters.getString("id"); ApplicationServer applicationServer = null; if (_key != null) { applicationServer = _dao.findById(_key); if (applicationServer == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("id", _key))); _key = null;/*from www . jav a 2s. co m*/ } } IModel model = new DaoDetachableModel(applicationServer); if (isAdding()) { _title = getString(getPrefix() + ".add.title"); } else { _title = getString(getPrefix() + ".edit.title", model); } Form form = new Form("form", new CompoundPropertyModel(model)); add(form); form.add(new Label("title", applicationServer == null ? "" : applicationServer.getName())); form.add(new RequiredTextField<String>("name", String.class)); form.add(new RequiredTextField<String>("serverName", String.class).add(new UriValidator(true))); form.add(new DropDownChoice("defaultHandling", Arrays.asList(new Short[] { 0, 1 }), new ChoiceRenderer<Short>() { @Override public Object getDisplayValue(Short id) { return DefaultHandling.toString(id); } }).setRequired(true)); form.add(new CheckBox("includeRegisterRequest")); form.add(new CheckBox("includeRegisterResponse")); form.add(new TextField("serviceInformation", String.class)); form.add(new Button("submit") { @Override public void onSubmit() { try { ApplicationServer as = (ApplicationServer) getForm().getModelObject(); _dao.save(as); getCxManager().applicationServerUpdated(as); getSession().info(getString("modification.success")); } catch (Exception e) { getSession().error(getString(getPrefix() + ".error.duplicate", getForm().getModel())); } } }); form.add(new Button("cancel") { @Override public void onSubmit() { getSession().info(getString("modification.cancel")); goToBackPage(AsBrowserPage.class); } }.setDefaultFormProcessing(false)); if (applicationServer != null) setContextMenu(new ContextPanel(applicationServer)); }
From source file:org.cipango.ims.hss.web.debugsession.EditDebugSessionPage.java
License:Apache License
@SuppressWarnings("unchecked") public EditDebugSessionPage(PageParameters pageParameters) { super(pageParameters); String sKey = pageParameters.getString("id"); PublicIdentity publicIdentity = null; if (sKey != null) _key = Long.decode(sKey); else {/*from w w w .j av a 2 s.co m*/ _publicIdKey = pageParameters.getString("publicId"); publicIdentity = _publicIdentityDao.findById(_publicIdKey); } DebugSession debugSession = null; if (_key != null) { debugSession = _dao.findById(_key); if (debugSession == null) { error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"), new MicroMap("identity", _key))); _key = null; } else publicIdentity = debugSession.getPublicIdentity(); } if (debugSession == null) { debugSession = new DebugSession(); debugSession.setDebugId(ID.newDebugId()); } DaoDetachableModel model = new DaoDetachableModel(debugSession); if (isAdding()) { _title = getString(getPrefix() + ".add.title"); } else { _title = getString(getPrefix() + ".edit.title", model); } Form form = new Form("form", new CompoundPropertyModel(model)); add(form); form.add(new TextField<String>("from", String.class).add(new UriValidator())); form.add(new TextField<String>("to", String.class).add(new UriValidator())); form.add(new MethodField("method")); form.add(new TextField<String>("iari", String.class)); form.add(new TextField<String>("icsi", String.class)); form.add(new DateTimeField("startDate")); form.add(new TextField<String>("duration", String.class)); form.add(new DropDownChoice("reason", Arrays.asList(new Boolean[] { true, false }), new ChoiceRenderer<Boolean>() { @Override public Object getDisplayValue(Boolean id) { return DebugSession.getReasonAsString(id); } })); form.add(new DateTimeField("stopDate")); form.add(new RequiredTextField<String>("debugId", String.class)); form.add(new DropDownChoice("traceDepth", Arrays.asList(new Boolean[] { true, false }), new ChoiceRenderer<Boolean>() { @Override public Object getDisplayValue(Boolean id) { return DebugSession.getTraceDepthAsString(id); } })); form.add(new Button("submit") { @Override public void onSubmit() { try { DebugSession debugSession = (DebugSession) getForm().getModelObject(); if (_publicIdKey != null) { PublicIdentity publicIdentity = _publicIdentityDao.findById(_publicIdKey); if (publicIdentity != null) debugSession.setPublicIdentity(publicIdentity); } _dao.save(debugSession); getCxManager().identityUpdated(debugSession.getPublicIdentity()); getSession().info(getString("modification.success")); if (!debugSession.getId().equals(_key)) setResponsePage(EditDebugSessionPage.class, new PageParameters("id=" + debugSession.getId())); } catch (Exception e) { __log.debug("Failed to apply edit", e); getSession().error(getString(getPrefix() + ".error.duplicate", getForm().getModel())); } } }); form.add(new Button("cancel") { @Override public void onSubmit() { getSession().info(getString("modification.cancel")); String id; if (isAdding()) id = _publicIdentityDao.findById(_publicIdKey).getIdentity(); else id = _dao.findById(_key).getPublicIdentity().getIdentity(); setResponsePage(EditPublicUserIdPage.class, new PageParameters("id=" + id)); } }.setDefaultFormProcessing(false)); form.add(new Button("delete") { @Override public void onSubmit() { DebugSession session = _dao.findById(_key); setResponsePage(EditPublicUserIdPage.class, new PageParameters("id=" + session.getPublicIdentity().getIdentity())); getCxManager().identityUpdated(session.getPublicIdentity()); _dao.delete(session); getSession().info(getString(getPrefix() + ".delete.done", new DaoDetachableModel(session))); } }.setDefaultFormProcessing(false).setVisible(!isAdding())); if (publicIdentity != null) { if (publicIdentity instanceof PublicUserIdentity) setContextMenu(new ContextPanel((PublicUserIdentity) publicIdentity)); else setContextMenu(new PsiContextPanel((PSI) publicIdentity)); } }