예제 #1
0
  public void initButtons(Form mainForm) {
    AjaxSubmitButton save =
        new AjaxSubmitButton(ID_SAVE, createStringResource("PageBase.button.save")) {

          private static final long serialVersionUID = 1L;

          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            savePerformed(target);
          }
        };
    mainForm.add(save);

    AjaxButton back =
        new AjaxButton(ID_BACK, createStringResource("PageBase.button.back")) {

          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
          }
        };
    mainForm.add(back);
  }
예제 #2
0
 public BillingPlots() {
   long t = getWebadminApplication().getBillingService().getRefreshIntervalInMillis();
   Form<?> form = getAutoRefreshingForm("billingForm", t, TimeUnit.MILLISECONDS);
   form.add(new OptionPanel("optionPanel", this));
   form.add(new PlotsPanel("plotsPanel", this));
   add(form);
 }
  /**
   * Defines an {@link AddCommentPanel} object of a file or an album, either album or file must be
   * null, but not both.
   *
   * @param id This panel {@code wicket:id}
   * @param commentsPanel Comment panel, to reload it on adding comments, it can be {@code null}
   * @param album The {@link #album}, or {@code null} for a file panel
   * @param file The {@link #file}, or {@code null} for an album panel
   */
  private AddCommentPanel(String id, ShowCommentsPanel commentsPanel, Album album, File file) {
    super(id);
    this.album = album;
    this.file = file;

    final ShowCommentsPanel showCommentsPanel = commentsPanel;
    final TextArea<String> text = new TextArea<String>("text", Model.of(""));
    text.setRequired(true);

    Form<Void> form =
        new Form<Void>("addCommentForm") {
          @Override
          protected void onSubmit() {
            String textString = cleanComment(text.getModelObject());
            if (validateComment(textString)) {
              createComment(textString);
              if (showCommentsPanel != null) {
                showCommentsPanel.reload();
              }
            }
            setResponsePage(this.getPage());
          }
        };
    add(form);
    form.add(text);
    form.add(new Label("maxLength", String.valueOf(Comment.MAX_TEXT_LENGTH)));
  }
예제 #4
0
  private void setUpPage(IModel<AssignmentAdminBackingBean> model) {
    Border greyBorder = new GreySquaredRoundedBorder("border", WebGeo.W_CONTENT_SMALL);
    add(greyBorder);

    final Form<AssignmentAdminBackingBean> form =
        new Form<AssignmentAdminBackingBean>("assignmentForm", model);
    greyBorder.add(form);

    // add submit form
    boolean deletable =
        ((AssignmentAdminBackingBean) getDefaultModelObject()).getProjectAssignment().isDeletable();
    FormConfig formConfig =
        new FormConfig()
            .forForm(form)
            .withDelete(deletable)
            .withSubmitTarget(this)
            .withDeleteEventType(AssignmentAjaxEventType.ASSIGNMENT_DELETED)
            .withSubmitEventType(AssignmentAjaxEventType.ASSIGNMENT_UPDATED);

    FormUtil.setSubmitActions(formConfig);

    form.add(
        new AssignmentFormComponentContainerPanel(
            "formComponents",
            form,
            model,
            DisplayOption.SHOW_PROJECT_SELECTION,
            DisplayOption.SHOW_SAVE_BUTTON,
            DisplayOption.SHOW_DELETE_BUTTON));

    form.add(new ServerMessageLabel("serverMessage", "formValidationError"));
  }
  public EntitlementPurchaseModalPanel(
      CustomModalWindow purchaseTransactionModal, EntitlementLookup entilement) {
    super(purchaseTransactionModal.getContentId());
    this.purchaseTransactionWindow = purchaseTransactionModal;

    final Form<Object> purchaseHistoryForm = new Form<Object>("purchaseHistoryForm");
    purchaseHistoryForm.setOutputMarkupPlaceholderTag(true);
    add(purchaseHistoryForm);

    final FeedbackMessageFilter filter = new FeedbackMessageFilter("PurchaseHistory");
    filter.setAcceptAllUnspecifiedComponents(false);
    filter.addFilterInComponent(purchaseHistoryForm);

    final FeedbackPanel purchaseHistoryFeedback =
        new FeedbackPanel("purchaseHistoryFeedback", filter);
    purchaseHistoryFeedback.setOutputMarkupPlaceholderTag(true);
    add(purchaseHistoryFeedback);

    purchaseHistoryForm.add(
        new PurchaseHistoryTabPanel(
            "gspPurchaseHistoryTabPanel",
            purchaseHistoryFeedback,
            purchaseHistoryForm,
            filter,
            TabId.ALL));

    PurchaseSelectTabPanel purchaseSelectTabPanel =
        new PurchaseSelectTabPanel("purchaseSelectTabPanel", entilement);
    purchaseHistoryForm.add(purchaseSelectTabPanel);
  }
  private void initButtons(final Form mainForm) {
    AjaxSubmitButton saveButton =
        new AjaxSubmitButton(ID_SAVE_BUTTON, createStringResource("PageBase.button.save")) {

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

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
          }
        };
    mainForm.add(saveButton);

    AjaxButton backButton =
        new AjaxButton(ID_BACK_BUTTON, createStringResource("PageBase.button.back")) {

          @Override
          public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageResources.class);
          }
        };
    mainForm.add(backButton);
  }
