Java Code Examples for org.apache.wicket.markup.html.form.Button

The following are top voted examples for showing how to use org.apache.wicket.markup.html.form.Button. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Unicorn   File: LoginPage.java   Source Code and License 6 votes vote down vote up
private void addLoginButton() {
	final Button applyButton = new Button("loginButton") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit() {
			final String email = LoginPage.this.emailInput.getValue();
			final String password = LoginPage.this.passwordInput.getValue();
			if (LoginPage.this.login(email, password)) {
				this.setResponsePage(LoginPage.class);
			}
		}

	};
	this.loginForm.add(applyButton);
}
 
Example 2
Project: Intercloud   File: LoginPanel.java   Source Code and License 6 votes vote down vote up
public LoginForm(String markupId) {
    super(markupId);
    this.setDefaultModel(new CompoundPropertyModel<Object>(this));

    this.add(new TextField("username").setRequired(true));
    this.add(new PasswordTextField("password").setRequired(true));

    Button submitBtn = new AjaxButton("loginBtn", Model.of("Sign In")) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (AuthenticatedWebSession.get().signIn(username, password))
                setResponsePage(DiscoverItemsPage.class);
            else {
                target.add(ComponentUtils.displayBlock(alert));
            }
        }
    };
    this.add(submitBtn);
    this.setDefaultButton(submitBtn);
}
 
Example 3
Project: openmeetings   File: MessagesContactsPanel.java   Source Code and License 6 votes vote down vote up
private void selectMessage(long id, AjaxRequestTarget target) {
	PrivateMessage msg = getBean(PrivateMessageDao.class).get(id);
	selectedMessage.addOrReplace(new Label("from", msg == null ? "" : getEmail(msg.getFrom())));
	selectedMessage.addOrReplace(new Label("to", msg == null ? "" : getEmail(msg.getTo())));
	selectedMessage.addOrReplace(new Label("subj", msg == null ? "" : msg.getSubject()));
	selectedMessage.addOrReplace(new Label("body", msg == null ? "" : msg.getMessage()).setEscapeModelStrings(false));
	if (msg != null) {
		Room r = msg.getRoom();
		if (r != null) {
			Appointment a = getBean(AppointmentDao.class).getByRoom(r.getId());
			roomContainer.addOrReplace(new Label("start", a == null ? "" : getDateFormat().format(a.getStart())));
			roomContainer.addOrReplace(new Label("end", a == null ? "" : getDateFormat().format(a.getEnd())));
			roomContainer.addOrReplace(new Button("enter").add(new RoomEnterBehavior(r.getId())));
		}
		roomContainer.setVisible(r != null);
	}
	if (target != null) {
		target.add(selectedMessage);
		updateControls(target);
	}
}
 
Example 4
Project: superfly   File: ConfirmPanel.java   Source Code and License 6 votes vote down vote up
public ConfirmPanel(final String id, String message) {
    super(id);
    Form cform = new Form("cform");
    cform.add(new Label("message", message));
    cform.add(new Button("confirm") {
        @Override
        public void onSubmit() {
            onConfirm();
        }
    });
    cform.add(new Button("cancel") {
        @Override
        public void onSubmit() {
            ConfirmPanel.this.setVisible(false);
        }
    });
    add(cform);
}
 
Example 5
Project: superfly   File: EditRolePage.java   Source Code and License 6 votes vote down vote up
public EditRolePage(PageParameters parameters) {
    super(ListRolesPage.class, parameters);
     long roleId = parameters.get("id").toLong(-1L);
     final UIRole role  = roleService.getRole(roleId);
     setDefaultModel(new CompoundPropertyModel<UIRole>(role));
     Form form = new Form("form"){

        @Override
        protected void onSubmit() {
        roleService.updateRole(role);
        setResponsePage(ListRolesPage.class);
        }

     };
     add(form);
     form.add(new LabelValueRow<String>("role-name", new Model<String>(role.getRoleName()), "role.create.name"));
     form.add(new LabelTextFieldRow<String>(role, "principalName", "role.create.principal-name", true));
     form.add(new Button("form-submit"));
     form.add(new BookmarkablePageLink<Page>("form-cancel", ListRolesPage.class));
}
 
