List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add
public MarkupContainer add(final Component... children)
From source file:org.apache.syncope.client.console.panels.ResourceMappingPanel.java
License:Apache License
/** * Attribute Mapping Panel./* w w w . j ava 2 s. com*/ * * @param id panel id * @param resourceTO external resource * @param attrType USER / GROUP */ public ResourceMappingPanel(final String id, final ResourceTO resourceTO, final AttributableType attrType) { super(id); setOutputMarkupId(true); this.resourceTO = resourceTO; this.attrType = attrType; this.mappingContainer = new WebMarkupContainer("mappingContainer"); this.mappingContainer.setOutputMarkupId(true); add(this.mappingContainer); this.accountLinkContainer = new WebMarkupContainer("accountLinkContainer"); this.accountLinkContainer.setOutputMarkupId(true); add(this.accountLinkContainer); if (this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0) { schemaNames = getSchemaNames(this.resourceTO.getConnectorId(), this.resourceTO.getConnConfProperties()); setEnabled(); } else { schemaNames = Collections.<String>emptyList(); } final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); mappingContainer.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); final Label passwordLabel = new Label("passwordLabel", new ResourceModel("password")); mappingContainer.add(passwordLabel); if (AttributableType.USER != ResourceMappingPanel.this.attrType) { passwordLabel.setVisible(false); } Collections.sort(getMapping().getItems(), new Comparator<MappingItemTO>() { @Override public int compare(final MappingItemTO left, final MappingItemTO right) { int compared; if (left == null && right == null) { compared = 0; } else if (left == null) { compared = 1; } else if (right == null) { compared = -1; } else if (left.getPurpose() == MappingPurpose.BOTH && right.getPurpose() != MappingPurpose.BOTH) { compared = -1; } else if (left.getPurpose() != MappingPurpose.BOTH && right.getPurpose() == MappingPurpose.BOTH) { compared = 1; } else if (left.getPurpose() == MappingPurpose.PROPAGATION && (right.getPurpose() == MappingPurpose.SYNCHRONIZATION || right.getPurpose() == MappingPurpose.NONE)) { compared = -1; } else if (left.getPurpose() == MappingPurpose.SYNCHRONIZATION && right.getPurpose() == MappingPurpose.PROPAGATION) { compared = 1; } else if (left.getPurpose() == MappingPurpose.SYNCHRONIZATION && right.getPurpose() == MappingPurpose.NONE) { compared = -1; } else if (left.getPurpose() == MappingPurpose.NONE && right.getPurpose() != MappingPurpose.NONE) { compared = 1; } else if (left.isAccountid()) { compared = -1; } else if (right.isAccountid()) { compared = 1; } else if (left.isPassword()) { compared = -1; } else if (right.isPassword()) { compared = 1; } else { compared = left.getIntAttrName().compareTo(right.getIntAttrName()); } return compared; } }); mappings = new ListView<MappingItemTO>("mappings", getMapping().getItems()) { private static final long serialVersionUID = 4949588177564901031L; @Override protected void populateItem(final ListItem<MappingItemTO> item) { final MappingItemTO mapItem = item.getModelObject(); if (mapItem.getPurpose() == null) { mapItem.setPurpose(MappingPurpose.BOTH); } AttributableType entity = null; if (mapItem.getIntMappingType() != null) { entity = mapItem.getIntMappingType().getAttributableType(); } final List<IntMappingType> attrTypes = new ArrayList<IntMappingType>(getAttributeTypes(entity)); item.add(new AjaxDecoratedCheckbox("toRemove", new Model<Boolean>(Boolean.FALSE)) { private static final long serialVersionUID = 7170946748485726506L; @Override protected void onUpdate(final AjaxRequestTarget target) { int index = -1; for (int i = 0; i < getMapping().getItems().size() && index == -1; i++) { if (mapItem.equals(getMapping().getItems().get(i))) { index = i; } } if (index != -1) { getMapping().getItems().remove(index); item.getParent().removeAll(); target.add(ResourceMappingPanel.this); } } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { 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); } }); final AjaxDropDownChoicePanel<String> intAttrNames = new AjaxDropDownChoicePanel<String>( "intAttrNames", getString("intAttrNames"), new PropertyModel<String>(mapItem, "intAttrName"), false); intAttrNames.setChoices(schemaNames); intAttrNames.setRequired(true); intAttrNames.setStyleSheet(FIELD_STYLE); intAttrNames.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(intAttrNames); final AjaxDropDownChoicePanel<IntMappingType> intMappingTypes = new AjaxDropDownChoicePanel<IntMappingType>( "intMappingTypes", new ResourceModel("intMappingTypes", "intMappingTypes").getObject(), new PropertyModel<IntMappingType>(mapItem, "intMappingType")); intMappingTypes.setRequired(true); intMappingTypes.setChoices(attrTypes); intMappingTypes.setStyleSheet(FIELD_STYLE); item.add(intMappingTypes); final AjaxDropDownChoicePanel<AttributableType> entitiesPanel = new AjaxDropDownChoicePanel<AttributableType>( "entities", new ResourceModel("entities", "entities").getObject(), new Model<AttributableType>(entity)); entitiesPanel.setChoices(attrType == AttributableType.GROUP ? Collections.<AttributableType>singletonList(AttributableType.GROUP) : Arrays.asList(AttributableType.values())); entitiesPanel.setStyleSheet(DEF_FIELD_STYLE); entitiesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { attrTypes.clear(); attrTypes.addAll(getAttributeTypes(entitiesPanel.getModelObject())); intMappingTypes.setChoices(attrTypes); intAttrNames.setChoices(Collections.<String>emptyList()); target.add(intMappingTypes.getField()); target.add(intAttrNames.getField()); } }); item.add(entitiesPanel); final FieldPanel<String> extAttrNames = new AjaxTextFieldPanel("extAttrName", new ResourceModel("extAttrNames", "extAttrNames").getObject(), new PropertyModel<String>(mapItem, "extAttrName")); ((AjaxTextFieldPanel) extAttrNames).setChoices(schemaNames); boolean required = false; if (mapItem.isPassword()) { ((AjaxTextFieldPanel) extAttrNames).setModelObject(null); } else { required = true; } extAttrNames.setRequired(required); extAttrNames.setEnabled(required); extAttrNames.setStyleSheet(FIELD_STYLE); item.add(extAttrNames); final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel("mandatoryCondition", new ResourceModel("mandatoryCondition", "mandatoryCondition").getObject(), new PropertyModel<String>(mapItem, "mandatoryCondition")); mandatory.setChoices(Arrays.asList(new String[] { "true", "false" })); mandatory.setStyleSheet(SHORT_FIELD_STYLE); item.add(mandatory); final AjaxCheckBoxPanel accountId = new AjaxCheckBoxPanel("accountId", new ResourceModel("accountId", "accountId").getObject(), new PropertyModel<Boolean>(mapItem, "accountid")); accountId.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (accountId.getModelObject()) { mapItem.setMandatoryCondition("true"); mandatory.setEnabled(false); } else { mapItem.setMandatoryCondition("false"); mandatory.setEnabled(true); } target.add(mandatory); } }); item.add(accountId); final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel("password", new ResourceModel("password", "password").getObject(), new PropertyModel<Boolean>(mapItem, "password")); password.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { extAttrNames.setEnabled(!mapItem.isAccountid() && !password.getModelObject()); extAttrNames.setModelObject(null); extAttrNames.setRequired(!password.getModelObject()); target.add(extAttrNames); setAccountId(intMappingTypes.getModelObject(), accountId, password); target.add(accountId); } }); item.add(password); if (AttributableType.USER != ResourceMappingPanel.this.attrType) { password.setVisible(false); } final WebMarkupContainer purpose = new WebMarkupContainer("purpose"); purpose.setOutputMarkupId(Boolean.TRUE); final MappingPurposePanel panel = new MappingPurposePanel("purposeActions", new PropertyModel<MappingPurpose>(mapItem, "purpose"), purpose); purpose.add(panel); item.add(purpose); intMappingTypes.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { setAttrNames(intMappingTypes.getModelObject(), intAttrNames); target.add(intAttrNames); setAccountId(intMappingTypes.getModelObject(), accountId, password); target.add(accountId); } }); setAttrNames(mapItem.getIntMappingType(), intAttrNames); setAccountId(mapItem.getIntMappingType(), accountId, password); } }; mappings.setReuseItems(true); mappingContainer.add(mappings); addMappingBtn = new IndicatingAjaxButton("addMappingBtn", new ResourceModel("add")) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { getMapping().getItems().add(new MappingItemTO()); target.add(ResourceMappingPanel.this); } }; addMappingBtn.setDefaultFormProcessing(false); addMappingBtn.setEnabled(this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0); mappingContainer.add(addMappingBtn); boolean accountLinkEnabled = false; if (getMapping().getAccountLink() != null) { accountLinkEnabled = true; } accountLinkCheckbox = new AjaxCheckBoxPanel("accountLinkCheckbox", new ResourceModel("accountLinkCheckbox", "accountLinkCheckbox").getObject(), new Model<Boolean>(Boolean.valueOf(accountLinkEnabled))); accountLinkCheckbox.setEnabled(true); accountLinkContainer.add(accountLinkCheckbox); final AjaxTextFieldPanel accountLink = new AjaxTextFieldPanel("accountLink", new ResourceModel("accountLink", "accountLink").getObject(), new PropertyModel<String>(getMapping(), "accountLink")); accountLink.setEnabled(accountLinkEnabled); accountLinkContainer.add(accountLink); accountLinkCheckbox.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (accountLinkCheckbox.getModelObject()) { accountLink.setEnabled(Boolean.TRUE); accountLink.setModelObject(""); } else { accountLink.setEnabled(Boolean.FALSE); accountLink.setModelObject(""); } target.add(accountLink); } }); }
From source file:org.apache.syncope.client.console.panels.RoleDetailsPanel.java
License:Apache License
public RoleDetailsPanel(final String id, final RoleTO roleTO, final boolean templateMode) { super(id);// www.j av a 2 s . c o m ownerContainer = new WebMarkupContainer("ownerContainer"); ownerContainer.setOutputMarkupId(true); this.add(ownerContainer); final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin"); userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal"); this.add(userOwnerSelectWin); final ModalWindow roleOwnerSelectWin = new ModalWindow("roleOwnerSelectWin"); roleOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); roleOwnerSelectWin.setCookieName("create-roleOwnerSelect-modal"); this.add(roleOwnerSelectWin); final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin"); parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); parentSelectWin.setCookieName("create-parentSelect-modal"); this.add(parentSelectWin); if (templateMode) { parentFragment = new Fragment("parent", "parentFragment", this); parentModel = new ParentModel(roleTO); @SuppressWarnings("unchecked") final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel); parent.setReadOnly(true); parent.setOutputMarkupId(true); parentFragment.add(parent); final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, ParentSelectPayload.class); } }); parentSelectWin.show(target); } }; parentFragment.add(parentSelect); final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentModel.setObject(null); target.add(parent); } }; parentFragment.add(parentReset); } else { parentFragment = new Fragment("parent", "emptyFragment", this); } parentFragment.setOutputMarkupId(true); this.add(parentFragment); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(roleTO, "key")); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); this.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { name.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } this.add(name); userOwnerModel = new OwnerModel(roleTO, AttributableType.USER); @SuppressWarnings("unchecked") final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel); userOwner.setReadOnly(true); userOwner.setOutputMarkupId(true); ownerContainer.add(userOwner); final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin); } }); userOwnerSelectWin.show(target); } }; ownerContainer.add(userOwnerSelect); final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerModel.setObject(null); target.add(userOwner); } }; ownerContainer.add(userOwnerReset); roleOwnerModel = new OwnerModel(roleTO, AttributableType.ROLE); @SuppressWarnings("unchecked") final AjaxTextFieldPanel roleOwner = new AjaxTextFieldPanel("roleOwner", "roleOwner", roleOwnerModel); roleOwner.setReadOnly(true); roleOwner.setOutputMarkupId(true); ownerContainer.add(roleOwner); final AjaxLink<Void> roleOwnerSelect = new IndicatingAjaxLink<Void>("roleOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, RoleOwnerSelectPayload.class); } }); parentSelectWin.show(target); } }; ownerContainer.add(roleOwnerSelect); final IndicatingAjaxLink<Void> roleOwnerReset = new IndicatingAjaxLink<Void>("roleOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { roleOwnerModel.setObject(null); target.add(roleOwner); } }; ownerContainer.add(roleOwnerReset); final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner", new PropertyModel<Boolean>(roleTO, "inheritOwner")); this.add(inhOwner); final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates", new PropertyModel<Boolean>(roleTO, "inheritTemplates")); inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rPlainAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rDerAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rVirAttrTemplates, target)); } }); this.add(inhTemplates); }
From source file:org.apache.syncope.client.console.panels.UserDetailsPanel.java
License:Apache License
public UserDetailsPanel(final String id, final UserTO userTO, final Form form, final boolean resetPassword, final boolean templateMode) { super(id);//from w w w . j av a 2 s. c om // ------------------------ // Username // ------------------------ final FieldPanel<String> username = new AjaxTextFieldPanel("username", "username", new PropertyModel<String>(userTO, "username")); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("usernameJexlHelp"); final AjaxLink<?> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "usernameQuestionMarkJexlHelp"); add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { username.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } add(username); // ------------------------ // ------------------------ // Password // ------------------------ final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("pwdJexlHelp"); final AjaxLink<?> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp, "pwdQuestionMarkJexlHelp"); add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); FieldPanel<String> password; Label confirmPasswordLabel = new Label("confirmPasswordLabel", new ResourceModel("confirmPassword")); FieldPanel<String> confirmPassword; if (templateMode) { password = new AjaxTextFieldPanel("password", "password", new PropertyModel<String>(userTO, "password")); confirmPasswordLabel.setVisible(false); confirmPassword = new AjaxTextFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); confirmPassword.setEnabled(false); confirmPassword.setVisible(false); } else { pwdQuestionMarkJexlHelp.setVisible(false); password = new AjaxPasswordFieldPanel("password", "password", new PropertyModel<String>(userTO, "password")); ((PasswordTextField) password.getField()).setResetPassword(resetPassword); confirmPassword = new AjaxPasswordFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); if (!resetPassword) { confirmPassword.getField().setModelObject(userTO.getPassword()); } ((PasswordTextField) confirmPassword.getField()).setResetPassword(resetPassword); form.add(new EqualPasswordInputValidator(password.getField(), confirmPassword.getField())); } add(password); add(confirmPasswordLabel); add(confirmPassword); final WebMarkupContainer mandatoryPassword = new WebMarkupContainer("mandatory_pwd"); mandatoryPassword.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { if (userTO.getKey() > 0) { tag.put("style", "display:none;"); } } }); add(mandatoryPassword); // ------------------------ }
From source file:org.apache.syncope.client.console.SyncopeApplication.java
License:Apache License
public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) { // Modal window for editing user profile final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal"); editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT); editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH); editProfileModalWin.setCookieName("edit-profile-modal"); page.add(editProfileModalWin);//from w w w . jav a 2 s . c om final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { final UserTO userTO; if (SyncopeSession.get().isAuthenticated()) { try { userTO = userSelfRestClient.read(); } catch (Exception e) { throw new WicketRuntimeException(e); } } else { userTO = new UserTO(); } editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO); } }); editProfileModalWin.show(target); } }; editProfileLink.add(new Label("username", SyncopeSession.get().getUsername())); if ("admin".equals(SyncopeSession.get().getUsername())) { editProfileLink.setEnabled(false); } page.add(editProfileLink); }
From source file:org.apache.syncope.console.pages.DerSchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, DerSchemaTO schema, final boolean createFlag) { if (schema == null) { schema = new DerSchemaTO(); }//ww w . j a va 2 s .c o m final Form<DerSchemaTO> schemaForm = new Form<DerSchemaTO>(FORM); schemaForm.setModel(new CompoundPropertyModel<DerSchemaTO>(schema)); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(schema, "name")); name.addRequiredLabel(); final AjaxTextFieldPanel expression = new AjaxTextFieldPanel("expression", getString("expression"), new PropertyModel<String>(schema, "expression")); expression.addRequiredLabel(); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); schemaForm.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); name.setEnabled(createFlag); 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) { DerSchemaTO schemaTO = (DerSchemaTO) form.getDefaultModelObject(); try { if (createFlag) { schemaRestClient.createDerSchema(kind, schemaTO); } else { schemaRestClient.updateDerSchema(kind, schemaTO); } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); String allowedRoles = createFlag ? xmlRolesReader.getAllAllowedRoles("Schema", "create") : xmlRolesReader.getAllAllowedRoles("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); schemaForm.add(name); schemaForm.add(expression); schemaForm.add(submit); schemaForm.add(cancel); add(schemaForm); }
From source file:org.apache.syncope.console.pages.Login.java
License:Apache License
public Login(final PageParameters parameters) { super(parameters); feedbackPanel = new NotificationPanel(Constants.FEEDBACK); add(feedbackPanel);/*from ww w . j a va 2 s . c o m*/ form = new Form<Void>("login"); userIdField = new TextField<String>("userId", new Model<String>()); userIdField.setMarkupId("userId"); form.add(userIdField); passwordField = new PasswordTextField("password", new Model<String>()); passwordField.setMarkupId("password"); form.add(passwordField); languageSelect = new LocaleDropDown("language"); form.add(languageSelect); AjaxButton submitButton = new AjaxButton("submit", new Model<String>(getString("submit"))) { private static final long serialVersionUID = 429178684321093953L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { try { if (anonymousUser.equals(userIdField.getRawInput())) { throw new AccessControlException("Illegal username"); } authenticate(userIdField.getRawInput(), passwordField.getRawInput()); setResponsePage(WelcomePage.class, parameters); } catch (AccessControlException e) { error(getString("login-error")); feedbackPanel.refresh(target); SyncopeSession.get().resetClients(); } } }; submitButton.setDefaultFormProcessing(false); form.add(submitButton); add(form); // Modal window for self registration final ModalWindow editProfileModalWin = new ModalWindow("selfRegModal"); editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editProfileModalWin.setInitialHeight(SELF_REG_WIN_HEIGHT); editProfileModalWin.setInitialWidth(SELF_REG_WIN_WIDTH); editProfileModalWin.setCookieName("self-reg-modal"); add(editProfileModalWin); Fragment selfRegFrag; if (userSelfRestClient.isSelfRegistrationAllowed()) { selfRegFrag = new Fragment("selfRegistration", "selfRegAllowed", this); final AjaxLink<Void> selfRegLink = new ClearIndicatingAjaxLink<Void>("link", getPageReference()) { private static final long serialVersionUID = -7978723352517770644L; @Override protected void onClickInternal(final AjaxRequestTarget target) { editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { // anonymous authentication needed for self-registration authenticate(anonymousUser, anonymousKey); return new UserSelfModalPage(Login.this.getPageReference(), editProfileModalWin, new UserTO()); } }); editProfileModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 251794406325329768L; @Override public void onClose(final AjaxRequestTarget target) { SyncopeSession.get().invalidate(); } }); editProfileModalWin.show(target); } }; selfRegLink.add(new Label("linkTitle", getString("selfRegistration"))); Panel panel = new LinkPanel("selfRegistration", new ResourceModel("selfRegistration")); panel.add(selfRegLink); selfRegFrag.add(panel); } else { selfRegFrag = new Fragment("selfRegistration", "selfRegNotAllowed", this); } add(selfRegFrag); }
From source file:org.apache.syncope.console.pages.panels.AttributesPanel.java
License:Apache License
public <T extends AbstractAttributableTO> AttributesPanel(final String id, final T entityTO, final Form form, final boolean templateMode, final AttrTemplatesPanel attrTemplates) { super(id);//w w w . j a va 2s . com this.entityTO = entityTO; this.templateMode = templateMode; this.attrTemplates = attrTemplates; this.setOutputMarkupId(true); setSchemas(); setAttrs(); final ListView<AttributeTO> attributeView = new AltListView<AttributeTO>("schemas", new PropertyModel<List<? extends AttributeTO>>(entityTO, "attrs")) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<AttributeTO> item) { final AttributeTO attributeTO = (AttributeTO) item.getDefaultModelObject(); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); item.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { questionMarkJexlHelp.setVisible(false); } item.add(new Label("name", attributeTO.getSchema())); final FieldPanel panel = getFieldPanel(schemas.get(attributeTO.getSchema()), form, attributeTO); if (templateMode || !schemas.get(attributeTO.getSchema()).isMultivalue()) { item.add(panel); } else { item.add(new MultiFieldPanel<String>("panel", new PropertyModel<List<String>>(attributeTO, "values"), panel)); } } }; add(attributeView); }
From source file:org.apache.syncope.console.pages.panels.ResourceMappingPanel.java
License:Apache License
/** * Attribute Mapping Panel.// w w w . ja v a 2s. c o m * * @param id panel id * @param resourceTO external resource * @param attrType USER / ROLE */ public ResourceMappingPanel(final String id, final ResourceTO resourceTO, final AttributableType attrType) { super(id); setOutputMarkupId(true); this.resourceTO = resourceTO; this.attrType = attrType; this.mappingContainer = new WebMarkupContainer("mappingContainer"); this.mappingContainer.setOutputMarkupId(true); add(this.mappingContainer); this.accountLinkContainer = new WebMarkupContainer("accountLinkContainer"); this.accountLinkContainer.setOutputMarkupId(true); add(this.accountLinkContainer); if (this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0) { schemaNames = getSchemaNames(this.resourceTO.getConnectorId(), this.resourceTO.getConnConfProperties()); setEnabled(); } else { schemaNames = Collections.<String>emptyList(); } final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); mappingContainer.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); final Label passwordLabel = new Label("passwordLabel", new ResourceModel("password")); mappingContainer.add(passwordLabel); if (AttributableType.USER != ResourceMappingPanel.this.attrType) { passwordLabel.setVisible(false); } Collections.sort(getMapping().getItems(), new Comparator<MappingItemTO>() { @Override public int compare(final MappingItemTO left, final MappingItemTO right) { int compared; if (left == null && right == null) { compared = 0; } else if (left == null) { compared = 1; } else if (right == null) { compared = -1; } else if (left.getPurpose() == MappingPurpose.BOTH && right.getPurpose() != MappingPurpose.BOTH) { compared = -1; } else if (left.getPurpose() != MappingPurpose.BOTH && right.getPurpose() == MappingPurpose.BOTH) { compared = 1; } else if (left.getPurpose() == MappingPurpose.PROPAGATION && (right.getPurpose() == MappingPurpose.SYNCHRONIZATION || right.getPurpose() == MappingPurpose.NONE)) { compared = -1; } else if (left.getPurpose() == MappingPurpose.SYNCHRONIZATION && right.getPurpose() == MappingPurpose.PROPAGATION) { compared = 1; } else if (left.getPurpose() == MappingPurpose.SYNCHRONIZATION && right.getPurpose() == MappingPurpose.NONE) { compared = -1; } else if (left.getPurpose() == MappingPurpose.NONE && right.getPurpose() != MappingPurpose.NONE) { compared = 1; } else if (left.isAccountid()) { compared = -1; } else if (right.isAccountid()) { compared = 1; } else if (left.isPassword()) { compared = -1; } else if (right.isPassword()) { compared = 1; } else { compared = left.getIntAttrName().compareTo(right.getIntAttrName()); } return compared; } }); mappings = new ListView<MappingItemTO>("mappings", getMapping().getItems()) { private static final long serialVersionUID = 4949588177564901031L; @Override protected void populateItem(final ListItem<MappingItemTO> item) { final MappingItemTO mapItem = item.getModelObject(); if (mapItem.getPurpose() == null) { mapItem.setPurpose(MappingPurpose.BOTH); } AttributableType entity = null; if (mapItem.getIntMappingType() != null) { entity = mapItem.getIntMappingType().getAttributableType(); } final List<IntMappingType> attrTypes = new ArrayList<IntMappingType>(getAttributeTypes(entity)); item.add(new AjaxDecoratedCheckbox("toRemove", new Model<Boolean>(Boolean.FALSE)) { private static final long serialVersionUID = 7170946748485726506L; @Override protected void onUpdate(final AjaxRequestTarget target) { int index = -1; for (int i = 0; i < getMapping().getItems().size() && index == -1; i++) { if (mapItem.equals(getMapping().getItems().get(i))) { index = i; } } if (index != -1) { getMapping().getItems().remove(index); item.getParent().removeAll(); target.add(ResourceMappingPanel.this); } } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { 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); } }); final AjaxDropDownChoicePanel<String> intAttrNames = new AjaxDropDownChoicePanel<String>( "intAttrNames", getString("intAttrNames"), new PropertyModel<String>(mapItem, "intAttrName"), false); intAttrNames.setChoices(schemaNames); intAttrNames.setRequired(true); intAttrNames.setStyleSheet(FIELD_STYLE); intAttrNames.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); item.add(intAttrNames); final AjaxDropDownChoicePanel<IntMappingType> intMappingTypes = new AjaxDropDownChoicePanel<IntMappingType>( "intMappingTypes", new ResourceModel("intMappingTypes", "intMappingTypes").getObject(), new PropertyModel<IntMappingType>(mapItem, "intMappingType")); intMappingTypes.setRequired(true); intMappingTypes.setChoices(attrTypes); intMappingTypes.setStyleSheet(FIELD_STYLE); item.add(intMappingTypes); final AjaxDropDownChoicePanel<AttributableType> entitiesPanel = new AjaxDropDownChoicePanel<AttributableType>( "entities", new ResourceModel("entities", "entities").getObject(), new Model<AttributableType>(entity)); entitiesPanel.setChoices(attrType == AttributableType.ROLE ? Collections.<AttributableType>singletonList(AttributableType.ROLE) : Arrays.asList(AttributableType.values())); entitiesPanel.setStyleSheet(DEF_FIELD_STYLE); entitiesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { attrTypes.clear(); attrTypes.addAll(getAttributeTypes(entitiesPanel.getModelObject())); intMappingTypes.setChoices(attrTypes); intAttrNames.setChoices(Collections.<String>emptyList()); target.add(intMappingTypes.getField()); target.add(intAttrNames.getField()); } }); item.add(entitiesPanel); final FieldPanel<String> extAttrNames = new AjaxTextFieldPanel("extAttrName", new ResourceModel("extAttrNames", "extAttrNames").getObject(), new PropertyModel<String>(mapItem, "extAttrName")); ((AjaxTextFieldPanel) extAttrNames).setChoices(schemaNames); boolean required = false; boolean accountIdOrPassword = mapItem.isAccountid() || mapItem.isPassword(); if (accountIdOrPassword) { ((AjaxTextFieldPanel) extAttrNames).setModelObject(null); } else { required = true; } extAttrNames.setRequired(required); extAttrNames.setEnabled(required); extAttrNames.setStyleSheet(FIELD_STYLE); item.add(extAttrNames); final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel("mandatoryCondition", new ResourceModel("mandatoryCondition", "mandatoryCondition").getObject(), new PropertyModel<String>(mapItem, "mandatoryCondition")); mandatory.setChoices(Arrays.asList(new String[] { "true", "false" })); mandatory.setStyleSheet(SHORT_FIELD_STYLE); item.add(mandatory); final AjaxCheckBoxPanel accountId = new AjaxCheckBoxPanel("accountId", new ResourceModel("accountId", "accountId").getObject(), new PropertyModel<Boolean>(mapItem, "accountid")); accountId.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { extAttrNames.setEnabled(!accountId.getModelObject() && !mapItem.isPassword()); extAttrNames.setModelObject(null); extAttrNames.setRequired(!accountId.getModelObject()); target.add(extAttrNames); if (accountId.getModelObject()) { mapItem.setMandatoryCondition("true"); mandatory.setEnabled(false); } else { mapItem.setMandatoryCondition("false"); mandatory.setEnabled(true); } target.add(mandatory); } }); item.add(accountId); final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel("password", new ResourceModel("password", "password").getObject(), new PropertyModel<Boolean>(mapItem, "password")); password.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { extAttrNames.setEnabled(!mapItem.isAccountid() && !password.getModelObject()); extAttrNames.setModelObject(null); extAttrNames.setRequired(!password.getModelObject()); target.add(extAttrNames); setAccountId(intMappingTypes.getModelObject(), accountId, password); target.add(accountId); } }); item.add(password); if (AttributableType.USER != ResourceMappingPanel.this.attrType) { password.setVisible(false); } final WebMarkupContainer purpose = new WebMarkupContainer("purpose"); purpose.setOutputMarkupId(Boolean.TRUE); final MappingPurposePanel panel = new MappingPurposePanel("purposeActions", new PropertyModel<MappingPurpose>(mapItem, "purpose"), purpose); purpose.add(panel); item.add(purpose); intMappingTypes.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { setAttrNames(intMappingTypes.getModelObject(), intAttrNames); target.add(intAttrNames); setAccountId(intMappingTypes.getModelObject(), accountId, password); target.add(accountId); } }); setAttrNames(mapItem.getIntMappingType(), intAttrNames); setAccountId(mapItem.getIntMappingType(), accountId, password); } }; mappings.setReuseItems(true); mappingContainer.add(mappings); addMappingBtn = new IndicatingAjaxButton("addMappingBtn", new ResourceModel("add")) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { getMapping().getItems().add(new MappingItemTO()); target.add(ResourceMappingPanel.this); } }; addMappingBtn.setDefaultFormProcessing(false); addMappingBtn.setEnabled(this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0); mappingContainer.add(addMappingBtn); boolean accountLinkEnabled = false; if (getMapping().getAccountLink() != null) { accountLinkEnabled = true; } accountLinkCheckbox = new AjaxCheckBoxPanel("accountLinkCheckbox", new ResourceModel("accountLinkCheckbox", "accountLinkCheckbox").getObject(), new Model<Boolean>(Boolean.valueOf(accountLinkEnabled))); accountLinkCheckbox.setEnabled(true); accountLinkContainer.add(accountLinkCheckbox); final AjaxTextFieldPanel accountLink = new AjaxTextFieldPanel("accountLink", new ResourceModel("accountLink", "accountLink").getObject(), new PropertyModel<String>(getMapping(), "accountLink")); accountLink.setEnabled(accountLinkEnabled); accountLinkContainer.add(accountLink); accountLinkCheckbox.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (accountLinkCheckbox.getModelObject()) { accountLink.setEnabled(Boolean.TRUE); accountLink.setModelObject(""); } else { accountLink.setEnabled(Boolean.FALSE); accountLink.setModelObject(""); } target.add(accountLink); } }); }
From source file:org.apache.syncope.console.pages.panels.RoleDetailsPanel.java
License:Apache License
public RoleDetailsPanel(final String id, final RoleTO roleTO, final boolean templateMode) { super(id);//from w w w. j a v a 2 s . c o m ownerContainer = new WebMarkupContainer("ownerContainer"); ownerContainer.setOutputMarkupId(true); this.add(ownerContainer); final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin"); userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal"); this.add(userOwnerSelectWin); final ModalWindow roleOwnerSelectWin = new ModalWindow("roleOwnerSelectWin"); roleOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); roleOwnerSelectWin.setCookieName("create-roleOwnerSelect-modal"); this.add(roleOwnerSelectWin); final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin"); parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); parentSelectWin.setCookieName("create-parentSelect-modal"); this.add(parentSelectWin); if (templateMode) { parentFragment = new Fragment("parent", "parentFragment", this); parentModel = new ParentModel(roleTO); @SuppressWarnings("unchecked") final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel); parent.setReadOnly(true); parent.setOutputMarkupId(true); parentFragment.add(parent); final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, ParentSelectPayload.class); } }); parentSelectWin.show(target); } }; parentFragment.add(parentSelect); final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentModel.setObject(null); target.add(parent); } }; parentFragment.add(parentReset); } else { parentFragment = new Fragment("parent", "emptyFragment", this); } parentFragment.setOutputMarkupId(true); this.add(parentFragment); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(roleTO, "name")); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); this.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { name.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } this.add(name); userOwnerModel = new OwnerModel(roleTO, AttributableType.USER); @SuppressWarnings("unchecked") final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel); userOwner.setReadOnly(true); userOwner.setOutputMarkupId(true); ownerContainer.add(userOwner); final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin); } }); userOwnerSelectWin.show(target); } }; ownerContainer.add(userOwnerSelect); final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerModel.setObject(null); target.add(userOwner); } }; ownerContainer.add(userOwnerReset); roleOwnerModel = new OwnerModel(roleTO, AttributableType.ROLE); @SuppressWarnings("unchecked") final AjaxTextFieldPanel roleOwner = new AjaxTextFieldPanel("roleOwner", "roleOwner", roleOwnerModel); roleOwner.setReadOnly(true); roleOwner.setOutputMarkupId(true); ownerContainer.add(roleOwner); final AjaxLink<Void> roleOwnerSelect = new IndicatingAjaxLink<Void>("roleOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin, RoleOwnerSelectPayload.class); } }); parentSelectWin.show(target); } }; ownerContainer.add(roleOwnerSelect); final IndicatingAjaxLink<Void> roleOwnerReset = new IndicatingAjaxLink<Void>("roleOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { roleOwnerModel.setObject(null); target.add(roleOwner); } }; ownerContainer.add(roleOwnerReset); final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner", new PropertyModel<Boolean>(roleTO, "inheritOwner")); this.add(inhOwner); final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates", new PropertyModel<Boolean>(roleTO, "inheritTemplates")); inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rDerAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rVirAttrTemplates, target)); } }); this.add(inhTemplates); }
From source file:org.apache.syncope.console.pages.panels.UserDetailsPanel.java
License:Apache License
public UserDetailsPanel(final String id, final UserTO userTO, final Form form, final boolean resetPassword, final boolean templateMode) { super(id);/*from w w w. j a va 2s . c o m*/ // ------------------------ // Username // ------------------------ final FieldPanel<String> username = new AjaxTextFieldPanel("username", "username", new PropertyModel<String>(userTO, "username")); final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("usernameJexlHelp"); final AjaxLink<?> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "usernameQuestionMarkJexlHelp"); add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { username.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } add(username); // ------------------------ // ------------------------ // Password // ------------------------ final WebMarkupContainer pwdJexlHelp = JexlHelpUtil.getJexlHelpWebContainer("pwdJexlHelp"); final AjaxLink<?> pwdQuestionMarkJexlHelp = JexlHelpUtil.getAjaxLink(pwdJexlHelp, "pwdQuestionMarkJexlHelp"); add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); FieldPanel<String> password; Label confirmPasswordLabel = new Label("confirmPasswordLabel", new ResourceModel("confirmPassword")); FieldPanel<String> confirmPassword; if (templateMode) { password = new AjaxTextFieldPanel("password", "password", new PropertyModel<String>(userTO, "password")); confirmPasswordLabel.setVisible(false); confirmPassword = new AjaxTextFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); confirmPassword.setEnabled(false); confirmPassword.setVisible(false); } else { pwdQuestionMarkJexlHelp.setVisible(false); password = new AjaxPasswordFieldPanel("password", "password", new PropertyModel<String>(userTO, "password")); password.setRequired(userTO.getId() == 0); ((PasswordTextField) password.getField()).setResetPassword(resetPassword); confirmPassword = new AjaxPasswordFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); if (!resetPassword) { confirmPassword.getField().setModelObject(userTO.getPassword()); } confirmPassword.setRequired(userTO.getId() == 0); ((PasswordTextField) confirmPassword.getField()).setResetPassword(resetPassword); form.add(new EqualPasswordInputValidator(password.getField(), confirmPassword.getField())); } add(password); add(confirmPasswordLabel); add(confirmPassword); final WebMarkupContainer mandatoryPassword = new WebMarkupContainer("mandatory_pwd"); mandatoryPassword.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { if (userTO.getId() > 0) { tag.put("style", "display:none;"); } } }); add(mandatoryPassword); // ------------------------ }