예제 #7
0
  public Example6() {
    final Form<Data> form =
        new Form<Data>("form", new CompoundPropertyModel<Data>(dummy)) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onSubmit() {
            super.onSubmit();

            if (!new BeanValidator(this).isValid(dummy)) {
              // execute...
            } else {
              // stay here...
            }
          }
        };

    add(form);
    form.add(new PropertyValidation());
    add(new FeedbackPanel("fb"));
    add(
        new WebMarkupContainer("message") {
          private static final long serialVersionUID = 1L;

          @Override
          public boolean isVisible() {
            return form.isSubmitted() && !form.hasError();
          }
        });

    form.add(new TextField<String>("field1"));
    form.add(new TextField<String>("field2"));
  }
  private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    final IModel<Boolean> editable =
        new LoadableModel<Boolean>(false) {

          @Override
          protected Boolean load() {
            return !isEditing();
          }
        };
    mainForm.add(
        new AjaxCheckBox(ID_EDIT, editable) {

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            editPerformed(target, editable.getObject());
          }
        });
    AceEditor editor =
        new AceEditor(ID_ACE_EDITOR, new PropertyModel<String>(model, ObjectViewDto.F_XML));
    editor.setReadonly(
        new LoadableModel<Boolean>(false) {

          @Override
          protected Boolean load() {
            return isEditing();
          }
        });
    mainForm.add(editor);

    initButtons(mainForm);
  }
예제 #9
0
 private void createMailInput(Form<T> form) {
   TextField<String> emailField = new TextField<String>("user.email");
   emailField.add(EmailAddressValidator.getInstance());
   emailField.add(new ValidatingFormComponentAjaxBehavior());
   form.add(emailField);
   form.add(new AjaxFormComponentFeedbackIndicator("emailValidationError", emailField));
 }
예제 #10
0
  private void initialize() {
    final Form<Void> form = new Form<Void>("form");
    this.add(form);

    // FeedbackPanel //
    final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback");
    form.add(feedback.setOutputMarkupId(true));

    // Sliders //
    final Label label =
        new Label("label", this.model); // the supplied model allows the initial display
    form.add(label);

    form.add(
        new AjaxSlider("slider", this.model, label) {

          private static final long serialVersionUID = 1L;

          @Override
          public void onValueChanged(IPartialPageRequestHandler handler) {
            AjaxSliderPage.this.info(this);
            handler.add(feedback); // do never add 'this' or the form here!
          }
        });
  }