Example 6
Project: directory-fortress-commander   File: LoginPage.java   Source Code and License 6 votes vote down vote up
public LoginPageForm( String id )
{
    super( id );
    HttpServletRequest servletReq = ( HttpServletRequest ) getRequest().getContainerRequest();
    Principal principal = servletReq.getUserPrincipal();
    if ( principal != null )
    {
        LOG.info( "user already logged in, route to launch page instead" );
        setResponsePage( LaunchPage.class );
    }
    add( new Button( "login" ) );
    TextField userId = new TextField( "userId", new PropertyModel<String>( this, "userId" ) );
    add( userId );
    PasswordTextField pw = new PasswordTextField( "pswdField", new PropertyModel<String>( this, "pswdField" ) );
    pw.setRequired( false );
    add( pw );
}
 
Example 7
Project: ontopia   File: ModalInstancePage.java   Source Code and License 6 votes vote down vote up
public ModalInstancePage(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) {
  super(id);
  this.topicModel = topicModel;
  this.topicTypeModel = topicTypeModel;
  this.fieldsViewModel = fieldsViewModel;
  
  // page is read-only if topic type is read-only
  this.isReadOnly = ((topicTypeModel != null && topicTypeModel.getTopicType().isReadOnly()) || (Objects.equals(getRequest().getParameter("ro"), "true")));

  this.popupContent = new WebMarkupContainer("popupContent");
  popupContent.setOutputMarkupId(true);
  add(popupContent);
  
  popupContent.add(createInstancePanel("instancePanel"));
  
  Button closeOkButton = new Button("closeOK");
  closeOkButton.add(new AjaxFormComponentUpdatingBehavior("onclick") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      onCloseOk(target);
    }
  });
  popupContent.add(closeOkButton);
}
 
Example 8
Project: ontopia   File: AssociationTransformFunctionBoxPanel.java   Source Code and License 6 votes vote down vote up
public AssociationTransformFunctionBoxPanel(String id, final TopicModel<Topic> topicModel) {
  super(id);
  add(new Label("title", new ResourceModel("transform.association.instances")));   
  
  Button addButton = new Button("button", new ResourceModel("transform"));
  addButton.add(new AjaxFormComponentUpdatingBehavior("onclick") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      Topic instance = topicModel.getTopic();
      Map<String,String> pageParametersMap = new HashMap<String,String>();
      pageParametersMap.put("topicMapId", instance.getTopicMap().getId());
      pageParametersMap.put("topicId", instance.getId());
      setResponsePage(AssociationTransformPage.class, new PageParameters(pageParametersMap));
    }          
  });
  add(addButton);
}
 
Example 9
Project: edemocracia   File: EdicaoArtigoPage.java   Source Code and License 6 votes vote down vote up
/**
 * Exclui um artigo
 */
private void initExcluirButton() {
	Button btn = new Button("excluir") {
		@Override
		public void onSubmit() {
			try {
				WikiLegisServiceUtil.excluiArtigo(EdicaoArtigoPage.this.getModelObject().getArtigoId());
			} catch (Exception e) {
				LOG.error("Erro ao excluir artigo", e);
			}
			setResponsePage(HomePage.class);
			setRedirect(true);
		}
	};
	btn.setDefaultFormProcessing(false);
	form.add(btn);
}
 
Example 10
Project: nocket   File: Kunde_KartePanel.java   Source Code and License 6 votes vote down vote up
public Kunde_KartePanel(String id, IModel<?> model) {
    super(id, model);
    GeneratedBinding generatedBinding = new GeneratedBinding(this);
    generatedBinding.withInterceptors(new BindingInterceptor() {
        @Override
        public Component createButton(ButtonElement e) {
            if (e.getWicketId().equals(Kunde_KarteConstants.pruefen)) {
                Button button = new GeneratedButton(e) {
                    @Override
                    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                        super.onSubmit(target, form);
                        System.err.println("Button call intercepted");
                    }
                };
                return button;

            }
            return super.createButton(e);
        }
    });
    generatedBinding.bind();
}
 
Example 11
Project: gradebookNG   File: GradeImportUploadStep.java   Source Code and License 6 votes vote down vote up
public UploadForm(String id) {
            super(id);

            setMultiPart(true);
            setMaxSize(Bytes.megabytes(2));

            fileUploadField = new FileUploadField("upload");
            add(fileUploadField);

            add(new Button("continuebutton"));

            Button cancel = new Button("cancelbutton"){
                public void onSubmit() {
//                    info("Cancel was pressed!");
                    setResponsePage(new GradebookPage());
                }
            };
            cancel.setDefaultFormProcessing(false);
            add(cancel);
        }
 
