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 addOptionalFormAttributes(ExtendedForm form) {
    final Form<?> optionalContainer = new Form<Object>("optional");
    optionalContainer.setOutputMarkupId(true);
    optionalContainer.setOutputMarkupPlaceholderTag(true);
    optionalContainer.setVisible(false);
    form.add(optionalContainer);
    addToggleOptionalCheckBox(form, optionalContainer);

    FormUtils.addGenericField(optionalContainer, "xdsRegistry", xdsRegistry, false, false);
    FormUtils.addGenericField(optionalContainer, "xdsRepository", xdsRepository, false, false);

    optionalContainer.add(
        new Label("xdsSourceUrl.label", new ResourceModel("dicom.edit.xds.xdsSourceUrl.label"))
            .setOutputMarkupPlaceholderTag(true));
    optionalContainer.add(
        new TextField<String>("xdsSourceUrl", xdsSourceUrlModel).setType(String.class));
  }
  private void createAttachmentContainer(final Form form) {
    final WebMarkupContainer attachmentContainer = new WebMarkupContainer("attachmentContainer");
    attachmentContainer.setOutputMarkupPlaceholderTag(true);
    forceReload = true;
    isAttachmentContainerVisible =
        isAttachmentContainerVisible
            && (message.getAttachments().size() > 0 || PortalUtils.exists(attachmentsList));
    createAttachmentsListDataView(attachmentContainer, form);
    final WebMarkupContainer addAttachmentContainer =
        new WebMarkupContainer("addAttachmentContainer");
    final Form<?> addAttachmentForm =
        new Form("addAttachmentForm", new CompoundPropertyModel<NotificationMessagePanel>(this));

    addAttachmentForm.add(
        new KeyValueDropDownChoice<Long, String>("attachmentAdd", attachmentsList)
            .setVisible(PortalUtils.exists(attachmentsList)));
    addAttachmentForm.setOutputMarkupPlaceholderTag(true);
    addAttachmentForm.add(
        new Button("add") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            message.getAttachments().add(attachmentAdd);
            try {
              if (updateMessage()) {
                info(getLocalizer().getString("add.attachment.success", this));
                forceReload = true;
                getAttachments();
                createAttachmentContainer(form);
              }
            } catch (Exception e) {
              error(getLocalizer().getString("add.attachment.error", this));
              LOG.error("Error in attaching attachment with message", e);
            }
          }
        });

    addAttachmentForm.add(
        new AjaxLink("cancel") {

          @Override
          public void onClick(AjaxRequestTarget target) {
            addAttachmentContainer.setVisible(false);
            target.addComponent(addAttachmentContainer);
          }
        });
    addAttachmentContainer.setVisible(false);
    addAttachmentContainer.add(addAttachmentForm);
    addAttachmentContainer.setOutputMarkupPlaceholderTag(true);
    attachmentContainer.addOrReplace(addAttachmentContainer);
    attachmentContainer.addOrReplace(
        new AjaxLink("addAttachment") {

          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            addAttachmentContainer.setVisible(true);
            target.addComponent(addAttachmentContainer);
          }
        }.setVisible(PortalUtils.exists(attachmentsList)));
    attachmentContainer.setVisible(isAttachmentContainerVisible);
    form.addOrReplace(attachmentContainer);
  }