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

The following examples show how to use org.apache.wicket.markup.html.form.Button. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IconButtonPanel.java    From projectforge-webapp with GNU General Public License v3.0 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 #2
Source File: OrienteerBasePage.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private WebMarkupContainer createPerspectivesContainer(String id, IModel<ODocument> perspectiveModel,
													   IModel<List<ODocument>> perspectivesModel) {
	return new WebMarkupContainer(id) {
		@Override
		protected void onInitialize() {
			super.onInitialize();
			add(createPerspectivesList("perspectives", perspectivesModel));
			Button perspectiveButton = new Button("perspectiveButton");

			perspectiveButton.add(new FAIcon("icon", new PropertyModel<>(perspectiveModel, "icon")));
			perspectiveButton.add(new Label("name", new ODocumentNameModel(perspectiveModel)));
			add(perspectiveButton);

			setOutputMarkupPlaceholderTag(true);
		}

		@Override
		protected void onConfigure() {
			super.onConfigure();
			List<ODocument> perspectives = perspectivesModel.getObject();
			setVisible(perspectives != null && perspectives.size() > 1);
		}
	};
}
 
Example #3
Source File: TypeBrowser.java    From oodt with Apache License 2.0 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 #4
Source File: AdminForm.java    From projectforge-webapp with GNU General Public License v3.0 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 #5
Source File: AssociationTransformFunctionBoxPanel.java    From ontopia with Apache License 2.0 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 #6
Source File: UserEditForm.java    From projectforge-webapp with GNU General Public License v3.0 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 #7
Source File: TaskListForm.java    From projectforge-webapp with GNU General Public License v3.0 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 #8
Source File: ModalInstancePage.java    From ontopia with Apache License 2.0 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 #9
Source File: AbstractEditForm.java    From projectforge-webapp with GNU General Public License v3.0 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 #10
Source File: MessagesContactsPanel.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
private void selectMessage(long id, AjaxRequestTarget target) {
	PrivateMessage msg = msgDao.get(id);
	selectedMessage.addOrReplace(new Label("from", msg == null ? "" : getDisplayName(msg.getFrom())));
	selectedMessage.addOrReplace(new Label("to", msg == null ? "" : getDisplayName(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) {
		lastSelected = null;
	} else {
		lastSelected = id;
		Room r = msg.getRoom();
		if (r != null) {
			Appointment a = apptDao.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 #11
Source File: AbstractImportForm.java    From projectforge-webapp with GNU General Public License v3.0 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 #12
Source File: SkillListForm.java    From projectforge-webapp with GNU General Public License v3.0 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 #13
Source File: LogoutPanel.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Construct logout panel.
 * @param id component id.
 */
public LogoutPanel(final String id) {
    super(id);

    final StatelessForm form = new StatelessForm(LOGOFF_LINK);

    final Button submit = new Button("logoffCmd") {
        @Override
        public void onSubmit() {
            final Map<String, Object> cmd = new HashMap<>();
            cmd.put(ShoppingCartCommand.CMD_LOGOUT, ShoppingCartCommand.CMD_LOGOUT);
            shoppingCartCommandFactory.execute(ShoppingCartCommand.CMD_LOGOUT, getCurrentCart(), cmd);
            ((AbstractWebPage) getPage()).persistCartIfNecessary();
            LogoutPanel.this.setResponsePage(Application.get().getHomePage());
        }
    };

    submit.setDefaultFormProcessing(false);

    form.add(submit);

    add(form);

}
 
Example #14
Source File: SingleButtonPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @param id
 * @param button
 * @param label
 * @param classnames css class names
 */
public SingleButtonPanel(final String id, final Button button, final IModel<String> label, final String... classnames)
{
  super(id);
  this.button = button;
  add(button);
  button.add(new Label("label", label).setRenderBodyOnly(true));
  if (classnames != null) {
    button.add(AttributeModifier.append("class", StringHelper.listToString(" ", classnames)));
  }
}
 
Example #15
Source File: AbstractStandardForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
protected SingleButtonPanel addCancelButton(final Button cancelButton)
{
  cancelButton.setDefaultFormProcessing(false); // No validation of the form.
  final SingleButtonPanel cancelButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), cancelButton, getString("cancel"),
      SingleButtonPanel.CANCEL);
  actionButtons.add(cancelButtonPanel);
  return cancelButtonPanel;
}
 
Example #16
Source File: SystemUpdateForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("serial")
protected void init()
{
  add(createFeedbackPanel());
  gridBuilder = newGridBuilder(this, "flowform");
  gridBuilder.newGridPanel();
  {
    final FieldsetPanel fs = gridBuilder.newFieldset("Show all");
    fs.add(new CheckBoxPanel(fs.newChildId(), new PropertyModel<Boolean>(this, "showOldUpdateScripts"), null, true) {
      /**
       * @see org.projectforge.web.wicket.flowlayout.CheckBoxPanel#onSelectionChanged(java.lang.Boolean)
       */
      @Override
      protected void onSelectionChanged(final Boolean newSelection)
      {
        parentPage.refresh();
      }
    });
  }
  scripts = new WebMarkupContainer("scripts");
  add(scripts);
  updateEntryRows();

  actionButtons = new MyComponentsRepeater<SingleButtonPanel>("buttons");
  add(actionButtons.getRepeatingView());
  {
    final Button refreshButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("refresh")) {
      @Override
      public final void onSubmit()
      {
        parentPage.refresh();
      }
    };
    final SingleButtonPanel refreshButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), refreshButton, "refresh",
        SingleButtonPanel.DEFAULT_SUBMIT);
    actionButtons.add(refreshButtonPanel);
    setDefaultButton(refreshButton);
  }
}
 
