コード例 #1
0
  private void createLayout() {
    AjaxButton button =
        new AjaxButton(ID_BUTTON, createButtonStringResource(getCaption())) {

          @Override
          public void onClick(AjaxRequestTarget target) {
            clickPerformed(target, SingleButtonPanel.this.getModel());
          }

          @Override
          public boolean isEnabled() {
            return SingleButtonPanel.this.isEnabled(SingleButtonPanel.this.getModel());
          }

          @Override
          public boolean isVisible() {
            return SingleButtonPanel.this.isVisible(SingleButtonPanel.this.getModel());
          }
        };
    button.add(new AttributeAppender("class", getButtonCssClass()));

    add(button);
  }
コード例 #2
0
  private void initButtons(WebMarkupContainer buttonBar, IModel<Integer> inputType) {
    AjaxButton backButton =
        new AjaxButton(ID_BACK_BUTTON, createStringResource("PageCertCampaign.button.back")) {

          @Override
          public void onClick(AjaxRequestTarget target) {
            redirectBack();
          }
        };
    backButton.add(
        new VisibleEnableBehaviour() {
          public boolean isVisible() {
            PageParameters params = PageImportObject.this.getPageParameters();
            if (params != null) {
              if (params.get(FROM_MENU_ITEM_PARAM) != null
                  && !params.get(FROM_MENU_ITEM_PARAM).isNull()
                  && params
                      .get(FROM_MENU_ITEM_PARAM)
                      .toString()
                      .equals(FROM_MENU_ITEM_PARAM_TRUE_VALUE)) {
                return false;
              }
            }
            return true;
          }
        });
    buttonBar.add(backButton);

    AjaxSubmitButton saveFileButton =
        new AjaxSubmitButton(
            ID_IMPORT_FILE_BUTTON, createStringResource("PageImportObject.button.import")) {

          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(false, OPERATION_IMPORT_FILE, target);
          }

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
          }
        };
    addVisibileForInputType(saveFileButton, INPUT_FILE, inputType);
    buttonBar.add(saveFileButton);

    AjaxSubmitButton saveXmlButton =
        new AjaxSubmitButton(
            ID_IMPORT_XML_BUTTON, createStringResource("PageImportObject.button.import")) {

          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(true, OPERATION_IMPORT_XML, target);
          }

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
          }
        };
    addVisibileForInputType(saveXmlButton, INPUT_XML, inputType);
    buttonBar.add(saveXmlButton);
  }