예제 #11
0
  private void init() {
    if (model.getObject() == null) {
      getFeedbackPanel().error("Process not found");
    }
    queue(
        new Label(
            "info",
            new AbstractReadOnlyModel<Object>() {

              @Override
              public Object getObject() {
                BuildJob object = model.getObject();
                return object.toString();
              }
            }));
    form = new Form("form");

    form.add(getLogPanel());
    queue(form);

    kill = new PocessKillButton("kill", model);
    kill2 = new PocessKillButton("kill2", model);
    form.add(kill);
    form.add(kill2);
    rerun1 = new PocessRerunButton("rerun1", model);
    form.add(rerun1);
    rerun2 = new PocessRerunButton("rerun2", model);
    form.add(rerun2);
  }
예제 #12
0
  protected void addOtherFilters(Form<Object> form) {
    inAPeriod = new Model<Boolean>(false);
    form.add(new CheckBox("showNoSite", inAPeriod));

    showPermissionUsers = new Model<Boolean>(true);
    form.add(new CheckBox("showPermissionUsers", showPermissionUsers));
  }
  private void makingReport(PageParameters pageParams) {

    Form form = new Form("nexusAggregationForm");

    String aggDate = pageParams.get("aggDate").toString();
    form.add(new Label("reportTitle", aggDate));
    setLists(ServiceAggregation.accessLogResults);

    this.resulttable = new WebMarkupContainer("resulttable");
    this.resulttable.setVisible(false);
    form.add(resulttable);
    HashMap<String, ? extends ArrayList> urlMappingResult =
        queryApplicationAccessLogGroupByWeek(aggDate);
    form.add(new NexusAccessLogPanel("NexusAggregation", urlMappingResult.get(aggDate)));
    if (getLists() != null) {

      renderPerformanceChartJs(getLists());
    }

    form.add(
        new AjaxButton("backSummary") {

          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            setResponsePage(CBSSummaryPage.class);
          }

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            // TODO Auto-generated method stub

          }
        }.setVisible(false));
    add(form);
  }
예제 #14
0
  private void initDebugUtilForm() {
    Form form = new Form(ID_DEBUG_UTIL_FORM);
    form.setOutputMarkupId(true);
    add(form);

    CheckFormGroup detailed =
        new CheckFormGroup(
            ID_DETAILED_DEBUG_DUMP,
            new PropertyModel<Boolean>(internalsModel, InternalsConfigDto.F_DETAILED_DEBUG_DUMP),
            createStringResource("PageInternals.detailedDebugDump"),
            LABEL_SIZE,
            INPUT_SIZE);
    form.add(detailed);

    AjaxSubmitButton update =
        new AjaxSubmitButton(ID_SAVE_DEBUG_UTIL, createStringResource("PageBase.button.update")) {

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

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
          }
        };
    form.add(update);
  }
  public AjaxDropDownPage() {
    Form<Void> form = new Form<Void>("form");
    this.add(form);

    // FeedbackPanel //
    final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback");
    form.add(feedback.setOutputMarkupId(true));

    // ComboBox //
    final DropDownList<String> dropdown =
        new AjaxDropDownList<String>("select", new Model<String>(), new ListModel<String>(GENRES)) {

          private static final long serialVersionUID = 1L;

          @Override
          public void onSelectionChanged(AjaxRequestTarget target, Form<?> form) {
            String choice = this.getModelObject();

            this.info(choice != null ? choice : "no choice");
            target.add(feedback);
          }
        };

    form.add(dropdown);
  }
  private void initGui() {

    Form<Location> addLocationForm =
        new Form<Location>(
            "addLocationForm",
            new CompoundPropertyModel<Location>((Model<Location>) getDefaultModel()));
    add(addLocationForm);

    Label nameLabel = new Label("nameLabel", new StringResourceModel("locationName", this, null));
    addLocationForm.add(nameLabel);

    addLocationForm.add(createLabelFieldWithValidation());

    Button submitButton =
        new Button("submitButton") {
          @Override
          public void onSubmit() {
            Location location = getLocationFromPageModel();

            if (location.isNew()) {
              locationService.save(location);
              getSession().info(new StringResourceModel("locationAdded", this, null).getString());
            } else {
              locationService.update(location);
              getSession().info(new StringResourceModel("locationUpdated", this, null).getString());
            }

            setResponsePage(LocationsPage.class);
          }
        };
    addLocationForm.add(submitButton);
  }
  public HighlightActionsPanel(String id, final IModel<Restaurant> restaurantModel) {
    super(id);
    setVisible(
        RestaurantWicketSession.get().isSignedIn()
            && RestaurantWicketSession.get().getUser().isAdmin());
    boolean state = restaurantModel.getObject().isHighlighted();

    Form<Void> highlightForm =
        new Form<Void>("highlightForm") {
          @Override
          protected void onSubmit() {
            Restaurant r = restaurantModel.getObject();
            r.highlight();
            setResponsePage(new RestaurantListPage());
          }
        };
    highlightForm.add(new Button("highlight", new ResourceModel("highlight")));
    add(highlightForm);

    Form<Void> unhighlightForm =
        new Form<Void>("unhighlightForm") {
          @Override
          protected void onSubmit() {
            Restaurant r = restaurantModel.getObject();
            r.unhighlight();
            setResponsePage(new RestaurantListPage());
          }
        };
    unhighlightForm.add(new Button("unhighlight", new ResourceModel("unhighlight")));
    add(unhighlightForm);
    unhighlightForm.setVisible(state);
    highlightForm.setVisible(!state);
  }
