Java Code Examples for org.apache.wicket.markup.html.form.Form#setVisible()

The following examples show how to use org.apache.wicket.markup.html.form.Form#setVisible() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Orienteer   File: GenericTablePanel.java    License: Apache License 2.0 5 votes vote down vote up
public GenericTablePanel(String id, IModel<String> errorMessage) {
    super(id);
    dataTable = null;
    Form form = new Form("form");
    form.add(new EmptyPanel("table").setVisible(false));
    form.setVisible(false);
    form.add(new AjaxFallbackButton("submit", form) {}.setVisible(false));
    add(new Label("error", errorMessage));
    add(form);
}
 
Example 2
public LicenseErrorPage(PageParameters parameters)  {
String error = parameters.get("errorMessage").toString();

      FeedbackPanel uploadFeedback = new FeedbackPanel("uploadFeedback");
      add(uploadFeedback);

      add(new Label("curentUser", NextServerSession.get().getUsername()));
      add(new Label("realName", NextServerSession.get().getRealName()));
      add(new Link<String>("logout") {

	private static final long serialVersionUID = 1L;

	@Override
          public void onClick() {
              NextServerSession.get().signOut();
              setResponsePage(getApplication().getHomePage());
          }
          
      });

      Form<Void> uploadLicenseForm = new UploadLicenseForm("licenseForm");          
      uploadLicenseForm.add(new UploadProgressBar("progress", uploadLicenseForm));
      if (!NextServerSession.get().isAdmin()) {
          error = "Please contact your administrator : " + error;
          uploadLicenseForm.setVisible(false);
      } 
      add(new Label("error", error));
      add(uploadLicenseForm);
  }
 
Example 3
Source Project: inception   File: CurationSidebar.java    License: Apache License 2.0 4 votes vote down vote up
public CurationSidebar(String aId, IModel<AnnotatorState> aModel,
        AnnotationActionHandler aActionHandler, CasProvider aCasProvider,
        AnnotationPage aAnnotationPage)
{
    super(aId, aModel, aActionHandler, aCasProvider, aAnnotationPage);
    annoPage = aAnnotationPage;
    
    mainContainer = new WebMarkupContainer("mainContainer");
    mainContainer.setOutputMarkupId(true);
    add(mainContainer);
    
    // set up user-checklist
    usersForm = createUserSelection();
    usersForm.setOutputMarkupId(true);
    mainContainer.add(usersForm);
    
    // set up settings form for curation target
    Form<Void> settingsForm = createSettingsForm("settingsForm");
    settingsForm.setOutputMarkupId(true);
    settingsForm.setVisible(false);
    mainContainer.add(settingsForm);
    // confirmation dialog when using automatic merging (might change user's annos)  
    IModel<String> documentNameModel = PropertyModel.of(annoPage.getModel(), "document.name");
    add(mergeConfirm = new MergeDialog("mergeConfirmDialog",
            new StringResourceModel("mergeConfirmTitle", this),
            new StringResourceModel("mergeConfirmText", this)
                    .setModel(annoPage.getModel()).setParameters(documentNameModel),
            documentNameModel));
    mainContainer.add(mergeConfirm);
    
    // Add empty space message
    noDocsLabel = new Label("noDocumentsLabel", new ResourceModel("noDocuments"));
    mainContainer.add(noDocsLabel);
    
    // if curation user changed we have to reload the document
    AnnotatorState state = aModel.getObject();
    String currentUser = userRepository.getCurrentUser().getUsername();
    long projectid = state.getProject().getId();
    User curationUser = curationService.retrieveCurationUser(currentUser, 
            projectid);
    if (currentUser != null && !currentUser.equals(curationUser.getUsername())) {
        state.setUser(curationUser);
        Optional<AjaxRequestTarget> target = RequestCycle.get().find(AjaxRequestTarget.class);
        annoPage.actionLoadDocument(target.orElseGet(null));
    }
    
    // user started curating, extension can show suggestions
    state.setMetaData(CurationMetadata.CURATION_USER_PROJECT, true);
}
 
Example 4
Source Project: yes-cart   File: DynaFormPanel.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Construct dynamic form.
 *
 * @param id            component id.
 * @param customerModel customer model
 */
