List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close
public void close(final IPartialPageRequestHandler target)
From source file:org.syncope.console.pages.DisplayAttributesModalPage.java
License:Apache License
public DisplayAttributesModalPage(final PageReference callerPageRef, final ModalWindow window) { super();//from ww w. j a va 2 s . c o m final Form form = new Form("form"); form.setModel(new CompoundPropertyModel(this)); userDetails = prefMan.getList(getRequest(), Constants.PREF_USERS_DETAILS_VIEW); selectedSchemas = prefMan.getList(getRequest(), Constants.PREF_USERS_ATTRIBUTES_VIEW); selectedVirSchemas = prefMan.getList(getRequest(), Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW); selectedDerSchemas = prefMan.getList(getRequest(), Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW); final CheckGroup dgroup = new CheckGroup("dCheckGroup", new PropertyModel(this, "userDetails")); form.add(dgroup); final ListView<String> details = new ListView<String>("details", dnames) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(ListItem<String> item) { item.add(new Check("dcheck", item.getModel())); item.add(new Label("dname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; dgroup.add(details); if (names.getObject() != null && !names.getObject().isEmpty()) { final Fragment fragment = new Fragment("schemas", "sfragment", form); form.add(fragment); final CheckGroup sgroup = new CheckGroup("sCheckGroup", new PropertyModel(this, "selectedSchemas")); fragment.add(sgroup); final ListView<String> schemas = new ListView<String>("schemas", names) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(ListItem<String> item) { item.add(new Check("scheck", item.getModel())); item.add(new Label("sname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; sgroup.add(schemas); } else { final Fragment fragment = new Fragment("schemas", "emptyFragment", form); form.add(fragment); selectedSchemas.clear(); } if (vsnames.getObject() != null && !vsnames.getObject().isEmpty()) { final Fragment fragment = new Fragment("vschemas", "vsfragment", form); form.add(fragment); final CheckGroup vsgroup = new CheckGroup("vsCheckGroup", new PropertyModel(this, "selectedVirSchemas")); fragment.add(vsgroup); final ListView<String> virSchemas = new ListView<String>("virSchemas", vsnames) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(ListItem<String> item) { item.add(new Check("vscheck", item.getModel())); item.add(new Label("vsname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; vsgroup.add(virSchemas); } else { final Fragment fragment = new Fragment("vschemas", "emptyFragment", form); form.add(fragment); selectedVirSchemas.clear(); } if (dsnames.getObject() != null && !dsnames.getObject().isEmpty()) { final Fragment fragment = new Fragment("dschemas", "dsfragment", form); form.add(fragment); final CheckGroup dsgroup = new CheckGroup("dsCheckGroup", new PropertyModel(this, "selectedDerSchemas")); fragment.add(dsgroup); final ListView<String> derSchemas = new ListView<String>("derSchemas", dsnames) { private static final long serialVersionUID = 9101744072914090143L; @Override protected void populateItem(ListItem<String> item) { item.add(new Check("dscheck", item.getModel())); item.add(new Label("dsname", new ResourceModel(item.getModelObject(), item.getModelObject()))); } }; dsgroup.add(derSchemas); } else { final Fragment fragment = new Fragment("dschemas", "emptyFragment", form); form.add(fragment); selectedDerSchemas.clear(); } final IndicatingAjaxButton submit = new IndicatingAjaxButton("submit", new ResourceModel("submit")) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { if (userDetails.size() + selectedSchemas.size() + selectedVirSchemas.size() + selectedDerSchemas.size() > MAX_SELECTIONS) { error(getString("tooMuchSelections")); onError(target, form); } else { final Map<String, List<String>> prefs = new HashMap<String, List<String>>(); prefs.put(Constants.PREF_USERS_DETAILS_VIEW, userDetails); prefs.put(Constants.PREF_USERS_ATTRIBUTES_VIEW, selectedSchemas); prefs.put(Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW, selectedVirSchemas); prefs.put(Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW, selectedDerSchemas); prefMan.setList(getRequest(), getResponse(), prefs); ((BasePage) callerPageRef.getPage()).setModalResult(true); window.close(target); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }; form.add(submit); add(form); }
From source file:org.syncope.console.pages.MembershipModalPage.java
License:Apache License
public MembershipModalPage(final PageReference pageRef, final ModalWindow window, final MembershipTO membershipTO, final boolean templateMode) { final Form form = new Form("MembershipForm"); final UserTO userTO = ((UserModalPage) pageRef.getPage()).getUserTO(); form.setModel(new CompoundPropertyModel(membershipTO)); submit = new AjaxButton("submit", new ResourceModel("submit")) { private static final long serialVersionUID = -958724007591692537L; @Override/*w w w . ja v a 2s .com*/ protected void onSubmit(final AjaxRequestTarget target, final Form form) { userTO.removeMembership(membershipTO); userTO.addMembership(membershipTO); ((UserModalPage) pageRef.getPage()).setUserTO(userTO); window.close(target); } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(feedbackPanel); } }; String allowedRoles = userTO.getId() == 0 ? xmlRolesReader.getAllAllowedRoles("Users", "create") : xmlRolesReader.getAllAllowedRoles("Users", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, allowedRoles); form.add(submit); //-------------------------------- // Attributes panel //-------------------------------- form.add(new AttributesPanel("attributes", membershipTO, form, templateMode)); //-------------------------------- //-------------------------------- // Derived attributes container //-------------------------------- form.add(new DerivedAttributesPanel("derivedAttributes", membershipTO)); //-------------------------------- //-------------------------------- // Virtual attributes container //-------------------------------- form.add(new VirtualAttributesPanel("virtualAttributes", membershipTO, templateMode)); //-------------------------------- add(form); }
From source file:org.syncope.console.pages.NotificationModalPage.java
License:Apache License
public NotificationModalPage(final PageReference callPageRef, final ModalWindow window, final NotificationTO notificationTO, final boolean createFlag) { Form form = new Form("form", new CompoundPropertyModel(notificationTO)); form.setModel(new CompoundPropertyModel(notificationTO)); final AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"), new PropertyModel<String>(notificationTO, "sender"), false); sender.addRequiredLabel();/*w ww .j av a 2 s . c om*/ sender.addValidator(EmailAddressValidator.getInstance()); form.add(sender); final AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"), new PropertyModel<String>(notificationTO, "subject"), false); subject.addRequiredLabel(); form.add(subject); final AjaxDropDownChoicePanel<String> template = new AjaxDropDownChoicePanel<String>("template", getString("template"), new PropertyModel(notificationTO, "template"), false); template.setChoices(restClient.getMailTemplates()); template.addRequiredLabel(); form.add(template); final AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<TraceLevel>("traceLevel", getString("traceLevel"), new PropertyModel(notificationTO, "traceLevel"), false); traceLevel.setChoices(Arrays.asList(TraceLevel.values())); traceLevel.addRequiredLabel(); form.add(traceLevel); final UserSearchPanel about = new UserSearchPanel("about", notificationTO.getAbout()); form.add(about); final AjaxPalettePanel events = new AjaxPalettePanel("events", new PropertyModel(notificationTO, "events"), new ListModel<String>(restClient.getEvents())); form.add(events); final UserSearchPanel recipients = new UserSearchPanel("recipients", notificationTO.getRecipients()); form.add(recipients); final AjaxCheckBoxPanel selfAsRecipient = new AjaxCheckBoxPanel("selfAsRecipient", getString("selfAsRecipient"), new PropertyModel(notificationTO, "selfAsRecipient"), false); form.add(selfAsRecipient); AjaxButton submit = new IndicatingAjaxButton("apply", new Model<String>(getString("submit"))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { notificationTO.setAbout(about.buildSearchCond()); notificationTO.setRecipients(recipients.buildSearchCond()); try { if (createFlag) { restClient.createNotification(notificationTO); } else { restClient.updateNotification(notificationTO); } info(getString("operation_succeded")); Configuration callerPage = (Configuration) callPageRef.getPage(); callerPage.setModalResult(true); window.close(target); } catch (SyncopeClientCompositeErrorException scee) { error(getString("error") + ":" + scee.getMessage()); target.add(feedbackPanel); } } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(feedbackPanel); } }; String allowedRoles = createFlag ? xmlRolesReader.getAllAllowedRoles("Notification", "create") : xmlRolesReader.getAllAllowedRoles("Notification", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); form.add(submit); add(form); }
From source file:org.syncope.console.pages.panels.UserManagementResultPanel.java
License:Apache License
/** * Panel constructor.//w w w .j a va 2s . c o m * * @param id panel id. * @param window guest modal window. * @param mode operation mode. * @param userTO User TO. */ public UserManagementResultPanel(final String id, final ModalWindow window, final UserModalPage.Mode mode, final UserTO userTO) { super(id); // shortcut to retrieve fragments inside inner classes final Panel panel = this; final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); final Fragment fragment = new Fragment("userModalResultFrag", mode == UserModalPage.Mode.SELF ? "userModalSelfResultFrag" : "userModalPropagationResultFrag", this); fragment.setOutputMarkupId(true); container.add(fragment); if (mode == UserModalPage.Mode.ADMIN) { // add Syncope propagation status PropagationTO syncope = new PropagationTO(); syncope.setResourceName("Syncope"); syncope.setStatus(PropagationTaskExecStatus.SUCCESS); List<PropagationTO> propagations = new ArrayList<PropagationTO>(); propagations.add(syncope); propagations.addAll(userTO.getPropagationTOs()); fragment.add(new Label("userInfo", userTO.getUsername() != null ? userTO.getUsername() : String.valueOf(userTO.getId()))); final ListView<PropagationTO> propRes = new ListView<PropagationTO>("resources", propagations) { private static final long serialVersionUID = -1020475259727720708L; @Override protected void populateItem(final ListItem item) { final PropagationTO propTO = (PropagationTO) item.getDefaultModelObject(); final ListView attributes = getConnObjectView(propTO); final Fragment attrhead; if (attributes.getModelObject() != null && !attributes.getModelObject().isEmpty()) { attrhead = new Fragment("attrhead", "attrHeadFrag", panel); } else { attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", panel); } item.add(attrhead); item.add(attributes); attrhead.add(new Label("resource", propTO.getResourceName())); attrhead.add(new Label("propagation", propTO.getStatus() != null ? propTO.getStatus().toString() : "UNDEFINED")); final Image image; final String alt, title; switch (propTO.getStatus()) { case SUCCESS: case SUBMITTED: case CREATED: image = new Image("icon", "statuses/active.png"); alt = "success icon"; title = "success"; break; default: image = new Image("icon", "statuses/inactive.png"); alt = "failure icon"; title = "failure"; } image.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("alt", alt); tag.put("title", title); } }); attrhead.add(image); } }; fragment.add(propRes); } final AjaxLink close = new IndicatingAjaxLink("close") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { window.close(target); } }; container.add(close); }
From source file:org.syncope.console.pages.PolicyModalPage.java
License:Apache License
public PolicyModalPage(final ModalWindow window, final T policyTO) { super();/*w w w.j a va2 s.c o m*/ final Form form = new Form("form"); form.setOutputMarkupId(true); add(form); final AjaxTextFieldPanel policyid = new AjaxTextFieldPanel("id", "id", new PropertyModel<String>(policyTO, "id"), false); policyid.setEnabled(false); policyid.setStyleShet("ui-widget-content ui-corner-all short_fixedsize"); form.add(policyid); final AjaxTextFieldPanel description = new AjaxTextFieldPanel("description", "description", new PropertyModel<String>(policyTO, "description"), false); description.addRequiredLabel(); description.setStyleShet("ui-widget-content ui-corner-all medium_dynamicsize"); form.add(description); final AjaxDropDownChoicePanel<PolicyType> type = new AjaxDropDownChoicePanel<PolicyType>("type", "type", new PropertyModel<PolicyType>(policyTO, "type"), false); switch (policyTO.getType()) { case GLOBAL_ACCOUNT: case ACCOUNT: type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_ACCOUNT, PolicyType.ACCOUNT })); break; case GLOBAL_PASSWORD: case PASSWORD: type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_PASSWORD, PolicyType.PASSWORD })); break; case GLOBAL_SYNC: case SYNC: type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_SYNC, PolicyType.SYNC })); default: } type.setChoiceRenderer(new PolicyTypeRenderer()); type.addRequiredLabel(); form.add(type); final AbstractPolicySpec policy = getPolicySpecification(policyTO); form.add(new PolicyBeanPanel("panel", policy)); final IndicatingAjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("apply")) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { setPolicySpecification(policyTO, policy); try { if (policyTO.getId() > 0) { policyRestClient.updatePolicy(policyTO); } else { policyRestClient.createPolicy(policyTO); } window.close(target); } catch (Exception e) { LOG.error("While creating policy", e); error(getString("operation_error")); target.add(getPage().get("feedback")); } } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(getPage().get("feedback")); } }; form.add(submit); }
From source file:org.syncope.console.pages.ReportExecResultDownloadModalPage.java
License:Apache License
public ReportExecResultDownloadModalPage(final ModalWindow window, final PageReference callerPageRef) { final AjaxDropDownChoicePanel<ReportExecExportFormat> format = new AjaxDropDownChoicePanel<ReportExecExportFormat>( "format", "format", new Model<ReportExecExportFormat>(), false); format.setChoices(Arrays.asList(ReportExecExportFormat.values())); format.setChoiceRenderer(new IChoiceRenderer<ReportExecExportFormat>() { private static final long serialVersionUID = -3941271550163141339L; @Override/*ww w. j a v a 2 s . c o m*/ public Object getDisplayValue(final ReportExecExportFormat object) { return object.name(); } @Override public String getIdValue(final ReportExecExportFormat object, final int index) { return object.name(); } }); format.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((ReportModalPage) callerPageRef.getPage()).setExportFormat(format.getField().getInput()); window.close(target); } }); add(format); }
From source file:org.syncope.console.pages.ReportModalPage.java
License:Apache License
public ReportModalPage(final ModalWindow window, final ReportTO reportTO, final PageReference callerPageRef) { this.reportTO = reportTO; form = new Form<ReportTO>("form"); form.setModel(new CompoundPropertyModel(reportTO)); add(form);//from w w w . j a va2s .c o m setupProfile(); setupExecutions(); final CrontabContainer crontab = new CrontabContainer("crontab", new PropertyModel<String>(reportTO, "cronExpression"), reportTO.getCronExpression()); form.add(crontab); final IndicatingAjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("apply")) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { ReportTO reportTO = (ReportTO) form.getModelObject(); reportTO.setCronExpression( StringUtils.hasText(reportTO.getCronExpression()) ? crontab.getCronExpression() : null); try { if (reportTO.getId() > 0) { restClient.update(reportTO); } else { restClient.create(reportTO); } ((BasePage) callerPageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientCompositeErrorException e) { LOG.error("While creating or updating report", e); error(getString("error") + ":" + e.getMessage()); target.add(feedbackPanel); } } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(feedbackPanel); } }; if (reportTO.getId() > 0) { MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getAllAllowedRoles("Reports", "update")); } else { MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getAllAllowedRoles("Reports", "create")); } form.add(submit); }
From source file:org.syncope.console.pages.ResourceModalPage.java
License:Apache License
public ResourceModalPage(final PageReference pageref, final ModalWindow window, final ResourceTO resourceTO, final boolean createFlag) { super();/*from www .java 2 s . co m*/ final Form form = new Form("form"); form.setModel(new CompoundPropertyModel(resourceTO)); //-------------------------------- // Resource details panel //-------------------------------- form.add(new ResourceDetailsPanel("details", resourceTO, createFlag)); //-------------------------------- //-------------------------------- // Resource mapping panle //-------------------------------- form.add(new ResourceMappingPanel("mapping", resourceTO, createFlag)); //-------------------------------- //-------------------------------- // Resource mapping panle //-------------------------------- form.add(new ResourceConnConfPanel("connconf", resourceTO, createFlag)); //-------------------------------- //-------------------------------- // Resource security panel //-------------------------------- form.add(new ResourceSecurityPanel("security", resourceTO)); //-------------------------------- final AjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("submit", "submit")) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { final ResourceTO resourceTO = (ResourceTO) form.getDefaultModelObject(); int accountIdCount = 0; for (SchemaMappingTO mapping : resourceTO.getMappings()) { if (mapping.isAccountid()) { accountIdCount++; } } if (accountIdCount == 0 || accountIdCount > 1) { error(new ResourceModel("accountIdValidation", "accountIdValidation").getObject()); target.add(feedbackPanel); } else { try { if (createFlag) { resourceRestClient.create(resourceTO); } else { resourceRestClient.update(resourceTO); } ((Resources) pageref.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientCompositeErrorException e) { LOG.error("Failuer managing resource {}", resourceTO); error(new ResourceModel("error", "error").getObject() + ":" + e.getMessage()); target.add(feedbackPanel); } } } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(feedbackPanel); } }; form.add(submit); add(form); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getAllAllowedRoles("Resources", createFlag ? "create" : "update")); }
From source file:org.syncope.console.pages.RoleModalPage.java
License:Apache License
public RoleModalPage(final PageReference callerPageRef, final ModalWindow window, final RoleTO roleTO) { super();//from w ww. j a va 2 s.com final boolean createFlag = roleTO.getId() == 0; if (!createFlag) { originalRoleTO = AttributableOperations.clone(roleTO); } final Form form = new Form("RoleForm"); add(new Label("displayName", roleTO.getId() != 0 ? roleTO.getDisplayName() : "")); form.setModel(new CompoundPropertyModel(roleTO)); final RoleAttributesPanel attributesPanel = new RoleAttributesPanel("attributesPanel", form, roleTO); form.add(attributesPanel); final AjaxButton submit = new IndicatingAjaxButton("submit", new ResourceModel("submit")) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { final RoleTO roleTO = (RoleTO) form.getDefaultModelObject(); try { final List<String> entitlementList = new ArrayList<String>( attributesPanel.getEntitlementsPalette().getModelCollection()); roleTO.setEntitlements(entitlementList); if (createFlag) { roleRestClient.createRole(roleTO); } else { RoleMod roleMod = AttributableOperations.diff(roleTO, originalRoleTO); // update role just if it is changed if (!roleMod.isEmpty()) { roleRestClient.updateRole(roleMod); } } ((Roles) callerPageRef.getPage()).setModalResult(true); window.close(target); } catch (Exception e) { error(getString("error") + ":" + e.getMessage()); target.add(feedbackPanel); } } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(feedbackPanel); } }; MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getAllAllowedRoles("Roles", createFlag ? "create" : "update")); form.add(submit); add(form); }
From source file:org.syncope.console.pages.SchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference callerPageRef, final ModalWindow window, AbstractBaseBean schemaTO, final boolean createFlag) { final SchemaTO schema = schemaTO == null ? new SchemaTO() : (SchemaTO) schemaTO; final Form schemaForm = new Form("form"); schemaForm.setModel(new CompoundPropertyModel(schema)); schemaForm.setOutputMarkupId(Boolean.TRUE); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(schema, "name"), true); name.addRequiredLabel();//from w w w .ja va2 s . co m name.setEnabled(createFlag); final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern", getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern"), true); final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return restClient.getAllValidatorClasses(); } }; final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<String>("validatorClass", getString("validatorClass"), new PropertyModel(schema, "validatorClass"), true); ((DropDownChoice) validatorClass.getField()).setNullValid(true); validatorClass.setChoices(validatorsList.getObject()); final AjaxDropDownChoicePanel<SchemaType> type = new AjaxDropDownChoicePanel<SchemaType>("type", getString("type"), new PropertyModel(schema, "type"), false); type.setChoices(Arrays.asList(SchemaType.values())); type.addRequiredLabel(); final AjaxTextFieldPanel enumerationValues = new AjaxTextFieldPanel("enumerationValues", getString("enumerationValues"), new PropertyModel<String>(schema, "enumerationValues"), false); if (schema != null && SchemaType.Enum.equals(((SchemaTO) schema).getType())) { enumerationValues.addRequiredLabel(); enumerationValues.setEnabled(Boolean.TRUE); } else { enumerationValues.removeRequiredLabel(); enumerationValues.setEnabled(Boolean.FALSE); } type.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (SchemaType.Enum.ordinal() == Integer.parseInt(type.getField().getValue())) { enumerationValues.addRequiredLabel(); enumerationValues.setEnabled(Boolean.TRUE); enumerationValues.setModelObject(((SchemaTO) schema).getEnumerationValues()); } else { enumerationValues.removeRequiredLabel(); enumerationValues.setEnabled(Boolean.FALSE); enumerationValues.setModelObject(null); } target.add(schemaForm); } }); final AutoCompleteTextField mandatoryCondition = new AutoCompleteTextField("mandatoryCondition") { private static final long serialVersionUID = -2428903969518079100L; @Override protected Iterator getChoices(String input) { List<String> choices = new ArrayList<String>(); if (Strings.isEmpty(input)) { choices = Collections.emptyList(); return choices.iterator(); } if ("true".startsWith(input.toLowerCase())) { choices.add("true"); } else if ("false".startsWith(input.toLowerCase())) { choices.add("false"); } return choices.iterator(); } }; mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(AjaxRequestTarget art) { } }); final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"), new PropertyModel<Boolean>(schema, "multivalue"), true); final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"), new PropertyModel<Boolean>(schema, "readonly"), true); final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint", getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint"), true); final AjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("submit")) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { SchemaTO schemaTO = (SchemaTO) form.getDefaultModelObject(); if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) { error(getString("multivalueAndUniqueConstr.validation")); target.add(feedbackPanel); return; } try { if (createFlag) { restClient.createSchema(kind, schemaTO); } else { restClient.updateSchema(kind, schemaTO); } if (callerPageRef.getPage() instanceof BasePage) { ((BasePage) callerPageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientCompositeErrorException e) { error(getString("error") + ":" + e.getMessage()); target.add(feedbackPanel); } } @Override protected void onError(final AjaxRequestTarget target, final Form form) { target.add(feedbackPanel); } }; String allowedRoles; if (createFlag) { allowedRoles = xmlRolesReader.getAllAllowedRoles("Schema", "create"); } else { allowedRoles = xmlRolesReader.getAllAllowedRoles("Schema", "update"); } MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); schemaForm.add(name); schemaForm.add(conversionPattern); schemaForm.add(validatorClass); schemaForm.add(type); schemaForm.add(enumerationValues); schemaForm.add(mandatoryCondition); schemaForm.add(multivalue); schemaForm.add(readonly); schemaForm.add(uniqueConstraint); schemaForm.add(submit); add(schemaForm); }