예제 #18
0
 @Override
 protected void paint() {
   add(listLabel);
   tableForm.add(table);
   tableForm.add(backButton);
   add(tableForm);
   add(feedBackPanel);
 }
예제 #19
0
  protected void addDateFilter(Form<Object> form) {
    DateTime currentDateTime = new DateTime(new Date());
    toDateM = new Model<Date>(currentDateTime.toDate());
    fromDateM = new Model<Date>(currentDateTime.minusMonths(1).toDate());

    form.add(new DateTextField("from", fromDateM));
    form.add(new DateTextField("to", toDateM));
  }
예제 #20
0
  /** Constructor. */
  public ChoicePage() {
    modelsMap.put("AUDI", Arrays.asList("A4", "A6", "TT"));
    modelsMap.put("CADILLAC", Arrays.asList("CTS", "DTS", "ESCALADE", "SRX", "DEVILLE"));
    modelsMap.put("FORD", Arrays.asList("CROWN", "ESCAPE", "EXPEDITION", "EXPLORER", "F-150"));

    IModel<List<? extends String>> makeChoices =
        new AbstractReadOnlyModel<List<? extends String>>() {
          private static final long serialVersionUID = 3083223353505563226L;

          @Override
          public List<String> getObject() {
            return new ArrayList<String>(modelsMap.keySet());
          }
        };

    IModel<List<? extends String>> modelChoices =
        new AbstractReadOnlyModel<List<? extends String>>() {
          private static final long serialVersionUID = -582253860769928261L;

          @Override
          public List<String> getObject() {
            List<String> models = modelsMap.get(selectedMake);
            if (models == null) {
              models = Collections.emptyList();
            }
            return models;
          }
        };

    Form<?> form = new Form("formid");
    add(form);

    final DropDownChoice<String> makes =
        new DropDownChoice<String>(
            "makes", new PropertyModel<String>(this, "selectedMake"), makeChoices);

    final DropDownChoice<String> models =
        new DropDownChoice<String>("models", new Model<String>(), modelChoices);
    models.setOutputMarkupId(true);
    final DropDownChoice<String> models2 =
        new DropDownChoice<String>("models2", new Model<String>(), modelChoices);
    models2.setOutputMarkupId(true);

    form.add(makes);
    form.add(models);
    form.add(models2);

    makes.add(
        new AjaxFormComponentUpdatingBehavior("onchange") {
          private static final long serialVersionUID = -4971073888222316420L;

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            target.add(models);
            target.add(models2);
          }
        });
  }