Example 12
Project: wicket-notes-demo   File: LoginPage.java   Source Code and License 6 votes vote down vote up
public LoginPage() {
	final Form<User> form = new Form<User>("loginForm",
			new CompoundPropertyModel<User>(user));
	TextField<String> nameField = new TextField<String>(User.NAME);
	form.add(nameField);
	PasswordTextField passwordField = new PasswordTextField(User.PASSWORD);
	form.add(passwordField);

	Button submit = new Button("loginButton") {
		@Override
		public void onSubmit() {
			User dbUser = userDAO.findByUsername(user.getName());
			if (dbUser != null
					&& dbUser.getPassword().equals(user.getPassword())) {
				LoginPage.this.getSession().setUser(dbUser);
				setResponsePage(NotesPage.class);
			} else {
				form.error("Invalid login");
			}
		};
	};
	submit.add(new ButtonBehavior());
	form.add(submit);
	add(form);
}
 
Example 13
Project: oodt   File: TypeBrowser.java   Source Code and License 6 votes vote down vote up
/**
 * @param id
 *          The wicket:id component ID of this form.
 */
public AddCriteriaForm(String id) {
  super(id, new CompoundPropertyModel<ElementCrit>(new ElementCrit()));
  List<Element> ptypeElements = fm.safeGetElementsForProductType(type);
  Collections.sort(ptypeElements, new Comparator<Element>() {
    public int compare(Element e1, Element e2) {
      return e1.getElementName().compareTo(e2.getElementName());
    }
  });

  add(new DropDownChoice<Element>("criteria_list", new PropertyModel(
      getDefaultModelObject(), "elem"), new ListModel<Element>(
      ptypeElements), new ChoiceRenderer<Element>("elementName",
      "elementId")));
  add(new TextField<TermQueryCriteria>(
      "criteria_form_add_element_value",
      new PropertyModel<TermQueryCriteria>(getDefaultModelObject(), "value")));
  add(new Button("criteria_elem_add"));
}
 
Example 14
Project: old-blog   File: SettingEditPage.java   Source Code and License 6 votes vote down vote up
public EditForm(String id, final IModel<Setting> setting) {
	super(id, new CompoundPropertyModel<Setting>(setting));
	add(new LocalFeedbackPanel("feedback", this));
	value = new RequiredTextField<String>("value");
	value.add(new SettingValidator(setting.getObject().getName()));
	add(value);
	add(new Button("save") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit() {
			if (!value.hasErrorMessage()) {
				BlogServiceHolder.get().updateSetting(EditForm.this.getModelObject());
				getSession().info("Setting saved");
				setRedirect(true);
				setResponsePage(SettingsPage.class);
			}
		}
	});
	add(new CancelButton("cancel", SettingsPage.class));
}
 
Example 15
Project: old-blog   File: LoginPage.java   Source Code and License 6 votes vote down vote up
public LoginForm(String id) {
	super(id, new CompoundPropertyModel<LoginFormModel>(new LoginFormModel()));
	
	add(new LocalFeedbackPanel("feedback", this));
	add(new PasswordTextField("password"));
	add(new Button("submit") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit() {
			if (BlogServiceHolder.get().isOwnerPasswordMatch(LoginForm.this.getModelObject().getPassword())) {
				((BlogSession) getSession()).setAuthenticated(true);
				setResponsePage(IndexPage.class);
			} else {
				error("Wrong password");
			}
		}
	});
}
 
Example 16
Project: projectforge-webapp   File: AdminForm.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
private MyButtonPanel(final String id, final String i18nKey)
{
  button = new Button(SingleButtonPanel.WICKET_ID, new Model<String>()) {
    @Override
    public final void onSubmit()
    {
      MyButtonPanel.this.onSubmit();
    }

    /**
     * @see org.apache.wicket.Component#isVisible()
     */
    @Override
    public boolean isVisible()
    {
      return MyButtonPanel.this.isVisible();
    }
  };
  buttonPanel = new SingleButtonPanel(id, button, getString("system.admin.button." + i18nKey), SingleButtonPanel.NORMAL);
  WicketUtils.addTooltip(button, getString("system.admin.button." + i18nKey + ".tooltip"));
}
 