Example #17
Source File: IconButtonPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public IconButtonPanel(final String id, final Button button, final IconType type, final String tooltip)
{
  super(id);
  this.button = button;
  add(button);
  init(type, tooltip);
}
 
Example #18
Source File: ButtonPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public ButtonPanel(final String id, final String title, final Button button, final ButtonType... buttonTypes)
{
  super(id);
  this.button = button;
  button.add(new Label("title", title));
  for (final ButtonType buttonType : buttonTypes) {
    button.add(AttributeModifier.append("class", buttonType.getClassAttrValue()));
  }
  add(button);
}
 
Example #19
Source File: ButtonPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public ButtonPanel(final String id, final String label, final ButtonType... buttonTypes)
{
  super(id);
  button = new Button(BUTTON_ID, new Model<String>(label));
  button.add(new Label("title", label));
  for (final ButtonType buttonType : buttonTypes) {
    button.add(AttributeModifier.append("class", buttonType.getClassAttrValue()));
  }
  add(button);
}
 
Example #20
Source File: DefaultFocusFormVisitor.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public void component(Component object, IVisit<Void> visit) {
	if (!visited.contains(object) && (object instanceof FormComponent) && !(object instanceof Button)) {
		final FormComponent<?> fc = (FormComponent<?>) object;
		visited.add(fc);
		if (!found && fc.isEnabled() && fc.isVisible()
				&& (fc instanceof DropDownChoice || fc instanceof AbstractTextComponent)) {
			found = true;
			fc.add(new DefaultFocusBehavior());
		}
	}
}
 
Example #21
Source File: ProjectPortfolioPanel.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
protected MarkupContainer getEditLink(String id, final IModel<? extends Project> projectModel) {
	Button editLink = new Button(id);
	editLink.add(new AjaxModalOpenBehavior(editProjectPopup, MouseEvent.CLICK) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onShow(AjaxRequestTarget target) {
			editProjectPopup.getModel().setObject(projectModel.getObject());
		}
	});
	return editLink;
}
 
Example #22
Source File: ProjectListPage.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public ProjectListPage(PageParameters parameters) {
	super(parameters);
	
	String term = parameters.get(LinkUtils.SEARCH_TERM_PARAMETER).toString();
	long pageNumber = LinkUtils.extractPageNumberParameter(parameters);
	
	IModel<String> searchTermModel = Model.of(term);
	
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("project.list.pageTitle"),
			ProjectListPage.linkDescriptor()));
	
	// Add project button
	final ProjectFormPopupPanel addProjectPopup = new ProjectFormPopupPanel("addProjectPopup", FormPanelMode.ADD);
	add(addProjectPopup);
	Button addProjectButton = new AuthenticatedOnlyButton("addProject") {
		private static final long serialVersionUID = 1L;
		
		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(MavenArtifactNotifierSession.get().hasRoleAdmin());
		}
	};
	addProjectButton.add(new AjaxModalOpenBehavior(addProjectPopup, MouseEvent.CLICK));
	add(addProjectButton);

	// Page content
	ProjectPortfolioPanel portfolioPanel = new ProjectPortfolioPanel("portfolio",
			new ProjectDataProvider(searchTermModel), configurer.getPortfolioItemsPerPage());
	portfolioPanel.getPageable().setCurrentPage(pageNumber);
	add(portfolioPanel);
	
	add(new ProjectSearchPanel("searchPanel", portfolioPanel.getPageable(), searchTermModel));
}
 