public DynaFormPanel(final String id, final IModel<Customer> customerModel) {

    super(id, customerModel);

    final Shop shop = getCurrentShop();
    final Customer customer = (Customer) getDefaultModelObject();

    final List<Pair<AttrValueWithAttribute, Boolean>> attrValueCollection = customerService.getCustomerProfileAttributes(shop, customer);

    final Form form = new Form<Object>(FORM) {

        @Override
        protected void onSubmit() {
            LOG.debug("Attributes will be updated for customer [{}]", customer.getEmail());

            final Map<String, String> values = new HashMap<>();
            for (Pair<? extends AttrValueWithAttribute, Boolean> av : attrValueCollection) {
                LOG.debug("Attribute with code [{}] has value [{}], readonly [{}]",
                                av.getFirst().getAttribute().getCode(),
                                av.getFirst().getVal(),
                                av.getSecond()
                        );
                if (av.getSecond() != null && !av.getSecond()) {
                    if ("salutation".equals(av.getFirst().getAttribute().getCode())) {
                        customer.setSalutation(av.getFirst().getVal());
                    } else if ("firstname".equals(av.getFirst().getAttribute().getCode())) {
                        if (StringUtils.isNotBlank(av.getFirst().getVal())) {
                            customer.setFirstname(av.getFirst().getVal());
                        }
                    } else if ("middlename".equals(av.getFirst().getAttribute().getCode())) {
                        customer.setMiddlename(av.getFirst().getVal());
                    } else if ("lastname".equals(av.getFirst().getAttribute().getCode())) {
                        if (StringUtils.isNotBlank(av.getFirst().getVal())) {
                            customer.setLastname(av.getFirst().getVal());
                        }
                    } else if ("companyname1".equals(av.getFirst().getAttribute().getCode())) {
                        customer.setCompanyName1(av.getFirst().getVal());
                    } else if ("companyname2".equals(av.getFirst().getAttribute().getCode())) {
                        customer.setCompanyName2(av.getFirst().getVal());
                    } else if ("companydepartment".equals(av.getFirst().getAttribute().getCode())) {
                        customer.setCompanyDepartment(av.getFirst().getVal());
                    } else if (!av.getFirst().getAttribute().isMandatory() || StringUtils.isNotBlank(av.getFirst().getVal())) {
                        values.put(av.getFirst().getAttribute().getCode(), av.getFirst().getVal());
                    }
                }
            }

            customerService.updateCustomerAttributes(getCurrentShop(), customer, values);
            info(getLocalizer().getString("profileUpdated", this));
        }
    };

    addOrReplace(form);

    RepeatingView fields = new RepeatingView(FIELDS);

    form.add(fields);

    final String lang = getLocale().getLanguage();

    for (Pair<? extends AttrValueWithAttribute, Boolean> attrValue : attrValueCollection) {

        WebMarkupContainer row = new WebMarkupContainer(fields.newChildId());

        row.add(getLabel(attrValue.getFirst(), lang));

        row.add(getEditor(attrValue.getFirst(), attrValue.getSecond()));

        fields.add(row);

    }

    form.add( new SubmitLink(SAVE_LINK) );

    form.add(new Label(CONTENT, ""));

    form.setVisible(!attrValueCollection.isEmpty());

}
 
Example 5
Source Project: syncope   File: DirectoryPanel.java    License: Apache License 2.0 4 votes vote down vote up
protected void initResultTable() {
    // ---------------------------
    // Result table initialization
    // ---------------------------
    updateResultTable(false);
    // ---------------------------

    // ---------------------------
    // Rows-per-page selector
    // ---------------------------
    Form<?> paginatorForm = new Form<>("paginator");
    paginatorForm.setOutputMarkupPlaceholderTag(true);
    paginatorForm.setVisible(showPaginator);
    container.add(paginatorForm);

    DropDownChoice<Integer> rowsChooser = new DropDownChoice<>(
            "rowsChooser", new PropertyModel<>(this, "rows"), PreferenceManager.getPaginatorChoices());
    rowsChooser.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            PreferenceManager.set(getRequest(), getResponse(), paginatorRowsKey(), String.valueOf(rows));

            EventDataWrapper data = new EventDataWrapper();
            data.setTarget(target);
            data.setRows(rows);

            send(getParent(), Broadcast.BREADTH, data);
        }
    });
    paginatorForm.add(rowsChooser);
    // ---------------------------

    // ---------------------------
    // Table handling
    // ---------------------------
    container.add(getHeader("tablehandling"));
    // ---------------------------
}
 
Example 6
public ArtifactSearchPanel(String id, final IPageable pageable, IModel<String> globalSearchModel,
		IModel<String> searchGroupModel, IModel<String> searchArtifactModel) {
	super(id);
	
	this.globalSearchModel = globalSearchModel;
	this.searchGroupModel = searchGroupModel;
	this.searchArtifactModel = searchArtifactModel;
	
	Form<Void> keywordSearchForm = new StatelessForm<Void>("keywordSearchForm") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit() {
			ArtifactSearchPanel.this.searchGroupModel.setObject("");
			ArtifactSearchPanel.this.searchArtifactModel.setObject("");
			
			setResponsePage(getPage().getClass(),
					LinkUtils.getSearchPageParameters(ArtifactSearchPanel.this.globalSearchModel));
		}
	};
	
	keywordSearchForm.add(new TextField<String>("globalSearchInput", this.globalSearchModel));
	keywordSearchForm.add(new SubmitLink("submit"));
	
	add(keywordSearchForm);
	
	// NOTE: If this search pattern is going to be reused, it will need to pass its groupId and
	// artifactId terms through the page parameters
	Form<Void> advancedSearchForm = new StatelessForm<Void>("advancedSearchForm") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit() {
			// Lors de la soumission d'un formulaire de recherche, on retourne sur la première page
			pageable.setCurrentPage(0);
			
			ArtifactSearchPanel.this.globalSearchModel.setObject("");
			
			super.onSubmit();
		}
	};
	
	advancedSearchForm.add(new TextField<String>("searchGroupInput", this.searchGroupModel));
	advancedSearchForm.add(new TextField<String>("searchArtifactInput", this.searchArtifactModel));
	advancedSearchForm.add(new SubmitLink("submit"));
	
	advancedSearchForm.setVisible(false);
	
	add(advancedSearchForm);
}