org.apache.wicket.markup.html.form.Button类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中org.apache.wicket.markup.html.form.Button类的一些代码示例,展示了Button类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button类的具体详情如下:
包路径:org.apache.wicket.markup.html.form.Button
类名称:Button

Button介绍

[英]A form button.

Within a form, you can nest Button components. Note that you don't have to do this to let the form work (a simple <input type="submit".. suffices), but if you want to have different kinds of submit behavior it might be a good idea to use Buttons.

The model property is used to set the "value" attribute. It will thus be the label of the button that shows up for end users. If you want the attribute to keep it's markup attribute value, don't provide a model, or let it return an empty string.

When you add a Wicket Button to a form, and that button is clicked, by default the button's onSubmit method is called first, and after that the form's onSubmit method is called. If you want to change this (e.g. you don't want to call the form's onSubmit method, or you want it called before the button's onSubmit method), you can override Form.delegateSubmit.

One other option you should know of is the 'defaultFormProcessing' property of Button components. When you set this to false (default is true), all validation and formupdating is bypassed and the onSubmit method of that button is called directly, and the onSubmit method of the parent form is not called. A common use for this is to create a cancel button.
[中]表单按钮。
在表单中,可以嵌套按钮组件。请注意,您不必这样做就可以让表单正常工作(一个简单的<input type=“submit.”就足够了),但是如果您想有不同类型的提交行为,最好使用按钮。
模型属性用于设置“值”属性。因此,它将是为最终用户显示的按钮标签。如果希望属性保留其标记属性值,请不要提供模型,或让它返回空字符串。
将Wicket按钮添加到表单并单击该按钮时,默认情况下,首先调用按钮的onSubmit方法,然后调用表单的onSubmit方法。如果要更改此选项(例如,您不想调用表单的onSubmit方法,或者希望在按钮的onSubmit方法之前调用它),则可以重写表单。授权提交。
您应该知道的另一个选项是按钮组件的“defaultFormProcessing”属性。当您将其设置为false(默认值为true)时,将绕过所有验证和表单更新,并直接调用该按钮的onSubmit方法,而不调用父表单的onSubmit方法。这通常用于创建“取消”按钮。

代码示例

代码示例来源:origin: org.opensingular/singular-form-wicket

private Button buildModelTrigger() {
  final Button modalTrigger = new Button(MODAL_TRIGGER_ID);
  modalTrigger.add(new AjaxEventBehavior("click") {
    @Override
    protected void onEvent(AjaxRequestTarget target) {
      target.add(ctx.getExternalContainer());
      getModal().show(target);
    }
  });
  return modalTrigger;
}

代码示例来源:origin: micromata/projectforge

/**
 * @param defaultFormProcessing
 * @return this for chaining.
 * @see Button#setDefaultFormProcessing(boolean)
 */
public IconButtonPanel setDefaultFormProcessing(final boolean defaultFormProcessing)
{
 button.setDefaultFormProcessing(defaultFormProcessing);
 return this;
}

代码示例来源:origin: org.onehippo.jcr.console/hippo-jcr-console-api

protected Button decorate(Button button) {
  button.setEnabled(enabled);
  button.setVisible(visible);
  if (getKeyType() != null) {
    button.add(new InputBehavior(new KeyType[]{getKeyType()}, EventType.click));
  }
  return button;
}

代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket

/**
 * Constructor without a model. Buttons without models leave the markup attribute
 * &quot;value&quot;. Provide a model if you want to set the button's label dynamically.
 * 
 * @see org.apache.wicket.Component#Component(String)
 */
public Button(String id)
{
  super(id);
  setVersioned(true);
  setOutputMarkupId(true);
}

代码示例来源:origin: apache/wicket

/**
 * Constructor taking an model for rendering the 'label' of the button (the value attribute of
 * the input/button tag). Use a {@link org.apache.wicket.model.StringResourceModel} for a
 * localized value.
 * 
 * @param id
 *            Component id
 * @param model
 *            The model property is used to set the &quot;value&quot; attribute. It will thus be
 *            the label of the button that shows up for end users. If you want the attribute to
 *            keep it's markup attribute value, don't provide a model, or let it return an empty
 *            string.
 */
public Button(final String id, final IModel<String> model)
{
  super(id, model);
  setVersioned(true);
  setOutputMarkupId(true);
  // don't double encode the value. it is encoded by ComponentTag.writeOutput()
  setEscapeModelStrings(false);
}

代码示例来源:origin: micromata/projectforge

@Override
public void populateItem(Item<ICellPopulator<FFPDebtDO>> item, String componentId,
  IModel<FFPDebtDO> rowModel)
{
 FFPDebtDO debt = rowModel.getObject();
 Button button = new Button(ButtonPanel.BUTTON_ID);
 if (debt.getFrom().equals(ThreadLocalUserContext.getUser())) {
  button.setOutputMarkupId(true);
  button.add(new AjaxEventBehavior("click")
  {
   @Override
   protected void onEvent(AjaxRequestTarget target)
   {
    if (debt.isApprovedByFrom() == false) {
     eventService.updateDebtFrom(debt);
     button.add(AttributeModifier.append("class", ButtonType.GREEN.getClassAttrValue()));
     button.addOrReplace(new Label("title", I18nHelper.getLocalizedMessage("plugins.ffp.payed")));
     target.add(button);
    }
   }
  });
 }
 String label = debt.isApprovedByFrom() ?
   I18nHelper.getLocalizedMessage("plugins.ffp.payed") :
   I18nHelper.getLocalizedMessage("plugins.ffp.notPayed");
 ButtonType bt = debt.isApprovedByFrom() ? ButtonType.GREEN : ButtonType.RED;
 ButtonPanel buttonPanel = new ButtonPanel(componentId, label, button, bt);
 item.add(buttonPanel);
}

代码示例来源:origin: micromata/projectforge

/**
 * @param attributeName
 * @param value
 * @return this for chaining.
 * @see AttributeModifier#append(String, java.io.Serializable)
 */
public IconButtonPanel oldAppendAttribute(final String attributeName, final Serializable value)
{
 button.add(AttributeModifier.append(attributeName, value));
 return this;
}

代码示例来源:origin: net.ontopia/ontopoly-editor

form.add(message);
Button button = new Button("button", new ResourceModel("button.ok"));
button.setVisible(roleCombos.isEmpty());
button.add(new AjaxFormComponentUpdatingBehavior("onclick") {
 @Override
 protected void onUpdate(AjaxRequestTarget target) {

代码示例来源:origin: micromata/projectforge

private Button createDeleteButton()
{
 final Button deleteButton = new Button("deleteButton");
 deleteButton.add(new AjaxEventBehavior("click")
 {
  @Override
  protected void onEvent(AjaxRequestTarget target)
  {
   // open dialog only if an attr row is selected
   if (selectedAttrRowModel.getObject() != null) {
    deleteDialog.open(target);
   }
  }
 });
 deleteButton.setMarkupId(attrGroup.getName() + "-deleteButton").setOutputMarkupId(true);
 return deleteButton;
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-api

@Override
  protected Button decorate(final Button button) {
    button.add(new AjaxEventBehavior("onclick") {
      @Override
      protected void onComponentTag(final ComponentTag tag) {
        super.onComponentTag(tag);
        tag.put("type", "button");
      }
      @Override
      protected void onEvent(final AjaxRequestTarget target) {
        onSubmit();
      }
    });
    button.setDefaultFormProcessing(false);
    return super.decorate(button);
  }
};

代码示例来源:origin: org.jabylon/updatecenter

button.setDefaultFormProcessing(false);
button.add(new AttributeModifier("value", resource.getBundleId()));
button.add(new AttributeModifier("class", "btn btn-small"));
button.setEnabled(CHANGEABLE_STATE.contains(bundleState));

代码示例来源:origin: org.jabylon/rest.ui

private Component buildAddNewLink(IModel<Project> model) {
  Project project = model.getObject();
  if (project.cdoState() == CDOState.NEW || project.cdoState() == CDOState.TRANSIENT) {
    // it's a new project, we can't add anything yet
    Button link = new Button("addNew");
    link.setEnabled(false);
    return link;
  }
  PageParameters parameters = WicketUtil.buildPageParametersFor(project);
  parameters.add(SettingsPanel.QUERY_PARAM_CREATE, PropertiesPackage.Literals.PROJECT_VERSION.getName());
  return new BookmarkablePageLink<Void>("addNew", SettingsPage.class, parameters);
}

代码示例来源:origin: de.alpharogroup/wicket-bootstrap3

/**
 * Factory method for create a new {@link Button}. This method is invoked in the constructor
 * from the derived classes and can be overridden so users can provide their own version of a
 * new {@link Button}.
 *
 * @param id
 *            the id
 * @return the new {@link Button}
 */
protected Component newnavbarBrandButton(final String id)
{
  return new Button(id);
}

代码示例来源:origin: theonedev/onedev

Button uploadButton = new Button("upload");
uploadButton.setVisible(false).setOutputMarkupPlaceholderTag(true);

代码示例来源:origin: org.opensingular/singular-form-wicket

this.ids = ids;
this.viewSupplier = viewSupplier;
this.clearButton = new Button("clearButton", $m.ofValue("Limpar"));
this.currentLocationButton = new Button("currentLocationButton", $m.ofValue("Marcar Minha Posição"));
this.multipleMarkers = multipleMarkers;
clearButton.setDefaultFormProcessing(false);
currentLocationButton.setDefaultFormProcessing(false);

代码示例来源:origin: micromata/projectforge

public void open(final AjaxRequestTarget target, final TeamEvent event, final Timestamp newStartDate, final Timestamp newEndDate)
{
 this.event = event;
 this.newStartDate = newStartDate;
 this.newEndDate = newEndDate;
 if (event instanceof TeamEventDO) {
  // All future events are the same as all events, because the user selected the first event:
  allFutureEventsButtonPanel.getButton().setVisible(false);
 } else {
  allFutureEventsButtonPanel.getButton().setVisible(true);
 }
 addButtonBar(target);
 super.open(target);
}

代码示例来源:origin: org.opensingular/singular-wicket-utils

public BSModalBorder addButton(ButtonStyle style, IModel<String> label, Button button) {
  if (label != null) {
    button.setLabel(label);
  }
  buttonsContainer.addOrReplace(button
      .add(newButtonLabel(BUTTON_LABEL, button))
      .add(new AttributeAppender("class", style.cssClassModel(), " ")));
  return this;
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-api

protected JQueryFileUploadDialog(final IPluginContext pluginContext, final IPluginConfig pluginConfig){
  setOutputMarkupId(true);
  setMultiPart(true);
  setOkVisible(false);
  setOkEnabled(false);
  setCancelLabel(new ResourceModel("button-close-label"));
  uploadButton = new AjaxButton(DialogConstants.BUTTON, new ResourceModel("button-upload-label")){
    @Override
    protected String getOnClickScript(){
      return fileUploadWidget.getUploadScript();
    }
    @Override
    protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
      isUploadButtonEnabled = false;
      target.add(this);
    }
    @Override
    public boolean isEnabled() {
      return isUploadButtonEnabled;
    }
  };
  uploadButton.add(new InputBehavior(new KeyType[]{KeyType.Enter}, EventType.click));
  uploadButton.setOutputMarkupId(true);
  this.addButton(uploadButton);
  this.pluginContext = pluginContext;
  this.pluginConfig = pluginConfig;
  this.validator = getValidator();
  createComponents();
}

代码示例来源:origin: apache/wicket

@Override
protected void onInitialize()
{
  super.onInitialize();
  add(newAjaxFormSubmitBehavior("click"));
}

代码示例来源:origin: org.onehippo.jcr.console/hippo-jcr-console-api

public void setVisible(boolean isset) {
  visible = isset;
  if (button != null && button.isVisible() != isset) {
    button.setVisible(isset);
    if (ajax) {
      AjaxRequestTarget target = AjaxRequestTarget.get();
      if (target != null) {
        target.addComponent(button);
      }
    }
  }
}

相关文章