/**
   * Constructor
   *
   * @param id the markup id
   * @param model the {@link IModel}
   * @param label {@link Label} on which the current slide value will be displayed
   */
  public AbstractSlider(String id, IModel<T> model, Label label) {
    super(id, model);

    label.setDefaultModel(model);
    label.setOutputMarkupId(true);
    this.setLabelId(label.getMarkupId());
  }
  /** tests timer behavior in a WebPage. */
  @Test
  public void addToWebPage() {
    Duration dur = Duration.seconds(20);
    final MyAjaxSelfUpdatingTimerBehavior timer = new MyAjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
    page.add(label);
    page.add(
        new Link<Void>(MockPageWithLinkAndComponent.LINK_ID) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick() {
            // do nothing, link is just used to simulate a roundtrip
          }
        });
    label.setOutputMarkupId(true);
    label.add(timer);

    tester.startPage(page);

    validate(timer, true);

    tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);

    validate(timer, true);
  }
Esempio n. 3
0
 public void updateCommentsCount() {
   viewComments.addOrReplace(
       commentsCount =
           new Label(
               "commentsCount",
               String.valueOf(activeInterviewService.getInterviewComments().size())));
   commentsCount.setOutputMarkupId(true);
 }
 public FailureMessageModal(final PageReference pageRef, final String failureMessage) {
   super(BaseModal.CONTENT_ID);
   final Label executionFailureMessage;
   if (!failureMessage.isEmpty()) {
     executionFailureMessage = new Label("failureMessage", new Model<String>(failureMessage));
   } else {
     executionFailureMessage = new Label("failureMessage");
   }
   add(executionFailureMessage.setOutputMarkupId(true));
 }
Esempio n. 5
0
  private void changeMonth(AjaxEvent ajaxEvent) {
    createModelForMonth(getEhourWebSession().getNavCalendar());

    Component originalForm = get(ID_FRAME + ":" + ID_BLUE_BORDER + ":" + ID_SELECTION_FORM);

    ExportCriteriaPanel replacementPanel = createExportCriteriaPanel(ID_SELECTION_FORM);

    originalForm.replaceWith(replacementPanel);
    ajaxEvent.getTarget().addComponent(replacementPanel);

    Label newLabel = getTitleLabel(getEhourWebSession().getNavCalendar());
    newLabel.setOutputMarkupId(true);
    titleLabel.replaceWith(newLabel);
    titleLabel = newLabel;
    ajaxEvent.getTarget().addComponent(newLabel);
  }
Esempio n. 6
0
  public HomePage(final PageParameters parameters) {
    super(parameters);

    final Label toReplace = new Label("toReplace", "Initial content");
    toReplace.setOutputMarkupId(true);
    add(toReplace);

    AjaxLink<Void> link =
        new AjaxLink<Void>("link") {
          @Override
          public void onClick(AjaxRequestTarget target) {
            toReplace.setDefaultModelObject("New value");
            Effects.replace(target, toReplace);
          }
        };
    add(link);
  }
Esempio n. 7
0
  public ExportMonthSelectionPage(Calendar forMonth) {
    super(new ResourceModel("printMonth.title"));

    setDefaultModel(createModelForMonth(forMonth));

    add(createCalendarPanel("sidePanel"));

    titleLabel = getTitleLabel(forMonth);
    titleLabel.setOutputMarkupId(true);

    add(
        new ContextualHelpPanel(
            "contextHelp", "printMonth.help.header", "printMonth.help.body", "Export+month"));

    CustomTitledGreyRoundedBorder greyBorder =
        new CustomTitledGreyRoundedBorder(ID_FRAME, titleLabel);
    GreyBlueRoundedBorder blueBorder = new GreyBlueRoundedBorder(ID_BLUE_BORDER);
    greyBorder.add(blueBorder);
    add(greyBorder);

    blueBorder.add(createExportCriteriaPanel(ID_SELECTION_FORM));
  }
  public RangeTextFieldDemo() {

    Model<Double> model = Model.of(2.3d);

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

    RangeTextField<Double> rangeTextField =
        new RangeTextField<Double>("range", model, Double.class);
    form.add(rangeTextField);

    rangeTextField.setMinimum(1.4d);
    rangeTextField.setMaximum(10.0d);

    final Label rangeLabel = new Label("rangeLabel", model);
    rangeLabel.setOutputMarkupId(true);
    add(rangeLabel);

    rangeTextField.add(
        new AjaxFormComponentUpdatingBehavior("change") {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            target.add(rangeLabel);
          }

          @Override
          protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);

            ThrottlingSettings throttleSettings =
                new ThrottlingSettings("rangeTextFieldDemoId", Duration.milliseconds(500));
            attributes.setThrottlingSettings(throttleSettings);
          }
        });
  }