Example 17
Project: projectforge-webapp   File: UserEditForm.java   Source Code and License 6 votes vote down vote up
public static void createLastLoginAndDeleteAllStayLogins(final GridBuilder gridBuilder, final PFUserDO user, final UserDao userDao,
    final Form< ? > form)
{
  // Last login and deleteAllStayLoggedInSessions
  final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString("login.lastLogin")).suppressLabelForWarning();
  fs.add(new DivTextPanel(fs.newChildId(), DateTimeFormatter.instance().getFormattedDateTime(user.getLastLogin())));
  @SuppressWarnings("serial")
  final Button button = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("invalidateStayLoggedInSessions")) {
    @Override
    public final void onSubmit()
    {
      userDao.renewStayLoggedInKey(user.getId());
      form.error(getString("login.stayLoggedIn.invalidateAllStayLoggedInSessions.successfullDeleted"));
    }
  };
  fs.add(new SingleButtonPanel(fs.newChildId(), button, gridBuilder.getString("login.stayLoggedIn.invalidateAllStayLoggedInSessions"),
      SingleButtonPanel.DANGER));
  WicketUtils.addTooltip(button, gridBuilder.getString("login.stayLoggedIn.invalidateAllStayLoggedInSessions.tooltip"));
}
 
Example 18
Project: projectforge-webapp   File: TaskListForm.java   Source Code and License 6 votes vote down vote up
@Override
protected void init()
{
  super.init();
  // Task tree view
  @SuppressWarnings("serial")
  final Button taskTreeButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("listView")) {
    @Override
    public final void onSubmit()
    {
      parentPage.onTreeViewSubmit();
    }
  };
  actionButtons.add(2, new SingleButtonPanel(actionButtons.newChildId(), taskTreeButton, getString("task.tree.perspective"),
      SingleButtonPanel.NORMAL));
}
 
Example 19
Project: projectforge-webapp   File: IconButtonPanel.java   Source Code and License 6 votes vote down vote up
/**
 * @param string
 * @return
 */
protected Button createButton(final String string)
{
  return new Button("button") {
    private static final long serialVersionUID = 1L;

    /**
     * @see org.apache.wicket.markup.html.form.Button#onSubmit()
     */
    @Override
    public void onSubmit()
    {
      IconButtonPanel.this.onSubmit();
    }

    /**
     * @see org.apache.wicket.Component#isVisible()
     */
    @Override
    public boolean isVisible()
    {
      return IconButtonPanel.this.isButtonVisible();
    }
  };
}
 
Example 20
Project: projectforge-webapp   File: AbstractEditForm.java   Source Code and License 6 votes vote down vote up
/**
 * Adds a clone button (only if the data isn't new) and calls {@link AbstractEditPage#cloneData()}.
 */
@SuppressWarnings("serial")
protected void addCloneButton() {
  if (isNew() == false) {
    // Clone button for existing and not deleted invoices:
    final Button cloneButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("clone")) {
      @Override
      public final void onSubmit()
      {
        parentPage.cloneData();
      }
    };
    final SingleButtonPanel cloneButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), cloneButton, getString("clone")) {
      /**
       * @see org.apache.wicket.Component#isVisible()
       */
      @Override
      public boolean isVisible()
      {
        return isNew() == false;
      }
    };
    actionButtons.add(2, cloneButtonPanel);
  }

}
 
Example 21
Project: projectforge-webapp   File: AbstractImportForm.java   Source Code and License 6 votes vote down vote up
/**
 * @return this for chaining.
 */
@SuppressWarnings("serial")
protected AbstractImportForm<F, P, S> addClearButton(final FieldsetPanel fs)
{
  fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("clearStorage")) {
    @Override
    public final void onSubmit()
    {
      parentPage.clear();
    }
  }, getString("common.import.clearStorage"), SingleButtonPanel.RESET) {
    /**
     * @see org.apache.wicket.Component#isVisible()
     */
    @Override
    public boolean isVisible()
    {
      return storagePanel.isVisible();
    }
  });
  return this;
}
 
Example 22
Project: projectforge-webapp   File: SkillListForm.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListForm#init()
 */
@Override
protected void init()
{
  super.init();
  final Button skillTreeButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("treeView")) {
    private static final long serialVersionUID = -8763718088111525575L;

    @Override
    public void onSubmit() {
      parentPage.onTreeViewSubmit();
    }
  };
  actionButtons.add(2, new SingleButtonPanel(actionButtons.newChildId(), skillTreeButton, "Tree View",
      SingleButtonPanel.NORMAL));
}
 