Example #23
Source File: UserEditForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("serial")
public static void createAuthenticationToken(final GridBuilder gridBuilder, final PFUserDO user, final UserDao userDao,
    final Form< ? > form)
{
  // Authentication token
  final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString("user.authenticationToken")).suppressLabelForWarning();
  fs.add(new DivTextPanel(fs.newChildId(), new Model<String>() {
    @Override
    public String getObject()
    {
      if (PFUserContext.getUserId().equals(user.getId()) == true) {
        return userDao.getAuthenticationToken(user.getId());
      } else {
        // Administrators shouldn't see the token.
        return "*****";
      }
    }
  }));
  fs.addHelpIcon(gridBuilder.getString("user.authenticationToken.tooltip"));
  final Button button = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("renewAuthenticationKey")) {
    @Override
    public final void onSubmit()
    {
      userDao.renewAuthenticationToken(user.getId());
      form.error(getString("user.authenticationToken.renew.successful"));
    }
  };
  button.add(WicketUtils.javaScriptConfirmDialogOnClick(form.getString("user.authenticationToken.renew.securityQuestion")));
  fs.add(new SingleButtonPanel(fs.newChildId(), button, gridBuilder.getString("user.authenticationToken.renew"), SingleButtonPanel.DANGER));
  WicketUtils.addTooltip(button, gridBuilder.getString("user.authenticationToken.renew.tooltip"));
}
 
Example #24
Source File: SetupImportForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("serial")
protected void init()
{
  add(createFeedbackPanel());
  final GridBuilder gridBuilder = newGridBuilder(this, "flowform");
  gridBuilder.newFormHeading(getString("import"));
  {
    // Upload dump file
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.setup.dumpFile"));
    fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID);
    fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField));
  }
  final RepeatingView actionButtons = new RepeatingView("buttons");
  add(actionButtons);
  {
    final Button importButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("import")) {
      @Override
      public final void onSubmit()
      {
        parentPage.upload();
      }
    };
    final SingleButtonPanel importButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), importButton, getString("import"),
        SingleButtonPanel.DEFAULT_SUBMIT);
    actionButtons.add(importButtonPanel);
  }
}
 
Example #25
Source File: AdministrationUserPortfolioPage.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public AdministrationUserPortfolioPage(PageParameters parameters) {
	super(parameters);
	
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("navigation.administration.user"),
			AdministrationUserPortfolioPage.linkDescriptor()));
	
	IModel<String> searchTermModel = Model.of("");
	
	UserPortfolioPanel portfolioPanel = new UserPortfolioPanel("portfolio", new UserDataProvider(searchTermModel),
			configurer.getPortfolioItemsPerPage());
	add(portfolioPanel);

	add(new AdministrationUserSearchPanel("searchPanel", portfolioPanel.getPageable(), searchTermModel));
	
	// User create popup
	UserFormPopupPanel userCreatePanel = new UserFormPopupPanel("userCreatePopupPanel");
	add(userCreatePanel);
	
	Button createUser = new Button("createUser");
	createUser.add(new AjaxModalOpenBehavior(userCreatePanel, MouseEvent.CLICK) {
		private static final long serialVersionUID = 5414159291353181776L;
		
		@Override
		protected void onShow(AjaxRequestTarget target) {
		}
	});
	add(createUser);
}
 