Esempio n. 9
0
  public AlertWidget(final String id) {
    super(id);
    this.latestAlerts = getLatestAlerts();

    setOutputMarkupId(true);

    final LoadableDetachableModel<Integer> size =
        new LoadableDetachableModel<Integer>() {

          private static final long serialVersionUID = 7474274077691068779L;

          @Override
          protected Integer load() {
            return AlertWidget.this.latestAlerts.getObject().size();
          }
        };

    final LoadableDetachableModel<List<T>> items =
        new LoadableDetachableModel<List<T>>() {

          private static final long serialVersionUID = 7474274077691068779L;

          @Override
          protected List<T> load() {
            final List<T> latest = AlertWidget.this.latestAlerts.getObject();
            return latest.subList(0, latest.size() < 6 ? latest.size() : 5);
          }
        };

    add(getIcon("icon"));

    linkAlertsNumber =
        new Label("alerts", size) {

          private static final long serialVersionUID = 4755868673082976208L;

          @Override
          protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);
            if (Integer.valueOf(getDefaultModelObject().toString()) > 0) {
              tag.put("class", "label label-danger");
            } else {
              tag.put("class", "label label-info");
            }
          }
        };
    add(linkAlertsNumber.setOutputMarkupId(true));

    headerAlertsNumber = new Label("number", size);
    headerAlertsNumber.setOutputMarkupId(true);
    add(headerAlertsNumber);

    latestAlertsList = new WebMarkupContainer("latestAlertsList");
    latestAlertsList.setOutputMarkupId(true);
    add(latestAlertsList);

    latestFive =
        new ListView<T>("latestAlerts", items) {

          private static final long serialVersionUID = 4949588177564901031L;

          @Override
          protected void populateItem(final ListItem<T> item) {
            item.add(getAlertLink("alert", item.getModelObject()).setRenderBodyOnly(true));
          }
        };
    latestAlertsList.add(latestFive.setReuseItems(false).setOutputMarkupId(true));

    add(getEventsLink("alertsLink"));
  }
    public AdminOrderPageForm(String id) {
      super(id);

      errorPanel = new FeedbackPanel("feedback");
      username = new TextField<String>("username", Model.of(""));
      email = new TextField<String>("email", Model.of(""));
      countryCostModel = Model.of("");
      hotelCostModel = Model.of("");
      tourCostModel = Model.of("");

      countryCost = new Label("countryCostLabel", countryCostModel);
      hotelCost = new Label("hotelCostLabel", hotelCostModel);
      tourCost = new Label("tourCostLabel", tourCostModel);

      order = new Order();
      orderDao = new OrderDao();
      hotelOptions = new HashMap<String, List<String>>();
      tourOptions = new HashMap<String, List<String>>();

      countries = orderDao.getCountries();
      hotels = orderDao.getHotels();
      tours = orderDao.getTours();

      for (OrderObject country : countries) {
        hotelOptions.put(country.getName(), getNames(hotels, country.getName()));
        tourOptions.put(country.getName(), getNames(tours, country.getName()));
      }

      IModel<List<? extends String>> makeCountryChoises =
          new AbstractReadOnlyModel<List<? extends String>>() {
            @Override
            public List<String> getObject() {
              return new ArrayList<String>(hotelOptions.keySet());
            }
          };

      IModel<List<? extends String>> modelTownChoices =
          new AbstractReadOnlyModel<List<? extends String>>() {
            @Override
            public List<String> getObject() {
              List<String> models = hotelOptions.get(selectedOption);
              if (models == null) {
                models = Collections.emptyList();
              }
              return models;
            }
          };

      IModel<List<? extends String>> modelTourChoices =
          new AbstractReadOnlyModel<List<? extends String>>() {
            @Override
            public List<String> getObject() {
              List<String> models = tourOptions.get(selectedOption);
              if (models == null) {
                models = Collections.emptyList();
              }
              return models;
            }
          };

      countryDropDown =
          new DropDownChoice<String>(
              "countryDropDown",
              new PropertyModel<String>(this, "selectedOption"),
              makeCountryChoises);

      hotelDropDown =
          new DropDownChoice<String>(
              "hotelDropDown", new PropertyModel<String>(this, "selectedHotel"), modelTownChoices);

      tourDropDown =
          new DropDownChoice<String>(
              "tourDropDown", new PropertyModel<String>(this, "selectedTour"), modelTourChoices);
      totalCostSumModel = new PropertyModel<String>(this, "calculatedTotalCostSum");
      totalCostSum = new TextField("totalCostSumLabel", totalCostSumModel);

      hotelDropDown.setOutputMarkupId(true);
      tourDropDown.setOutputMarkupId(true);
      countryCost.setOutputMarkupId(true);
      hotelCost.setOutputMarkupId(true);
      tourCost.setOutputMarkupId(true);
      totalCostSum.setOutputMarkupId(true);

      countryDropDown.add(
          new AjaxFormComponentUpdatingBehavior("onchange") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              target.add(hotelDropDown);
              target.add(tourDropDown);

              String cost = getCost(countries, selectedOption);
              countryCostModel.setObject(cost);
              hotelCostModel.setObject(getCost(hotels, selectedHotel));
              tourCostModel.setObject(getCost(tours, selectedTour));
              totalCostSumModel.setObject(getTotalCostSum());

              target.add(countryCost);
              target.add(hotelCost);
              target.add(tourCost);
              target.add(totalCostSum);
            }
          });
      hotelDropDown.add(
          new AjaxFormComponentUpdatingBehavior("onchange") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              hotelCostModel.setObject(getCost(hotels, selectedHotel));
              totalCostSumModel.setObject(getTotalCostSum());
              target.add(hotelCost);
              target.add(totalCostSum);
            }
          });
      tourDropDown.add(
          new AjaxFormComponentUpdatingBehavior("onchange") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
              tourCostModel.setObject(getCost(tours, selectedTour));
              totalCostSumModel.setObject(getTotalCostSum());
              target.add(tourCost);
              target.add(totalCostSum);
            }
          });
      add(new Label("feedBack", feedBack));
      add(errorPanel);
      add(username);
      add(email);
      add(countryDropDown);
      add(hotelDropDown);
      add(tourDropDown);
      add(countryCost);
      add(hotelCost);
      add(tourCost);
      add(totalCostSum);
    }