Example 23
Project: Jouve-Project   File: AdvancedSearchPanel.java   Source Code and License 6 votes vote down vote up
private Button newAddRuleButton(final SimpleSearch clonedSimpleSearch,
		final SearchRule rule) {
	Button addRule = new Button("addRule");
	
	SearchRule addedSearchRule;
	
	if (rule instanceof TextSearchRule) {
		addedSearchRule = rule.cloneRule();
	} else {
		addedSearchRule = SearchRulesFactory.getDefaultSearchRule();
	}
	
	String url = getAddRuleUrl(clonedSimpleSearch, rule, addedSearchRule);
	addRule.add(new SimpleAttributeModifier("name", "addRule"));
	addRule.add(new SimpleAttributeModifier("onclick", url));
	return addRule;
}
 
Example 24
Project: ansible-docker-talk   File: NewPersonForm.java   Source Code and License 5 votes vote down vote up
public NewPersonForm(String id, IModel<Person> model) {
    super(id, model);
    add(new TextField<String>("firstName"));
    add(new TextField<String>("lastName"));
     add(new TextField<String>("jobTitle"));
    add(new Button("submitButton"));

}
 
Example 25
Project: singular-server   File: HistoryPage.java   Source Code and License 5 votes vote down vote up
private IFunction<String, Button> viewFormButton(final FormVersionHistoryEntity formVersionHistoryEntity) {
    final String url = DispatcherPageUtil
            .baseURL(getBaseUrl())
            .formAction(FormAction.FORM_ANALYSIS_VIEW.getId())
            .requirementId(null)
            .param(FORM_NAME, formVersionHistoryEntity.getFormVersion().getFormEntity().getFormType().getAbbreviation())
            .param(FORM_VERSION_KEY, formVersionHistoryEntity.getCod().getCodFormVersion())
            .build();
    return id -> new Button(id) {
        @Override
        protected String getOnClickScript() {
            return ";var newtab = window.open('" + url + "'); newtab.opener=null;";
        }
    };
}
 
Example 26
Project: Unicorn   File: LoginPage.java   Source Code and License 5 votes vote down vote up
private void addLogoutButton() {
	final Button applyButton = new BlockingAjaxButton("logoutButton", this.logoutForm) {
		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
			super.onSubmit(target, form);
			this.getSession().invalidate();
			this.setResponsePage(MainPage.class);
		}

	};
	this.logoutForm.add(applyButton);
}
 
Example 27
Project: Unicorn   File: TransformationPage.java   Source Code and License 5 votes vote down vote up
private void buildOpenEventTypeEditorButton() {
	final Button openEventTypeEditorButton = new Button("openEventTypeEditorButton") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit() {
			this.setResponsePage(EventTypeEditor.class);
		}
	};
	final Form<Void> layoutForm = new Form<Void>("layoutForm");
	this.add(layoutForm);
	layoutForm.add(openEventTypeEditorButton);
}
 
Example 28
Project: Unicorn   File: WarnOnExitForm.java   Source Code and License 5 votes vote down vote up
@Override
public MarkupContainer add(final Component... childs) {
	super.add(childs);
	for (final Component component : childs) {
		if (component instanceof Button) {
			component.add(new AttributeAppender("onclick", new Model("dontConfirm()"), ";"));
		} else if (component instanceof FormComponent) {
			component.add(new AttributeAppender("onChange", new Model("setDirty()"), ";"));
		}
	}
	return this;
}
 
Example 29
Project: Unicorn   File: DeleteButtonPanel.java   Source Code and License 5 votes vote down vote up
public DeleteButtonPanel(final String id, final Button button) throws Exception {
	super(id);
	final Form<Void> form = new Form<Void>("form");
	if (button.getId().equals("button")) {
		form.add(button);
	} else {
		throw new Exception("Button-id needs to be 'button'!");
	}
	this.add(form);

}
 
Example 30
Project: Unicorn   File: DataTableButtonPanel.java   Source Code and License 5 votes vote down vote up
public DataTableButtonPanel(final String id, final Button button) throws Exception {
	super(id);
	final Form<Void> form = new Form<Void>("form");
	if (button.getId().equals("button")) {
		form.add(button);
	} else {
		throw new Exception("Button-id needs to be 'button'!");
	}
	this.add(form);

}
 