예제 #21
0
 private void createUsernameInput(Form<T> form) {
   RequiredTextField<String> usernameField = new RequiredTextField<String>("user.username");
   form.add(usernameField);
   usernameField.add(new StringValidator(0, 32));
   usernameField.add(new DuplicateUsernameValidator());
   usernameField.setLabel(new ResourceModel("admin.user.username"));
   usernameField.add(new ValidatingFormComponentAjaxBehavior());
   form.add(new AjaxFormComponentFeedbackIndicator("userValidationError", usernameField));
 }
예제 #22
0
 private void createRoleInput(Form<T> form) {
   ListMultipleChoice<UserRole> userRoles =
       new ListMultipleChoice<UserRole>("user.userRoles", getUserRoles(), new UserRoleRenderer());
   userRoles.setMaxRows(4);
   userRoles.setLabel(new ResourceModel("admin.user.roles"));
   userRoles.setRequired(true);
   userRoles.add(new ValidatingFormComponentAjaxBehavior());
   form.add(userRoles);
   form.add(new AjaxFormComponentFeedbackIndicator("rolesValidationError", userRoles));
 }
예제 #23
0
  private void createNameInput(Form<T> form) {
    TextField<String> firstNameField = new TextField<String>("user.firstName");
    form.add(firstNameField);

    TextField<String> lastNameField = new RequiredTextField<String>("user.lastName");
    form.add(lastNameField);
    lastNameField.setLabel(new ResourceModel("admin.user.lastName"));
    lastNameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("lastNameValidationError", lastNameField));
  }
  public ConsultaTransacoesPage() {
    super();

    form = new Form<Object>("form");
    add(form);

    form.add(novoCampoDataDeReferencia());
    form.add(novoBotaoConsultar());
    form.add(novaListaDeTransacoes());
  }
예제 #25
0
  private void initInternalsConfigForm() {
    Form form = new Form(ID_INTERNALS_CONFIG_FORM);
    form.setOutputMarkupId(true);
    add(form);

    CheckFormGroup consistency =
        new CheckFormGroup(
            ID_CONSISTENCY_CHECKS,
            new PropertyModel<Boolean>(internalsModel, InternalsConfigDto.F_CONSISTENCY_CHECKS),
            createStringResource("PageInternals.checkConsistency"),
            LABEL_SIZE,
            INPUT_SIZE);
    form.add(consistency);
    CheckFormGroup encryption =
        new CheckFormGroup(
            ID_ENCRYPTION_CHECKS,
            new PropertyModel<Boolean>(internalsModel, InternalsConfigDto.F_ENCRYPTION_CHECKS),
            createStringResource("PageInternals.checkEncryption"),
            LABEL_SIZE,
            INPUT_SIZE);
    form.add(encryption);
    CheckFormGroup encryptionRead =
        new CheckFormGroup(
            ID_READ_ENCRYPTION_CHECKS,
            new PropertyModel<Boolean>(internalsModel, InternalsConfigDto.F_READ_ENCRYPTION_CHECKS),
            createStringResource("PageInternals.checkReadEncrypion"),
            LABEL_SIZE,
            INPUT_SIZE);
    form.add(encryptionRead);
    CheckFormGroup tolerateUndeclaredPrefixes =
        new CheckFormGroup(
            ID_TOLERATE_UNDECLARED_PREFIXES,
            new PropertyModel<Boolean>(
                internalsModel, InternalsConfigDto.F_TOLERATE_UNDECLARED_PREFIXES),
            createStringResource("PageInternals.tolerateUndeclaredPrefixes"),
            LABEL_SIZE,
            INPUT_SIZE);
    form.add(tolerateUndeclaredPrefixes);

    AjaxSubmitButton update =
        new AjaxSubmitButton(
            ID_UPDATE_INTERNALS_CONFIG, createStringResource("PageBase.button.update")) {

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

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
          }
        };
    form.add(update);
  }