Esempio n. 11
0
  private void build() {

    feedbackPanel = new FeedbackPanel("feedback");
    add(feedbackPanel);

    form = new Form("questionForm");
    form.setOutputMarkupId(true);

    questionTitleField = new TextField("questionTitleField", new Model(""));
    questionTitleField.setRequired(true);
    questionTitleField.add(new FocusOnLoadBehavior());
    form.add(questionTitleField);

    if (question.getType().equals(Question.QuestionType.ALTER)) {
      form.add(new Label("promptHelpText", "(Refer to the alter as $$)"));
    } else if (question.getType().equals(Question.QuestionType.ALTER_PAIR)) {
      form.add(new Label("promptHelpText", "(Refer to the alters as $$1 and $$2)"));
    } else {
      form.add(new Label("promptHelpText", ""));
    }

    numericLimitsPanel = new NumericLimitsPanel("numericLimitsPanel", question);
    form.add(numericLimitsPanel);
    numericLimitsPanel.setVisible(false);

    multipleSelectionLimitsPanel = new MultipleSelectionLimitsPanel("multipleSelectionLimitsPanel");
    form.add(multipleSelectionLimitsPanel);
    multipleSelectionLimitsPanel.setVisible(false);

    timeUnitsPanel = new TimeUnitsPanel("timeUnitsPanel", question);
    form.add(timeUnitsPanel);
    timeUnitsPanel.setVisible(false);

    listLimitsPanel = new ListLimitsPanel("listLimitsPanel", question);
    form.add(listLimitsPanel);
    listLimitsPanel.setVisible(question.getAskingStyleList());

    questionPromptField = new TextArea("questionPromptField", new Model(""));
    questionPromptField.setRequired(true);
    form.add(questionPromptField);

    questionPrefaceField = new TextArea("questionPrefaceField", new Model(""));
    form.add(questionPrefaceField);

    questionCitationField = new TextArea("questionCitationField", new Model(""));
    form.add(questionCitationField);

    questionResponseTypeModel = new Model(Answer.AnswerType.TEXTUAL); // Could also leave this null.
    dropDownQuestionTypes =
        new DropDownChoice(
            "questionResponseTypeField",
            questionResponseTypeModel,
            Arrays.asList(Answer.AnswerType.values()));

    dropDownQuestionTypes.add(
        new AjaxFormComponentUpdatingBehavior("onchange") {
          protected void onUpdate(AjaxRequestTarget target) {
            onSelectionChanged(Integer.parseInt(dropDownQuestionTypes.getModelValue()));
            // target.addComponent(form);
            target.addComponent(numericLimitsPanel);
            target.addComponent(multipleSelectionLimitsPanel);
            target.addComponent(noneButtonLabel);
            target.addComponent(noneButtonCheckBox);
            target.addComponent(otherSpecifyLabel);
            target.addComponent(otherSpecifyCheckBox);
            target.addComponent(timeUnitsPanel);
            target.addComponent(listLimitsPanel);
          }
        });

    form.add(dropDownQuestionTypes);

    questionAnswerReasonModel = new Model(answerAlways);
    List<Object> answerChoices = new ArrayList<Object>();
    answerChoices.add(answerAlways);
    for (Expression expression : Expressions.forStudy(question.getStudyId())) {
      answerChoices.add(expression);
    }
    form.add(
        new DropDownChoice("questionAnswerReasonField", questionAnswerReasonModel, answerChoices));

    Label askingStyleListLabel = new Label("askingStyleListLabel", "Ask with list of alters:");
    askingStyleModel = new Model();
    askingStyleModel.setObject(Boolean.FALSE);
    AjaxCheckBox askingStyleListField =
        new AjaxCheckBox("askingStyleListField", askingStyleModel) {
          protected void onUpdate(AjaxRequestTarget target) {
            Boolean listLimitsVisible = false;

            if (questionResponseTypeModel.getObject().equals(Answer.AnswerType.MULTIPLE_SELECTION)
                || questionResponseTypeModel.getObject().equals(Answer.AnswerType.SELECTION))
              listLimitsVisible = (Boolean) askingStyleModel.getObject();

            listLimitsPanel.setVisible(listLimitsVisible);
            target.addComponent(form);
          }
        };
    askingStyleListLabel.setOutputMarkupId(true);
    askingStyleListLabel.setOutputMarkupPlaceholderTag(true);
    askingStyleListField.setOutputMarkupId(true);
    askingStyleListField.setOutputMarkupPlaceholderTag(true);
    form.add(askingStyleListLabel);
    form.add(askingStyleListField);
    if (question.getType().equals(Question.QuestionType.EGO)
        || question.getType().equals(Question.QuestionType.EGO_ID)) {
      askingStyleListLabel.setVisible(false);
      askingStyleListField.setVisible(false);
    }

    otherSpecifyLabel = new Label("otherSpecifyLabel", "Other/Specify Type Question?: ");
    otherSpecifyModel = new Model();
    otherSpecifyModel.setObject(Boolean.FALSE);
    otherSpecifyCheckBox = new CheckBox("otherSpecifyField", otherSpecifyModel);
    form.add(otherSpecifyLabel);
    form.add(otherSpecifyCheckBox);
    otherSpecifyLabel.setOutputMarkupId(true);
    otherSpecifyCheckBox.setOutputMarkupId(true);
    otherSpecifyLabel.setOutputMarkupPlaceholderTag(true);
    otherSpecifyCheckBox.setOutputMarkupPlaceholderTag(true);
    noneButtonLabel = new Label("noneButtonLabel", "NONE Button?: ");
    noneButtonModel = new Model();
    noneButtonModel.setObject(Boolean.FALSE);
    noneButtonCheckBox = new CheckBox("noneButtonField", noneButtonModel);
    form.add(noneButtonLabel);
    form.add(noneButtonCheckBox);
    noneButtonLabel.setOutputMarkupId(true);
    noneButtonCheckBox.setOutputMarkupId(true);
    noneButtonLabel.setOutputMarkupPlaceholderTag(true);
    noneButtonCheckBox.setOutputMarkupPlaceholderTag(true);
    noneButtonLabel.setVisible(false);
    noneButtonCheckBox.setVisible(false);

    // questionUseIfField = new TextField("questionUseIfField", new Model(""));
    // form.add(questionUseIfField);

    form.add(
        new AjaxFallbackButton("submitQuestion", form) {
          @Override
          public void onSubmit(AjaxRequestTarget target, Form form) {
            insertFormFieldsIntoQuestion(question);
            if (question.getId() == null) {
              List<Question> questions =
                  Questions.getQuestionsForStudy(question.getStudyId(), question.getType());
              questions.add(question);
              for (Integer i = 0; i < questions.size(); i++) {
                questions.get(i).setOrdering(i);
                DB.save(questions.get(i));
              }
            } else {
              DB.save(question);
            }
            form.setVisible(false);
            target.addComponent(parentThatNeedsUpdating);
            target.addComponent(form);
          }
        });
    add(form);

    setFormFieldsFromQuestion(question);
  }
  public TCViewBibliographyTab(
      final String id,
      IModel<TCEditableObject> model,
      TCAttributeVisibilityStrategy attrVisibilityStrategy) {
    super(id, model, attrVisibilityStrategy);

    list =
        new ListView<String>("tc-view-bibliography-list", new ListModelWrapper()) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void populateItem(final ListItem<String> item) {
            // textarea
            final TextArea<String> area =
                new SelfUpdatingTextArea("tc-view-bibliography-text", item.getModelObject()) {
                  @Override
                  protected void textUpdated(String text) {
                    ((ListModelWrapper) list.getModel()).setReference(item.getIndex(), text);
                  }
                };
            area.setOutputMarkupId(true);
            area.setEnabled(isEditing());
            area.add(createTextInputCssClassModifier());

            // remove button
            final AbstractLink removeBtn =
                new AjaxLink<Void>("tc-view-bibliography-remove-btn") {
                  @Override
                  public void onClick(AjaxRequestTarget target) {
                    try {
                      ((ListModelWrapper) list.getModel()).removeReference(item.getIndex());

                      target.addComponent(title);
                      target.addComponent(listContainer);
                      target.appendJavascript("updateTCViewDialog();");

                      tabTitleChanged(target);

                      if (tabTitleComponent != null) {
                        target.addComponent(tabTitleComponent);
                      }
                    } catch (Exception e) {
                      log.error("Removing bibliographic reference from teaching-file failed!", e);
                    }
                  }
                };
            removeBtn.add(
                new Image("tc-view-bibliography-remove-img", ImageManager.IMAGE_TC_CANCEL_MONO)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")));
            removeBtn.add(new TooltipBehaviour("tc.view.bibliography", "remove"));
            removeBtn.setOutputMarkupId(true);
            removeBtn.setVisible(isEditing());
            removeBtn.add(
                new AttributeModifier(
                    "onmouseover",
                    true,
                    new Model<String>(
                        "$(this).children('img').attr('src','"
                            + RequestCycle.get().urlFor(ImageManager.IMAGE_TC_CANCEL)
                            + "');")));
            removeBtn.add(
                new AttributeModifier(
                    "onmouseout",
                    true,
                    new Model<String>(
                        "$(this).children('img').attr('src','"
                            + RequestCycle.get().urlFor(ImageManager.IMAGE_TC_CANCEL_MONO)
                            + "');")));

            item.setOutputMarkupId(true);
            item.add(area);
            item.add(removeBtn);
          }
        };

    listContainer = new WebMarkupContainer("tc-view-bibliography-container");
    listContainer.setOutputMarkupId(true);
    listContainer.setMarkupId("tc-view-bibliography-container");
    listContainer.add(list);

    title =
        new Label(
            "tc-view-bibliography-title-text",
            new AbstractReadOnlyModel<String>() {
              @Override
              public String getObject() {
                String s = title.getString("tc.view.bibliography.number.text");
                List<String> refs = list.getModelObject();
                return MessageFormat.format(s, refs != null ? refs.size() : 0);
              }
            });
    title.setOutputMarkupId(true);

    addBtn =
        new AjaxLink<Void>("tc-view-bibliography-add-btn") {
          @Override
          public void onClick(AjaxRequestTarget target) {
            try {
              ((ListModelWrapper) list.getModel())
                  .addReference(addBtn.getString("tc.view.bibliography.reference.defaulttext"));

              target.addComponent(title);
              target.addComponent(listContainer);
              target.appendJavascript("updateTCViewDialog();");

              tabTitleChanged(target);

              if (tabTitleComponent != null) {
                target.addComponent(tabTitleComponent);
              }
            } catch (Exception e) {
              log.error("Adding new bibliographic reference to teachign-file failed!", e);
            }
          }
        };
    addBtn.add(
        new Image("tc-view-bibliography-add-img", ImageManager.IMAGE_COMMON_ADD)
            .add(new ImageSizeBehaviour("vertical-align: middle;")));
    addBtn.add(
        new Label(
            "tc-view-bibliography-add-text", new ResourceModel("tc.view.bibliography.add.text")));
    addBtn.add(new TooltipBehaviour("tc.view.bibliography", "add"));
    addBtn.setMarkupId("tc-view-bibliography-add-btn");

    title.setEnabled(isEditing());
    addBtn.setVisible(isEditing());
    listContainer.setEnabled(isEditing());

    add(title);
    add(addBtn);
    add(listContainer);
  }
  /**
   * Validates the response, then makes sure the timer injects itself again when called. Tests
   * {@link AbstractAjaxTimerBehavior#restart(AjaxRequestTarget)} method
   *
   * <p>WICKET-1525, WICKET-2152
   */
  public void testRestartMethod() {
    final Integer labelInitialValue = Integer.valueOf(0);

    final Label label =
        new Label(MockPageWithLinkAndComponent.COMPONENT_ID, new Model<Integer>(labelInitialValue));

    // the duration doesn't matter because we manually trigger the behavior
    final AbstractAjaxTimerBehavior timerBehavior =
        new AbstractAjaxTimerBehavior(Duration.seconds(2)) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onTimer(AjaxRequestTarget target) {
            // increment the label's model object
            label.setDefaultModelObject(((Integer) label.getDefaultModelObject()) + 1);
            target.add(label);
          }
        };

    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    page.add(label);
    page.add(
        new AjaxLink<Void>(MockPageWithLinkAndComponent.LINK_ID) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            if (timerBehavior.isStopped()) {
              timerBehavior.restart(target);
            } else {
              timerBehavior.stop(target);
            }
          }
        });

    label.setOutputMarkupId(true);
    label.add(timerBehavior);

    tester.startPage(page);

    final String labelPath = MockPageWithLinkAndComponent.COMPONENT_ID;

    // assert label == initial value (i.e. 0)
    tester.assertLabel(labelPath, String.valueOf(labelInitialValue));

    // increment to 1
    tester.executeBehavior(timerBehavior);

    // assert label == 1
    tester.assertLabel(labelPath, String.valueOf(labelInitialValue + 1));

    // stop the timer
    tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);

    // trigger it, but it is stopped
    tester.executeBehavior(timerBehavior);

    // assert label is still 1
    tester.assertLabel(labelPath, String.valueOf(labelInitialValue + 1));

    // restart the timer
    tester.clickLink(MockPageWithLinkAndComponent.LINK_ID);

    // increment to 2
    tester.executeBehavior(timerBehavior);

    // assert label is now 2
    tester.assertLabel(labelPath, String.valueOf(labelInitialValue + 2));
  }
  private void constructPageComponent() {
    add(new FeedbackPanel("errorMessages"));

    errorMsg =
        new Label(
            "smsAuthenticationError", getLocalizer().getString("smsAuthentication.error", this));
    errorMsg.setVisible(false);
    errorMsg.setOutputMarkupId(true);
    errorMsg.setOutputMarkupPlaceholderTag(true);

    final WebMarkupContainer backDiv = new WebMarkupContainer("backDiv");
    backDiv.setOutputMarkupId(true);
    backDiv.setVisible(false);
    backDiv.setOutputMarkupPlaceholderTag(true);
    Form<?> backForm = new Form("backForm", new CompoundPropertyModel<SmsAuthenticationPage>(this));
    backForm.add(
        new Button("back") {
          @Override
          public void onSubmit() {
            // TODO
          }
        });
    backDiv.add(backForm);

    retryDiv = new WebMarkupContainer("retryDiv");
    retryDiv.setOutputMarkupId(true);
    retryDiv.setOutputMarkupPlaceholderTag(true);
    retryDiv.setVisible(false);
    Form<?> retryForm =
        new Form("retryForm", new CompoundPropertyModel<SmsAuthenticationPage>(this));
    retryForm.add(
        new Button("retry") {
          @Override
          public void onSubmit() {
            // TODO
          }
        });
    retryDiv.add(retryForm);

    cancelDiv = new WebMarkupContainer("cancelDiv");
    cancelDiv.setOutputMarkupId(true);
    cancelDiv.setOutputMarkupPlaceholderTag(true);
    cancelDiv.setVisible(false);
    Form<?> cancelForm =
        new Form("cancelForm", new CompoundPropertyModel<SmsAuthenticationPage>(this));
    cancelForm.add(
        new Button("cancel") {
          @Override
          public void onSubmit() {
            // TODO
          }
        }.setVisible(false));
    cancelDiv.add(cancelForm);

    final AbstractDefaultAjaxBehavior behave =
        new AbstractDefaultAjaxBehavior() {
          protected void respond(final AjaxRequestTarget target) {
            if (!isRedirected) {
              checkStatus(target);
            }
          }
        };
    add(behave);

    Form<?> ajaxForm =
        new Form("ajaxForm", new CompoundPropertyModel<SmsAuthenticationPage>(this)) {
          @Override
          protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.put("action", behave.getCallbackUrl());
          }
        };
    add(errorMsg);
    add(backDiv);
    add(retryDiv);
    add(cancelDiv);
    add(ajaxForm);
  }