Ejemplo n.º 1
1
  @Override
  protected void onConfigure() {
    super.onConfigure();

    // set all components visible
    Components.show(help, label, feedback);

    // clear feedback message and current state
    stateClassName.setObject("");
    feedback.setDefaultModelObject("");

    final List<FormComponent<?>> formComponents = findFormComponents();
    for (final FormComponent<?> fc : formComponents) {
      final FeedbackMessages messages = fc.getFeedbackMessages();

      if (!messages.isEmpty()) {
        final FeedbackMessage worstMessage = getWorstMessage(messages);
        worstMessage.markRendered();

        stateClassName.setObject(toClassName(worstMessage));
        feedback.setDefaultModelObject(worstMessage.getMessage());

        break; // render worst message of first found child component with feedback message
      }
    }

    Components.hideIfModelIsEmpty(help);
    Components.hideIfModelIsEmpty(label);
    Components.hideIfModelIsEmpty(feedback);
  }
Ejemplo n.º 2
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"));
  }
Ejemplo n.º 3
0
  public GlossResultsSeparatedPanel(String id, IModel<List<SegmentedWord>> model) {
    super(id, model);

    Form<List<SegmentedWord>> form = new Form<>("form", model);
    add(form);

    Border textBorder =
        new HeaderPanel(
            "text",
            hid ->
                new HeaderButtonTitlePanel(
                    hid,
                    Model.of("Text"),
                    bid ->
                        new EditButton(bid, new ResourceModel("label.edit")).setSize(Size.Small)));
    form.add(textBorder);

    textBorder.add(
        new ListView<>(
            "text",
            model,
            item -> {
              ExternalLink link =
                  new ExternalLink(
                      "word",
                      Model.of("#def_link_" + item.getIndex()),
                      new LambdaModel<>(
                          item.getModel(), new OptionalFunction<>(SegmentedWord.FUNCTION_TEXT)));
              link.add(
                  new EnabledModelBehavior(
                      new SupplierModel<>(() -> item.getModelObject().hasDefinition())));
              link.setMarkupId("word_link_" + item.getIndex());
              item.add(link);
            }));

    Border defBorder = new HeaderPanel("defs", Model.of("Definitions"));
    form.add(defBorder);

    defBorder.add(
        new ListView<>(
            "defs",
            model,
            item ->
                item.add(
                        new WordPartsListPanel(
                            "def",
                            item.getModel(),
                            new SupplierModel<>(() -> "#word_link_" + item.getIndex())))
                    .setMarkupId("def_link_" + item.getIndex())
                    .add(
                        new VisibleModelBehavior(
                            new SupplierModel<>(() -> item.getModelObject().hasDefinition())))));
  }
  @Test
  public void border_nested() {
    MarkupContainer a = new A(), b = new B(), c = new C(), d = new D(), r = new R(), s = new S();

    Border outerBorder = new OuterBorder("outerBorder");

    Border innerBorder = new InnerBorder("innerBorder");

    outerBorder.queueToBorder(r, innerBorder);

    innerBorder.queueToBorder(c, d);

    outerBorder.queueToBorder(s);

    TestPage p = new TestPage();
    p.setPageMarkup("<p wicket:id='a'><p wicket:id='outerBorder'><p wicket:id='b'></p></p></p>");

    p.queue(b, outerBorder, a);

    tester.startPage(p);

    assertThat(
        p,
        hasPath(new Path(a, outerBorder, r, innerBorder, c, d, innerBorder.getBodyContainer(), s)));
    assertThat(p, hasPath(new Path(a, outerBorder, r, outerBorder.getBodyContainer(), b)));
  }
Ejemplo n.º 5
0
 public BaseUsersPage add(final Component child) {
   // Add children of the page to the page's border component
   if (border == null) {
     // Create border and add it to the page
     border = new UsersBorder();
     super.add(border);
   }
   border.add(child);
   return this;
 }
Ejemplo n.º 6
0
  @Override
  protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    checkComponentTag(tag, "div");
    Attributes.addClass(tag, "form-group", stateClassName.getObject());
    if (size != null) {
      Attributes.addClass(tag, size.cssClassName());
    }
  }