예제 #26
0
  private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    ImportOptionsPanel importOptions = new ImportOptionsPanel(ID_IMPORT_OPTIONS, model);
    mainForm.add(importOptions);

    final WebMarkupContainer input = new WebMarkupContainer(ID_INPUT);
    input.setOutputMarkupId(true);
    mainForm.add(input);

    final WebMarkupContainer buttonBar = new WebMarkupContainer(ID_BUTTON_BAR);
    buttonBar.setOutputMarkupId(true);
    mainForm.add(buttonBar);

    final IModel<Integer> groupModel = new Model<Integer>(INPUT_FILE);
    RadioGroup importRadioGroup = new RadioGroup(ID_IMPORT_RADIO_GROUP, groupModel);
    importRadioGroup.add(
        new AjaxFormChoiceComponentUpdatingBehavior() {

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            target.add(input);
            target.add(buttonBar);
          }
        });
    mainForm.add(importRadioGroup);

    Radio fileRadio = new Radio(ID_FILE_RADIO, new Model(INPUT_FILE), importRadioGroup);
    importRadioGroup.add(fileRadio);

    Radio xmlRadio = new Radio(ID_XML_RADIO, new Model(INPUT_XML), importRadioGroup);
    importRadioGroup.add(xmlRadio);

    WebMarkupContainer inputAce = new WebMarkupContainer(ID_INPUT_ACE);
    addVisibileForInputType(inputAce, INPUT_XML, groupModel);
    input.add(inputAce);

    AceEditor aceEditor = new AceEditor(ID_ACE_EDITOR, xmlEditorModel);
    aceEditor.setOutputMarkupId(true);
    inputAce.add(aceEditor);

    WebMarkupContainer inputFileLabel = new WebMarkupContainer(ID_INPUT_FILE_LABEL);
    addVisibileForInputType(inputFileLabel, INPUT_FILE, groupModel);
    input.add(inputFileLabel);

    WebMarkupContainer inputFile = new WebMarkupContainer(ID_INPUT_FILE);
    addVisibileForInputType(inputFile, INPUT_FILE, groupModel);
    input.add(inputFile);

    FileUploadField fileInput = new FileUploadField(ID_FILE_INPUT);
    inputFile.add(fileInput);

    initButtons(buttonBar, groupModel);
  }
예제 #27
0
    private void initLayout() {
      final Form searchForm = new Form(ID_SEARCH_FORM);
      add(searchForm);
      searchForm.setOutputMarkupId(true);

      final IModel<ReportOutputSearchDto> model = (IModel) getDefaultModel();

      BasicSearchPanel<ReportOutputSearchDto> basicSearch =
          new BasicSearchPanel<ReportOutputSearchDto>(ID_BASIC_SEARCH, model) {

            @Override
            protected IModel<String> createSearchTextModel() {
              return new PropertyModel<String>(model, UsersDto.F_TEXT);
            }

            @Override
            protected void searchPerformed(AjaxRequestTarget target) {
              PageCreatedReports page = (PageCreatedReports) getPage();
              page.searchPerformed(target);
            }

            @Override
            protected void clearSearchPerformed(AjaxRequestTarget target) {
              PageCreatedReports page = (PageCreatedReports) getPage();
              page.clearSearchPerformed(target);
            }
          };
      searchForm.add(basicSearch);

      DropDownChoice reportTypeSelect =
          new DropDownChoice(
              ID_REPORT_TYPE_SELECT,
              new PropertyModel(model, ReportOutputSearchDto.F_REPORT_TYPE),
              new PropertyModel(model, ReportOutputSearchDto.F_REPORT_TYPES),
              new ChoiceRenderer()) {

            @Override
            protected String getNullValidDisplayValue() {
              return getString("pageCreatedReports.filter.reportType");
            }
          };
      reportTypeSelect.add(
          new OnChangeAjaxBehavior() {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              PageCreatedReports page = (PageCreatedReports) getPage();
              page.searchPerformed(target);
            }
          });
      reportTypeSelect.setOutputMarkupId(true);
      reportTypeSelect.setNullValid(true);
      searchForm.add(reportTypeSelect);
    }