Example #26
Source File: AdministrationUserGroupPortfolioPage.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public AdministrationUserGroupPortfolioPage(PageParameters parameters) {
	super(parameters);
	
	addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("navigation.administration.usergroup"),
			AdministrationUserGroupPortfolioPage.linkDescriptor()));
	
	IModel<List<UserGroup>> userGroupListModel = new LoadableDetachableModel<List<UserGroup>>() {
		private static final long serialVersionUID = -4518288683578265677L;
		
		@Override
		protected List<UserGroup> load() {
			return userGroupService.list();
		}
	};
	
	add(new UserGroupPortfolioPanel("portfolio", userGroupListModel, configurer.getPortfolioItemsPerPage()));
	
	// User group create popup
	UserGroupFormPopupPanel userGroupCreatePanel = new UserGroupFormPopupPanel("userGroupCreatePopupPanel");
	add(userGroupCreatePanel);
	
	Button createUserGroup = new Button("createUserGroup");
	createUserGroup.add(new AjaxModalOpenBehavior(userGroupCreatePanel, MouseEvent.CLICK) {
		private static final long serialVersionUID = 5414159291353181776L;
		
		@Override
		protected void onShow(AjaxRequestTarget target) {
		}
	});
	add(createUserGroup);
}
 
Example #27
Source File: SakaiNavigatorSearch.java    From sakai with Educational Community License v2.0 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 #28
Source File: ShoppingCartItemsList.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Adjust quantity.
 *
 * @param productSkuCode sku code
 * @param supplier       supplier
 * @param qtyField       quantity input box  @return BookmarkablePageLink for remove one sku from cart command
 */
private Button createAddSeveralSkuButton(final String productSkuCode, final String supplier, final TextField<BigDecimal> qtyField) {
    final Button adjustQuantityButton = new Button(QUANTITY_ADJUST_BUTTON) {
        @Override
        public void onSubmit() {
            String qty = qtyField.getInput();
            if (StringUtils.isNotBlank(qty)) {
                qty = qty.replace(',', '.');
            }
            /*try {
                skuCode = URLEncoder.encode(productSkuCode, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                skuCode = productSkuCode;
            }*/


            if (NumberUtils.isNumber(qty)) {
                qtyField.setConvertedInput(new BigDecimal(qty).setScale(Constants.MONEY_SCALE, BigDecimal.ROUND_HALF_UP));
                setResponsePage(
                        getPage().getPageClass(),
                        new PageParameters()
                                .add(ShoppingCartCommand.CMD_SETQTYSKU, productSkuCode)
                                .add(ShoppingCartCommand.CMD_P_SUPPLIER, supplier)
                                .add(ShoppingCartCommand.CMD_P_QTY, qty)
                );


            } else {
                qtyField.setConvertedInput(MoneyUtils.ONE);
                error(getLocalizer().getString("nonZeroDigits", this, "Need positive integer value"));
            }
        }
    };
    adjustQuantityButton.setDefaultFormProcessing(true);
    return adjustQuantityButton;
}
 
Example #29
Source File: LoginPage.java    From webanno with Apache License 2.0 5 votes vote down vote up
public LoginPage()
{
    setStatelessHint(true);
    setVersioned(false);
    
    add(form = new LoginForm("loginForm"));
    signInBtn = new Button("signInBtn");
    signInBtn.add(LambdaBehavior.enabledWhen(() -> !isTooManyUsers()));
    tooManyUsersLabel = new WebMarkupContainer("usersLabel");
    tooManyUsersLabel.add(LambdaBehavior.visibleWhen(this::isTooManyUsers));
    form.add(signInBtn);
    form.add(tooManyUsersLabel);
    form.add(LambdaBehavior.enabledWhen(() -> !isTooManyUsers()));
    
    redirectIfAlreadyLoggedIn();

    // Create admin user if there is no user yet
    if (userRepository.list().isEmpty()) {
        User admin = new User();
        admin.setUsername(ADMIN_DEFAULT_USERNAME);
        admin.setPassword(ADMIN_DEFAULT_PASSWORD);
        admin.setEnabled(true);
        admin.setRoles(EnumSet.of(Role.ROLE_ADMIN, Role.ROLE_USER));
        userRepository.create(admin);

        String msg = "No user accounts have been found. An admin account has been created: "
                + ADMIN_DEFAULT_USERNAME + "/" + ADMIN_DEFAULT_PASSWORD;
        // We log this as a warning so the message sticks on the screen. Success and info
        // messages are set to auto-close after a short time.
        warn(msg);
    }
}
 
Example #30
Source File: ProjectMiraTemplatePanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
public MiraTemplateDetailForm(String id)
{
    super(id, new CompoundPropertyModel<>(new MiraTemplate()));

    add(new CheckBox("annotateAndRepeat"));

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

        @Override
        public void onSubmit()
        {
            template = MiraTemplateDetailForm.this.getModelObject();
            if (isNull(template.getId())) {
                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();
        }
    });
}