Ejemplo n.º 7
0
  @Override
  protected void onInitialize() {
    super.onInitialize();

    this.label = newLabel("label", labelModel);
    this.help = newHelpLabel("help", helpModel);
    this.feedback = newFeedbackMessageContainer("error");
    addToBorder(this.label, this.help, this.feedback);

    final List<FormComponent<?>> formComponents = findFormComponents();
    final int size = formComponents.size();

    if (size > 0) {
      addOutputMarkupId(formComponents);

      final FormComponent<?> formComponent = formComponents.get(size - 1);
      label.add(new AttributeModifier("for", formComponent.getMarkupId()));

      if (useFormComponentLabel) {
        if (formComponent.getLabel() != null
            && !Strings.isEmpty(formComponent.getLabel().getObject())) {
          label.setDefaultModel(formComponent.getLabel());
        } else {
          label.setDefaultModel(
              new LoadableDetachableModel<String>() {
                @Override
                protected String load() {
                  String text = formComponent.getDefaultLabel("wicket:unknown");
                  if (!"wicket:unknown".equals(text) && !Strings.isEmpty(text)) {
                    return text;
                  } else {
                    return labelModel.getObject();
                  }
                }
              });
        }
      }
    }
  }
Ejemplo n.º 8
0
 @Override
 public MarkupContainer replace(final Component child) {
   return border.replace(child);
 }
Ejemplo n.º 9
0
 @Override
 public MarkupContainer removeAll() {
   border.removeAll();
   return this;
 }
Ejemplo n.º 10
0
  @Override
  protected void doInitialize(Border layout) {
    add(layout);

    DSLContext context = Spring.getBean(DSLContext.class);
    MenuTable menuTable = Tables.MENU.as("menuTable");
    SectionTable sectionTable = Tables.SECTION.as("sectionTable");

    this.form = new Form<>("form");
    layout.add(this.form);

    this.orderField = new TextField<>("orderField", new PropertyModel<>(this, "order"));
    this.orderField.setRequired(true);
    this.form.add(this.orderField);
    this.orderFeedback = new TextFeedbackPanel("orderFeedback", this.orderField);
    this.form.add(this.orderFeedback);

    this.titleField = new TextField<>("titleField", new PropertyModel<>(this, "title"));
    this.titleField.setRequired(true);
    this.form.add(this.titleField);
    this.titleFeedback = new TextFeedbackPanel("titleFeedback", this.titleField);
    this.form.add(this.titleFeedback);

    this.iconField = new TextField<>("iconField", new PropertyModel<>(this, "icon"));
    this.iconField.setRequired(true);
    this.form.add(this.iconField);
    this.iconFeedback = new TextFeedbackPanel("iconFeedback", this.iconField);
    this.form.add(this.iconFeedback);

    this.menuParents = context.select(menuTable.fields()).from(menuTable).fetchInto(MenuPojo.class);
    this.parentField =
        new DropDownChoice<>(
            "parentField",
            new PropertyModel<>(this, "menuParent"),
            new PropertyModel<>(this, "menuParents"),
            new MenuChoiceRenderer());
    this.parentField.setNullValid(true);
    this.form.add(this.parentField);
    this.parentFeedback = new TextFeedbackPanel("parentFeedback", this.parentField);
    this.form.add(this.parentFeedback);

    this.sections =
        context.select(sectionTable.fields()).from(sectionTable).fetchInto(SectionPojo.class);
    this.sectionField =
        new DropDownChoice<>(
            "sectionField",
            new PropertyModel<>(this, "section"),
            new PropertyModel<>(this, "sections"),
            new SectionChoiceRenderer());
    this.sectionField.setNullValid(true);
    this.form.add(this.sectionField);
    this.sectionFeedback = new TextFeedbackPanel("sectionFeedback", this.sectionField);
    this.form.add(this.sectionFeedback);

    this.saveButton = new Button("saveButton");
    this.saveButton.setOnSubmit(this::saveButtonOnSubmit);
    this.form.add(this.saveButton);

    this.closeButton = new BookmarkablePageLink<>("closeButton", MenuBrowsePage.class);
    this.form.add(this.closeButton);

    this.form.add(new MenuFormValidator(this.parentField, this.sectionField));
  }