예제 #28
0
 protected void addSiteFilter(Form<Object> form) {
   IModel<List<Site>> allSites = siteService.listSites();
   List<Site> sites = new ArrayList<Site>();
   sites.addAll(allSites.getObject());
   numberOfSites = sites.size();
   showSitesM = new ListModel<Site>(sites);
   if (!allSites.getObject().isEmpty())
     form.add(
         new CheckBoxMultipleChoice<Site>(
             "site", showSitesM, allSites, new ChoiceRenderer<Site>("name", "id")));
   else form.add(new WebMarkupContainer("site").setVisible(false));
 }
  public UploadableProfileImagePanel(String id, final long userId) {
    super(id, userId);
    final Form<Void> form = new Form<Void>("form");
    form.setMultiPart(true);
    form.setMaxSize(Bytes.bytes(getBean(ConfigurationDao.class).getMaxUploadSize()));
    // Model is necessary here to avoid writing image to the User object
    form.add(
        fileUploadField =
            new FileUploadField(
                "image",
                new IModel<List<FileUpload>>() {
                  private static final long serialVersionUID = 1L;

                  // FIXME this need to be eliminated
                  public void detach() {}

                  public void setObject(List<FileUpload> object) {}

                  public List<FileUpload> getObject() {
                    return null;
                  }
                }));
    form.add(new UploadProgressBar("progress", form, fileUploadField));
    fileUploadField.add(
        new AjaxFormSubmitBehavior(form, "onchange") {
          private static final long serialVersionUID = 2160216679027859231L;

          @Override
          protected void onSubmit(AjaxRequestTarget target) {
            FileUpload fu = fileUploadField.getFileUpload();
            if (fu != null) {
              StoredFile sf = new StoredFile(fu.getClientFileName());
              if (sf.isImage()) {
                boolean asIs = sf.isAsIs();
                try {
                  // FIXME need to work with InputStream !!!
                  getBean(GenerateImage.class)
                      .convertImageUserProfile(fu.writeToTempFile(), userId, asIs);
                } catch (Exception e) {
                  // TODO display error
                  e.printStackTrace();
                }
              } else {
                // TODO display error
              }
            }
            target.add(profile, form);
          }
        });
    add(form.setOutputMarkupId(true));
    add(BootstrapFileUploadBehavior.INSTANCE);
  }
예제 #30
0
  private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior =
        new AjaxDownloadBehaviorFromStream() {
          @Override
          protected InputStream initStream() {
            return createReport(this);
          }

          @Override
          public String getFileName() {
            return getReportFileName();
          }
        };

    mainForm.add(ajaxDownloadBehavior);

    ObjectDataProvider provider =
        new ObjectDataProvider(PageCreatedReports.this, ReportOutputType.class) {

          @Override
          protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            ReportsStorage storage = getSessionStorage().getReports();
            storage.setReportOutputsPaging(paging);
          }

          @Override
          public ObjectQuery getQuery() {
            return createQuery();
          }
        };

    BoxedTablePanel table =
        new BoxedTablePanel(
            ID_CREATED_REPORTS_TABLE,
            provider,
            initColumns(ajaxDownloadBehavior),
            UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL,
            (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL)) {

          @Override
          protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(
                headerId, ID_TABLE_HEADER, PageCreatedReports.this, searchModel);
          }
        };
    table.setShowPaging(true);
    table.setOutputMarkupId(true);
    mainForm.add(table);
  }