Example 31
Project: invesdwin-nowicket   File: LoginButtonsChildPanel.java   Source Code and License 5 votes vote down vote up
public LoginButtonsChildPanel(final String id, final IModel<LoginButtonsChild> model, final boolean addBtnClasses) {
    super(id, model);
    new GeneratedBinding(this).bind();
    setRenderBodyOnly(true);
    if (addBtnClasses) {
        visitChildren(Button.class, new IVisitor<Button, Void>() {
            @Override
            public void component(final Button object, final IVisit<Void> visit) {
                object.add(AttributeModifier.append("class", getBtnClass()));
            }
        });
    }
}
 
Example 32
Project: webanno   File: ProjectMiraTemplatePanel.java   Source Code and License 5 votes vote down vote up
public MiraTemplateDetailForm(String id)
{
    super(id, new CompoundPropertyModel<>(new EntityModel<>(
            new MiraTemplate())));

    add(new CheckBox("annotateAndRepeat"));

    add(new Button("save", new StringResourceModel("label"))
    {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit()
        {
            template = MiraTemplateDetailForm.this.getModelObject();
            if (template.getId() == 0) {
                template.setTrainFeature(selectedFeature);
                automationService.createTemplate(template);
                featureModel.setObject(
                        MiraTemplateDetailForm.this.getModelObject().getTrainFeature());
            }
            template.setCurrentLayer(true);
            for (MiraTemplate tmp : automationService
                    .listMiraTemplates(ProjectMiraTemplatePanel.this.getModelObject())) {
                if (tmp.equals(template)) {
                    continue;
                }
                if (tmp.isCurrentLayer()) {
                    tmp.setCurrentLayer(false);
                }
            }
            updateForm();
        }
    });
}
 
Example 33
Project: wicket-spring-boot   File: CustomerCreatePage.java   Source Code and License 5 votes vote down vote up
private Component submitButton() {
	return new Button("submit"){
		@Override
		public void onSubmit() {
			service.save(customerModel.getObject());
			webSocketMessageBroadcaster.send(new CustomerChangedEvent(customerModel.getObject()));
			if(pageReferenceId != null){
				setResponsePage(new PageReference(pageReferenceId).getPage());
			} else {
				setResponsePage(CustomerListPage.class);
			}
		}
	};
}
 
Example 34
Project: sakai   File: SakaiNavigatorSearch.java   Source Code and License 5 votes vote down vote up
public SakaiNavigatorSearch(String id, final SortableSearchableDataProvider dataProvider) {
	super(id);
	this.dataProvider = dataProvider;

	setDefaultModel(new CompoundPropertyModel(this));

	Form form = new Form("searchForm");
	add(form);

	searchBox = new TextField("searchKeyword");
	form.add(searchBox);

	Button search = new Button("search") {
		@Override
		public void onSubmit() {
			String keyword = getSearchKeyword();
			if(keyword == null || "".equals(keyword)){
				dataProvider.clearSearchKeyword();
			}else{
				dataProvider.setSearchKeyword(keyword);
			}
			super.onSubmit();
		}
	};
	form.add(search);

	Button clear = new Button("clear") {
		@Override
		public void onSubmit() {
			dataProvider.clearSearchKeyword();
			super.onSubmit();
		}
	};
	form.add(clear);
}
 
Example 35
Project: superfly   File: AddRolePage.java   Source Code and License 5 votes vote down vote up
public AddRolePage() {
    super(ListRolesPage.class);

    final UIRole role = new UIRole();
    setDefaultModel(new CompoundPropertyModel<UIRole>(role));
    final RoleFilter roleFilter = new RoleFilter();
    Form<Void> form = new Form<Void>("form") {

    };
    add(form);
    LabelDropDownChoiceRow<UISubsystemForFilter> subsystem =new LabelDropDownChoiceRow<UISubsystemForFilter>("subsystem", roleFilter, "role.create.subsystem", subsystemService
            .getSubsystemsForFilter(), new SubsystemChoiceRenderer());
    subsystem.getDropDownChoice().setRequired(true);
    form.add(subsystem);

    form.add(new LabelTextFieldRow<String>(role, "roleName", "role.create.name", true));
    form.add(new LabelTextFieldRow<String>(role, "principalName", "role.create.principal-name", true));
    form.add(new Button("add-role") {

        @Override
        public void onSubmit() {
            role.setSubsystemId(roleFilter.getSubsystem().getId());
            roleService.createRole(role);
            PageParameters params = new PageParameters();
            params.set("id", String.valueOf(role.getRoleId()));
            params.set("idSubsystem", String.valueOf(role.getSubsystemId()));
            params.set("wizard", "true");
            getRequestCycle().setResponsePage(AddRoleGroupsPage.class,
                    params);
        }

    });
    form.add(new BookmarkablePageLink<Page>("cancel",ListRolesPage.class));
}
 
