コード例 #1
0
 protected void onSubmitForm() {
   String valueName = HtmlSanitizer.sanitize(modelName.getObject());
   Collection<UserRoles> newRoles = modelRoles.getObject();
   _user.setName(valueName);
   String password = modelPassword1.getObject();
   try {
     facade.createIdentity(selectedProvider, valueName, password, null, newRoles);
     setResponsePage(UserOverviewPage.class);
   } catch (UserExistsException e) {
     error(e.getMessage());
   }
 }
コード例 #2
0
  @Override
  protected void onInitialize() {
    super.onInitialize();
    InjectorHolder.getInjector().inject(this);
    modelName.setObject(_user.getName());
    addFeedback(this, "feedback");

    Form<String> form =
        new Form<String>("form") {
          @Override
          protected void onSubmit() {
            onSubmitForm();
          }
        };

    Button cancel =
        new Button("cancel") {
          public void onSubmit() {
            setResponsePage(UserOverviewPage.class);
          }
        };
    cancel.setDefaultFormProcessing(false);
    form.add(cancel);

    addTextInputField(form, "username", modelName, true);
    form.add(new PasswordTextField("password1", modelPassword1));
    form.add(new PasswordTextField("password2", modelPassword2));

    form.add(new Button("submit"));

    List<UserRoles> current = new ArrayList<UserRoles>();
    current.add(UserRoles.NONE);
    modelRoles = new MyModel(current);

    List<? extends UserRoles> choices = UserRoles.asList();
    ListMultipleChoice<UserRoles> roleSelect =
        new ListMultipleChoice<UserRoles>("roleSelect", modelRoles, choices);
    form.add(roleSelect);

    List<String> providers = facade.availableProviders();
    selectedProvider = providers.get(0);
    ListChoice<String> providerSelect =
        new ListChoice<String>(
            "providerSelect", new PropertyModel<String>(this, "selectedProvider"), providers);
    form.add(providerSelect);
    add(form);
  }