List of usage examples for org.apache.wicket.markup.html.form ListChoice ListChoice
public ListChoice(String id, IModel<T> model, IModel<? extends List<? extends T>> choices, IChoiceRenderer<? super T> renderer)
From source file:com.francetelecom.clara.cloud.presentation.designer.panels.DesignerServiceDefinitionPanel.java
License:Apache License
private void initServiceListChoiceComponent() { // This form is needed to automatically select a service in HMI tests Form<Void> selectForm = new Form<>("selectForm"); add(selectForm);/* ww w . j a v a2s . c o m*/ ChoiceRenderer<LogicalModelItem> choiceRenderer = new ChoiceRenderer<LogicalModelItem>() { private static final long serialVersionUID = -6313188726358374089L; @Override public Object getDisplayValue(LogicalModelItem modelItem) { return parentPage.getServiceCatalogName(modelItem); } @Override public String getIdValue(LogicalModelItem modelItem, int i) { return modelItem.getClass().getName(); } }; servicesListChoice = new ListChoice<LogicalModelItem>("logicalServicesListSelect", serviceModel, getModelObject(), choiceRenderer) { private static final long serialVersionUID = 4264246812205897235L; @Override protected boolean isDisabled(LogicalModelItem modelItem, int index, String selected) { return !parentPage.isServiceEnable(modelItem); } }; servicesListChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -913367640965160132L; @Override protected void onUpdate(AjaxRequestTarget target) { updateServiceFormPanel(target, serviceModel.getObject(), parentPage, true); } }); // servicesListChoice.setNullValid(true); servicesListChoice.setOutputMarkupId(true); selectForm.add(servicesListChoice); }
From source file:com.userweave.pages.components.slidableajaxtabpanel.addmethodpanel.AbstractAddPanel.java
License:Open Source License
public AbstractAddPanel(String id, final List<T> choices, final ChangeTabsCallback callback) { super(id);// w w w .ja v a 2 s . c o m try { selectedItem = choices.get(0); } catch (IndexOutOfBoundsException e) { selectedItem = null; } previewLegendLabel = new Label("preview_legend", getPreviewNameOnUpdate(selectedItem)); ListChoice moduleChoice = new ListChoice("choices", new PropertyModel(AbstractAddPanel.this, "selectedItem"), choices, getChoiceRenderer()); moduleChoice.add(AjaxBehaviorFactory.getUpdateBehavior("onclick", AbstractAddPanel.this)); moduleChoice.setRequired(true); moduleChoice.setOutputMarkupId(true); init(moduleChoice, callback); }
From source file:com.userweave.pages.components.slidableajaxtabpanel.addmethodpanel.AbstractAddPanel.java
License:Open Source License
public AbstractAddPanel(String id, final IModel choices, final ChangeTabsCallback callback) { super(id);/*from w w w .j a v a 2 s.co m*/ try { selectedItem = (T) ((List) choices.getObject()).get(0); } catch (IndexOutOfBoundsException e) { selectedItem = null; } previewLegendLabel = new Label("preview_legend", getPreviewNameOnUpdate(selectedItem)); ListChoice moduleChoice = new ListChoice("choices", new PropertyModel(AbstractAddPanel.this, "selectedItem"), choices, getChoiceRenderer()); moduleChoice.add(AjaxBehaviorFactory.getUpdateBehavior("onclick", AbstractAddPanel.this)); moduleChoice.setRequired(true); moduleChoice.setOutputMarkupId(true); init(moduleChoice, callback); }
From source file:nl.mpi.lamus.web.pages.SelectWorkspacePage.java
License:Open Source License
/** * Create Form that will show a list of Workspaces to be opened by a * specific user// w w w . j a v a 2 s . co m * * @param id * @return created form */ private Form createNodeIdForm(String id) { boolean showPanel = true; Workspace defaultSelectedWs = null; List<Workspace> myWSList = new ArrayList<>(workspaceService.listUserWorkspaces(currentUserId)); if (!myWSList.isEmpty()) { defaultSelectedWs = myWSList.iterator().next(); } else { showPanel = false; } IModel<Workspace> workspaceModel; if (!showPanel) { workspaceModel = null; } else { workspaceModel = workspaceModelProvider.getWorkspaceModel(defaultSelectedWs.getWorkspaceID()); } ListChoice<Workspace> listWorkspaces = new ListChoice<>("workspaceSelection", workspaceModel, myWSList, new ChoiceRenderer<Workspace>("workspaceSelectionDisplayString")); listWorkspaces.setMaxRows(5); listWorkspaces.setNullValid(false); listWorkspaces.setRequired(true); final Form<Workspace> openWsForm = new Form<>(id, workspaceModel); Button submitButton = new AjaxButton("openWorkspace") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); try { if (form.getModelObject() != null) { Workspace openSelectedWorkspace = workspaceService.openWorkspace(currentUserId, ((Workspace) form.getModelObject()).getWorkspaceID()); setResponsePage(pagesProvider.getWorkspacePage(openSelectedWorkspace)); } } catch (WorkspaceNotFoundException | WorkspaceAccessException | IOException ex) { Session.get().error(ex.getMessage()); } } }; openWsForm.add(submitButton); openWsForm.add(listWorkspaces); // Put details/submit form in container for refresh through AJAX final MarkupContainer formContainer = new WebMarkupContainer("formContainer"); formContainer.add(openWsForm); if (!showPanel) { formContainer.setVisible(false); Session.get().info(getLocalizer().getString("select_workspace_no_open_workspaces", this)); } // Add container to page add(formContainer); return openWsForm; }
From source file:org.apache.syncope.client.console.pages.ReportModalPage.java
License:Apache License
private void setupProfile() { final WebMarkupContainer profile = new WebMarkupContainer("profile"); profile.setOutputMarkupId(true);//from w w w . ja v a 2 s . c om form.add(profile); final ModalWindow reportletConfWin = new ModalWindow("reportletConfWin"); reportletConfWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); reportletConfWin.setCookieName("reportlet-conf-win-modal"); reportletConfWin.setInitialHeight(REPORTLET_CONF_WIN_HEIGHT); reportletConfWin.setInitialWidth(REPORTLET_CONF_WIN_WIDTH); reportletConfWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { int foundIdx = -1; if (modalReportletConfOldName != null) { for (int i = 0; i < reportTO.getReportletConfs().size() && foundIdx == -1; i++) { if (reportTO.getReportletConfs().get(i).getName().equals(modalReportletConfOldName)) { foundIdx = i; } } } if (modalReportletConf != null) { if (foundIdx == -1) { reportTO.getReportletConfs().add(modalReportletConf); } else { reportTO.getReportletConfs().set(foundIdx, modalReportletConf); } } target.add(reportlets); } }); add(reportletConfWin); final Label idLabel = new Label("idLabel", new ResourceModel("key")); profile.add(idLabel); final AjaxTextFieldPanel key = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(reportTO, "key")); key.setEnabled(false); profile.add(key); final Label nameLabel = new Label("nameLabel", new ResourceModel("name")); profile.add(nameLabel); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(reportTO, "name")); profile.add(name); final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"), new DateFormatROModel(new PropertyModel<String>(reportTO, "lastExec"))); lastExec.setEnabled(false); profile.add(lastExec); final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"), new DateFormatROModel(new PropertyModel<String>(reportTO, "nextExec"))); nextExec.setEnabled(false); profile.add(nextExec); reportlets = new ListChoice<AbstractReportletConf>("reportletConfs", new Model<AbstractReportletConf>(), reportTO.getReportletConfs(), new IChoiceRenderer<ReportletConf>() { private static final long serialVersionUID = 1048000918946220007L; @Override public Object getDisplayValue(final ReportletConf object) { return object.getName(); } @Override public String getIdValue(final ReportletConf object, final int index) { return object.getName(); } }) { private static final long serialVersionUID = 4022366881854379834L; @Override protected CharSequence getDefaultChoice(final String selectedValue) { return null; } }; reportlets.setNullValid(true); profile.add(reportlets); reportlets.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.add(reportlets); } }); profile.add(new AjaxLink<Void>(ADD_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { reportletConfWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { modalReportletConfOldName = null; modalReportletConf = null; return new ReportletConfModalPage(null, reportletConfWin, ReportModalPage.this.getPageReference()); } }); reportletConfWin.show(target); } }); profile.add(new AjaxLink<Void>(EDIT_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { reportletConfWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { modalReportletConfOldName = reportlets.getModelObject().getName(); modalReportletConf = null; return new ReportletConfModalPage(reportlets.getModelObject(), reportletConfWin, ReportModalPage.this.getPageReference()); } }); reportletConfWin.show(target); } } }); profile.add(new AjaxLink<Void>(REMOVE_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { reportTO.getReportletConfs().remove(reportlets.getModelObject()); reportlets.setModelObject(null); target.add(reportlets); } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { if (reportlets.getModelObject() != null) { super.updateAjaxAttributes(attributes); final AjaxCallListener ajaxCallListener = new AjaxCallListener() { private static final long serialVersionUID = 7160235486520935153L; @Override public CharSequence getPrecondition(final Component component) { return "if (!confirm('" + getString("confirmDelete") + "')) {return false;}"; } }; attributes.getAjaxCallListeners().add(ajaxCallListener); } } }); profile.add(new AjaxLink<Void>(UP_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { moveUp(reportlets.getModelObject()); target.add(reportlets); } } }); profile.add(new AjaxLink<Void>(DOWN_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { moveDown(reportlets.getModelObject()); target.add(reportlets); } } }); }
From source file:org.apache.syncope.console.pages.ReportModalPage.java
License:Apache License
private void setupProfile() { final WebMarkupContainer profile = new WebMarkupContainer("profile"); profile.setOutputMarkupId(true);/*ww w . ja va2 s .com*/ form.add(profile); final ModalWindow reportletConfWin = new ModalWindow("reportletConfWin"); reportletConfWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); reportletConfWin.setCookieName("reportlet-conf-win-modal"); reportletConfWin.setInitialHeight(REPORTLET_CONF_WIN_HEIGHT); reportletConfWin.setInitialWidth(REPORTLET_CONF_WIN_WIDTH); reportletConfWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { int foundIdx = -1; if (modalReportletConfOldName != null) { for (int i = 0; i < reportTO.getReportletConfs().size() && foundIdx == -1; i++) { if (reportTO.getReportletConfs().get(i).getName().equals(modalReportletConfOldName)) { foundIdx = i; } } } if (modalReportletConf != null) { if (foundIdx == -1) { reportTO.getReportletConfs().add(modalReportletConf); } else { reportTO.getReportletConfs().set(foundIdx, modalReportletConf); } } target.add(reportlets); } }); add(reportletConfWin); final Label idLabel = new Label("idLabel", new ResourceModel("id")); profile.add(idLabel); final AjaxTextFieldPanel id = new AjaxTextFieldPanel("id", getString("id"), new PropertyModel<String>(reportTO, "id")); id.setEnabled(false); profile.add(id); final Label nameLabel = new Label("nameLabel", new ResourceModel("name")); profile.add(nameLabel); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(reportTO, "name")); profile.add(name); final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"), new DateFormatROModel(new PropertyModel<String>(reportTO, "lastExec"))); lastExec.setEnabled(false); profile.add(lastExec); final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"), new DateFormatROModel(new PropertyModel<String>(reportTO, "nextExec"))); nextExec.setEnabled(false); profile.add(nextExec); reportlets = new ListChoice<AbstractReportletConf>("reportletConfs", new Model<AbstractReportletConf>(), reportTO.getReportletConfs(), new IChoiceRenderer<ReportletConf>() { private static final long serialVersionUID = 1048000918946220007L; @Override public Object getDisplayValue(final ReportletConf object) { return object.getName(); } @Override public String getIdValue(final ReportletConf object, final int index) { return object.getName(); } }) { private static final long serialVersionUID = 4022366881854379834L; @Override protected CharSequence getDefaultChoice(final String selectedValue) { return null; } }; reportlets.setNullValid(true); profile.add(reportlets); reportlets.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.add(reportlets); } }); profile.add(new AjaxLink<Void>(ADD_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { reportletConfWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { modalReportletConfOldName = null; modalReportletConf = null; return new ReportletConfModalPage(null, reportletConfWin, ReportModalPage.this.getPageReference()); } }); reportletConfWin.show(target); } }); profile.add(new AjaxLink<Void>(EDIT_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { reportletConfWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { modalReportletConfOldName = reportlets.getModelObject().getName(); modalReportletConf = null; return new ReportletConfModalPage(reportlets.getModelObject(), reportletConfWin, ReportModalPage.this.getPageReference()); } }); reportletConfWin.show(target); } } }); profile.add(new AjaxLink<Void>(REMOVE_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { reportTO.getReportletConfs().remove(reportlets.getModelObject()); reportlets.setModelObject(null); target.add(reportlets); } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { if (reportlets.getModelObject() != null) { super.updateAjaxAttributes(attributes); final AjaxCallListener ajaxCallListener = new AjaxCallListener() { private static final long serialVersionUID = 7160235486520935153L; @Override public CharSequence getPrecondition(final Component component) { return "if (!confirm('" + getString("confirmDelete") + "')) {return false;}"; } }; attributes.getAjaxCallListeners().add(ajaxCallListener); } } }); profile.add(new AjaxLink<Void>(UP_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { moveUp(reportlets.getModelObject()); target.add(reportlets); } } }); profile.add(new AjaxLink<Void>(DOWN_BUTTON_ID) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (reportlets.getModelObject() != null) { moveDown(reportlets.getModelObject()); target.add(reportlets); } } }); }
From source file:org.wintersleep.usermgmt.wicket.UserEditPage.java
License:Apache License
public UserEditPage(final Page backPage, HibernateObjectModel<Long, User> model) { // TODO replace queries with calls to Repository HibernateListModel<Long, UserProfile> userProfiles = new HibernateListModel<>( "from UserProfile order by name"); final Form form = new Form<User>("editform", model) { protected void onSubmit() { User user = getModelObject(); saver.save(user);//from ww w . j a v a 2s . com //getSession().info(String.format("Saved user %s %s", user.getNameFirst(), user.getNameLast())); setResponsePage(backPage); } }; add(form); // TODO allow model-based validation form.add(new RequiredTextField<>("login", new PropertyModel<String>(model, "login")) .add(StringValidator.maximumLength(8))); form.add(new PasswordTextField("password", new PropertyModel<String>(model, "password")) .add(StringValidator.maximumLength(16))); form.add(new RequiredTextField<>("fullName", new PropertyModel<String>(model, "fullName")) .add(StringValidator.maximumLength(32))); form.add(new ListChoice<>("userProfile", new PropertyModel<UserProfile>(model.getObject(), "userProfile"), userProfiles, new ChoiceRenderer<UserProfile>("name", "id"))); /* form.add(new Button("new") { public void onSubmit() { form.clearPersistentObject(); } }.setDefaultFormProcessing(false)); */ form.add(new Button("cancel") { public void onSubmit() { getSession().info("Cancelled edit"); sessionFactory.getCurrentSession().clear(); setResponsePage(backPage); } }.setDefaultFormProcessing(false)); form.add(new Label("userManagementService", new PropertyModel(model.getObject(), "msg"))); }