Example 36
Project: superfly   File: ChangePasswordPanel.java   Source Code and License 5 votes vote down vote up
public ChangePasswordPanel(String id) {
    super(id);

    add(new FeedbackPanel("feedback"));
    
    final UIUserCheckPassword user = new UIUserCheckPassword();

    user.setUsername(getCurrentUserName());

    final Form<UIUserCheckPassword> form = new Form<UIUserCheckPassword>("form",
            new Model<UIUserCheckPassword>(user)) {
               @Override
                public void onSubmit() {
                    userService.changeTempPassword(user.getUsername(), user.getPassword());
                    onPasswordChanged();
                }
    };

    add(form);

    FormComponent<String> password1Field = new PasswordTextField(
            "password", new PropertyModel<String>(user, "password"))
            .setRequired(true);
    form.add(password1Field);

    FormComponent<String> password2Field = new PasswordTextField(
            "password2", new PropertyModel<String>(user, "password2"))
            .setRequired(true);
    form.add(password2Field);

    form.add(new EqualPasswordInputValidator(password1Field,
                    password2Field));
    form.add(new PasswordInputValidator(getCurrentUserName(), password1Field, userService));

    Button submitButton = new Button("change");
    submitButton.setOutputMarkupId(true);
    submitButton.setMarkupId("change-button");
    form.add(submitButton);
}
 
Example 37
Project: superfly   File: ResetPasswordUserPage.java   Source Code and License 5 votes vote down vote up
public ResetPasswordUserPage(final PageParameters parameters) {
        super(ListUsersPage.class, parameters);

        final long userId = parameters.get("userId").toLong();
        final UIUser user = userService.getUser(userId);
//        System.out.println("POLICY NAME "+resetPasswordStrategy.getPolicyName());
        Form<Void> form = new Form<Void>("form");
        add(form);
        final Label label = new Label("generated-password", new LoadableDetachableModel<String>() {

            @Override
            protected String load() {
                setNewPassword(passwordGenerator.generate());
                return getNewPassword();
            }
        });
        label.setOutputMarkupId(true);
        form.add(label);
        form.add(new IndicatingAjaxLink<String>("generateNewPassword") {
            private static final long serialVersionUID = 1L;

            public void onClick(AjaxRequestTarget aTarget) {
                setNewPassword(passwordGenerator.generate());
                aTarget.add(label);
            }
        });
        form.add(new BookmarkablePageLink<Page>("cancel", ListUsersPage.class));
        form.add(new Button("reset-button"){

            @Override
            public void onSubmit() {
                resetPasswordStrategy.resetPassword(userId, user.getUsername(), newPassword);
                setResponsePage(ListUsersPage.class);
            }

        });
    }
 
Example 38
Project: edemocracia   File: BloqueioForumHome.java   Source Code and License 5 votes vote down vote up
private void initBotao() {
	bloquear = new Button("bloquear") {
		@Override
		public void onSubmit() {
			bloqueiaThreads();
			info("Todas as threads abaixo da comunidade informada foram marcadas como bloqueadas");
		}
	};
	form.add(bloquear);
}
 
Example 39
Project: edemocracia   File: BloqueioForumHome.java   Source Code and License 5 votes vote down vote up
private void initDesbloquear() {
	desbloquear = new Button("desbloquear") {
		@Override
		public void onSubmit() {
			desbloqueiaThreads();
			info("Todas as threads abaixo da comunidade informada foram desbloqueadas");
		}
	};
	form.add(desbloquear);
}
 
Example 40
Project: edemocracia   File: EditPage.java   Source Code and License 5 votes vote down vote up
private void initVoltar() {
	voltar = new Button("voltar") {
		@Override
		public void onSubmit() {
			getRequestCycle().setRequestTarget(
					new RedirectRequestTarget(viewUrl));
		}
	};
	voltar.setDefaultFormProcessing(false);
	form.add(voltar);
}