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

The following examples show how to use org.apache.wicket.markup.html.form.Form#add() . 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
public UploadJasperReportPanel(String id, Report report) {
    super(id);

    this.update = true;
    this.parentPath = StorageUtil.getParentPath(report.getPath());

    this.report = report;
    report.setType(ReportConstants.JASPER);

    Form form = new UploadForm("form", false);
    add(form);
    feedback = new NextFeedbackPanel("feedback", form);
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    setOutputMarkupId(true);
}
 
Example 2
private Form<Void> uploadForm(String aFormId, String aFieldId) {
        Form<Void> importProjectForm = new Form<Void>(aFormId) {
            private static final long serialVersionUID = -8284858297362896476L;
            
            @Override
            protected void onSubmit()
            {
                super.onSubmit();
                handleUploadedFiles();
            }
        };

        FileInputConfig config = new FileInputConfig();
        config.initialCaption("Import project archives ...");
        config.showPreview(false);
        config.showUpload(false);
        config.removeIcon("<i class=\"fa fa-remove\"></i>");
//        config.uploadIcon("<i class=\"fa fa-upload\"></i>");
        config.browseIcon("<i class=\"fa fa-folder-open\"></i>");
        importProjectForm.add(fileUpload = new BootstrapFileInputField(aFieldId,
            new ListModel<>(), config));
        return importProjectForm;
    }
 
Example 3
Source Project: ontopia   File: FunctionBoxesPanel.java    License: Apache License 2.0 6 votes vote down vote up
public FunctionBoxesPanel(String id) {
  super(id);
  
  Form<Object> form = new Form<Object>("functionBoxesForm");
  add(form);
  
  List<Component> list = getFunctionBoxesList("functionBox"); 
  ListView<Component> functionBoxes = new ListView<Component>("functionBoxesList", list) {
    @Override
    protected void populateItem(ListItem<Component> item) {
      item.add(item.getModelObject());
    }
  };
  functionBoxes.setVisible(!list.isEmpty());
  form.add(functionBoxes);
}
 
Example 4
Source Project: webanno   File: DocumentListPanel.java    License: Apache License 2.0 6 votes vote down vote up
public DocumentListPanel(String aId, IModel<Project> aProject)
{
    super(aId);
 
    setOutputMarkupId(true);
    
    project = aProject;
    selectedDocuments = new CollectionModel<>();

    Form<Void> form = new Form<>("form");
    add(form);
    
    overviewList = new ListMultipleChoice<>("documents");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("name"));
    overviewList.setModel(selectedDocuments);
    overviewList.setChoices(LambdaModel.of(this::listSourceDocuments));
    form.add(overviewList);

    confirmationDialog = new ConfirmationDialog("confirmationDialog");
    confirmationDialog.setTitleModel(new StringResourceModel("DeleteDialog.title", this));
    add(confirmationDialog);

    form.add(new LambdaAjaxButton<>("delete", this::actionDelete));
}
 
Example 5
public AbstractUploadFilePanel(String id, final ModalWindow modal,final AbstractModalWindowCommand<?> command) {
	super(id);
	modal.setMinimalHeight(300);
	modal.showUnloadConfirmation(false);
	Form<?> uploadForm = new Form<Object>("uploadForm");
	final FileUploadField inputFile = new FileUploadField("inputFile");
	uploadForm.add(inputFile);
	uploadForm.add(new AjaxButton("loadFile",getLoadButtonTitle(),uploadForm)
	{
		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit(AjaxRequestTarget target) {
			FileUpload file = inputFile.getFileUpload();
			if (file!=null){
				onLoadFile(file);
				command.onAfterModalSubmit();
				modal.close(target);
			}
		}
		
	});
	add(uploadForm);		
}
 
Example 6
Source Project: onedev   File: WebHooksPage.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	WebHooksBean bean = new WebHooksBean();
	bean.setWebHooks(getProject().getWebHooks());
	
	PropertyEditor<Serializable> editor = PropertyContext.edit("editor", bean, "webHooks");
	
	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			getSession().success("Web hooks saved");
			getProject().setWebHooks(bean.getWebHooks());
			OneDev.getInstance(ProjectManager.class).save(getProject());
			setResponsePage(WebHooksPage.class, WebHooksPage.paramsOf(getProject()));
		}
		
	};
	form.add(new NotificationPanel("feedback", form));
	form.add(editor);
	add(form);
}
 
Example 7
Source Project: sakai   File: MyPicture.java    License: Educational Community License v2.0 6 votes vote down vote up
public MyPicture(String userId, GalleryImage galleryImage,
		long galleryPageIndex) {

	configureFeedback();

	Label galleryImageHeading = new Label("galleryImageHeading",
			new Model<String>(galleryImage.getDisplayName()));
	add(galleryImageHeading);

	Form galleryImageForm = new Form("galleryImageForm");
	galleryImageForm.setOutputMarkupId(true);
	add(galleryImageForm);

	GalleryImageEdit galleryImageEdit = new GalleryImageEdit(
			"galleryImageEdit", userId, galleryImage, galleryPageIndex);
	galleryImageForm.add(galleryImageEdit);
}
 
Example 8
Source Project: Orienteer   File: AddTabDialog.java    License: Apache License 2.0 5 votes vote down vote up
public AddTabDialog(String id) {
	super(id);
	Form<T> form = new Form<T>("addTabForm");
	form.add(tabName = new TextField<String>("tabName", Model.of("")));
	form.add(new AjaxButton("addTab") {
		@Override
		protected void onSubmit(AjaxRequestTarget target) {
			onCreateTab(tabName.getModelObject(), Optional.of(target));
			tabName.setModelObject("");
		}
	});
	add(form);
}
 
Example 9
Source Project: Orienteer   File: GenericTablePanel.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private GenericTablePanel(String id, List<? extends IColumn<K, String>> columns,
                          ISortableDataProvider<K, String> provider, int rowsPerRange, boolean filtered) {
    super(id);
    Args.notNull(columns, "columns");
    Args.notNull(provider, "provider");
    setOutputMarkupPlaceholderTag(true);
    dataTable = new OrienteerDataTable<>("table", columns, provider, rowsPerRange);
    if (filtered) {
        FilterForm<OQueryModel<K>> filterForm = createFilterForm("form", (IFilterStateLocator<OQueryModel<K>>) provider);
        filterForm.setOutputMarkupPlaceholderTag(true);
        dataTable.addFilterForm(filterForm);
        filterForm.add(dataTable);
        AjaxFallbackButton button = new AjaxFallbackButton("submit", filterForm) {};
        filterForm.setDefaultButton(button);
        filterForm.enableFocusTracking(button);
        filterForm.add(button);
        filterForm.add(dataTable);
        add(filterForm);
    } else {
        Form form = new Form("form");
        form.add(dataTable);
        form.add(new AjaxFallbackButton("submit", form) {}.setVisible(false));
        add(form);
    }
    add(new EmptyPanel("error").setVisible(false));
}
 
Example 10
public SakaiNavigatorSearch(String id, final SortableSearchableDataProvider dataProvider) {
	super(id);
	this.dataProvider = dataProvider;

	setDefaultModel(new CompoundPropertyModel(this));

	Form form = new Form("searchForm");
	add(form);

	searchBox = new TextField("searchKeyword");
	form.add(searchBox);

	Button search = new Button("search") {
		@Override
		public void onSubmit() {
			String keyword = getSearchKeyword();
			if(keyword == null || "".equals(keyword)){
				dataProvider.clearSearchKeyword();
			}else{
				dataProvider.setSearchKeyword(keyword);
			}
			super.onSubmit();
		}
	};
	form.add(search);

	Button clear = new Button("clear") {
		@Override
		public void onSubmit() {
			dataProvider.clearSearchKeyword();
			super.onSubmit();
		}
	};
	form.add(clear);
}
 
Example 11
Source Project: inception   File: ActiveLearningSidebar.java    License: Apache License 2.0 5 votes vote down vote up
private Form<?> createLearningHistory()
{
    Form<?> learningHistoryForm = new Form<Void>(CID_LEARNING_HISTORY_FORM)
    {
        private static final long serialVersionUID = -961690443085882064L;
    };
    learningHistoryForm.add(LambdaBehavior.onConfigure(component -> component
        .setVisible(alStateModel.getObject().isSessionActive())));
    learningHistoryForm.setOutputMarkupPlaceholderTag(true);
    learningHistoryForm.setOutputMarkupId(true);

    learningHistoryForm.add(createLearningHistoryListView());
    return learningHistoryForm;
}
 
Example 12
public LappsGridRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender)
{
    super(aId, aRecommender);

    traits = toolFactory.readTraits(aRecommender.getObject());
    traitsModel = CompoundPropertyModel.of(traits);
    Form<LappsGridRecommenderTraits> form =
            new Form<LappsGridRecommenderTraits>(MID_FORM, traitsModel)
    {
        private static final long serialVersionUID = -3109239605742291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            toolFactory.writeTraits(aRecommender.getObject(), traits);
        }
    };

    urlField = new TextField<>(MID_URL);
    urlField.setRequired(true);
    urlField.add(new UrlValidator());
    urlField.setOutputMarkupId(true);
    form.add(urlField);

    servicesDropDown = new BootstrapSelect<>(MID_SERVICES);
    servicesDropDown.setModel(Model.of());
    servicesDropDown.setChoices(LoadableDetachableModel.of(this::getPredefinedServicesList));
    servicesDropDown.setChoiceRenderer(new ChoiceRenderer<>("description"));
    servicesDropDown.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> {
        LappsGridService selection = servicesDropDown.getModelObject();
        if (selection != null) {
            traits.setUrl(selection.getUrl());
        }
        t.add(urlField);
    }));
    form.add(servicesDropDown);

    add(form);
}
 
Example 13
public SakaiNavigatorSearch(String id, final SortableSearchableDataProvider dataProvider) {
	super(id);
	this.dataProvider = dataProvider;

	setDefaultModel(new CompoundPropertyModel(this));

	Form form = new Form("searchForm");
	add(form);

	searchBox = new TextField("searchKeyword");
	form.add(searchBox);

	Button search = new Button("search") {
		@Override
		public void onSubmit() {
			String keyword = getSearchKeyword();
			if(keyword == null || "".equals(keyword)){
				dataProvider.clearSearchKeyword();
			}else{
				dataProvider.setSearchKeyword(keyword);
			}
			super.onSubmit();
		}
	};
	form.add(search);

	Button clear = new Button("clear") {
		@Override
		public void onSubmit() {
			dataProvider.clearSearchKeyword();
			super.onSubmit();
		}
	};
	form.add(clear);
}
 
Example 14
Source Project: inception   File: AbstractInfoPanel.java    License: Apache License 2.0 5 votes vote down vote up
public EditMode(String id, CompoundPropertyModel<T> compoundModel) {
    super(id, "editMode", AbstractInfoPanel.this);
    
    // set up form components
    TextField<String> name = new TextField<>("name", compoundModel.bind("name"));
    name.add(AttributeModifier.append("placeholder",
            new ResourceModel(getNamePlaceholderResourceKey())));
    name.setOutputMarkupId(true);
    focusComponent = name;

    // there exists functionality to cancel the "new KBObject" prompt, but in hindsight, MB
    // thinks this functionality is not really needed in the UI, so the button is hidden
    // here
    LambdaAjaxLink cancelButton = new LambdaAjaxLink("cancel",
            AbstractInfoPanel.this::actionCancel)
                    .onConfigure((_this) -> _this.setVisible(false));
    cancelButton.add(new Label("label", new ResourceModel(getCancelButtonResourceKey())));

    LambdaAjaxButton<T> createButton = new LambdaAjaxButton<>("create",
            AbstractInfoPanel.this::actionCreate);
    createButton.add(new Label("label", new ResourceModel(getCreateButtonResourceKey())));

    Form<T> form = new Form<T>("form", compoundModel);
    form.add(name);
    form.add(cancelButton);
    form.add(createButton);
    form.setDefaultButton(createButton);
    add(form);
}
 
Example 15
Source Project: webanno   File: ImportDocumentsPanel.java    License: Apache License 2.0 5 votes vote down vote up
public ImportDocumentsPanel(String aId, IModel<Project> aProject)
{
    super(aId);

    projectModel = aProject;
    
    Form<Void> form = new Form<>("form");
    add(form);
    
    format = Model.of();
    List<String> readableFormats = listReadableFormats();
    if (!readableFormats.isEmpty()) {
        if (readableFormats.contains("Plain text")) {
            format.setObject("Plain text");
        }
        else {
            format.setObject(readableFormats.get(0));
        }
    }
    
    form.add(fileUpload = new BootstrapFileInputField("documents"));
    fileUpload.getConfig().showPreview(false);
    fileUpload.getConfig().showUpload(false);
    fileUpload.getConfig().showRemove(false);
    fileUpload.setRequired(true);

    DropDownChoice<String> formats = new BootstrapSelect<>("format");
    formats.setModel(format);
    formats.setChoices(LambdaModel.of(this::listReadableFormats));
    form.add(formats);
    
    form.add(new LambdaAjaxButton<>("import", this::actionImport));
}
 
Example 16
public AdministrationArtifactSearchPanel(String id, IPageable pageable, IModel<String> searchTermModel, IModel<ArtifactDeprecationStatus> deprecationModel) {
	super(id);
	
	this.pageable = pageable;
	
	this.searchTermModel = searchTermModel;
	this.deprecationModel = deprecationModel;
	
	Form<Void> form = new Form<Void>("form") {
		private static final long serialVersionUID = -584576228542906811L;
		@Override
		protected void onSubmit() {
			// Lors de la soumission d'un formulaire de recherche, on retourne sur la première page
			AdministrationArtifactSearchPanel.this.pageable.setCurrentPage(0);
			super.onSubmit();
		}
	};
	
	TextField<String> searchInput = new TextField<String>("searchInput", this.searchTermModel);
	form.add(searchInput);
	
	ArtifactDeprecationStatusDropDownChoice deprecationField = new ArtifactDeprecationStatusDropDownChoice("deprecation", deprecationModel) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void fillSelect2Settings(Select2Settings settings) {
			super.fillSelect2Settings(settings);
			settings.setAllowClear(true);
		}
	};
	deprecationField.setNullValid(true);
	form.add(deprecationField);
	
	form.add(new SubmitLink("submit"));
	
	add(form);
}
 
Example 17
Source Project: inception   File: ConceptListPanel.java    License: Apache License 2.0 5 votes vote down vote up
public ConceptListPanel(String aId, IModel<KnowledgeBase> aKbModel,
        IModel<KBHandle> selectedConceptModel) {
    super(aId, selectedConceptModel);

    setOutputMarkupId(true);

    selectedConcept = selectedConceptModel;
    kbModel = aKbModel;
    preferences = Model.of(new Preferences());

    OverviewListChoice<KBHandle> overviewList = new OverviewListChoice<>("concepts");
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    overviewList.setModel(selectedConceptModel);
    overviewList.setChoices(LambdaModel.of(this::getConcepts));
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change",
            this::actionSelectionChanged));
    overviewList.setMaxRows(LIST_MAX_ROWS);
    add(overviewList);

    add(new Label("count", LambdaModel.of(() -> overviewList.getChoices().size())));

    LambdaAjaxLink addLink = new LambdaAjaxLink("add", target -> send(getPage(),
            Broadcast.BREADTH, new AjaxNewConceptEvent(target)));
    addLink.add(new Label("label", new ResourceModel("concept.list.add")));
    addLink.add(new WriteProtectionBehavior(kbModel));
    add(addLink);

    Form<Preferences> form = new Form<>("form", CompoundPropertyModel.of(preferences));
    form.add(new CheckBox("showAllConcepts").add(
            new LambdaAjaxFormSubmittingBehavior("change", this::actionPreferenceChanged)));
    add(form);
}
 
Example 18
@Override
protected void addComponents(Form<Settings> form) {    	    	
   	
       final TextField<String> urlField = new TextField<String>("baseUrl");
       urlField.add(new UrlValidator());
       urlField.setRequired(true);
       form.add(urlField);
       
       ContextImage urlImage = new ContextImage("urlImage","images/exclamation.png");        
       urlImage.add(new SimpleTooltipBehavior(getString("Settings.general.baseUrlTooltip")));
       form.add(urlImage);
       
       final TextField<String> reportsHomeField = new TextField<String>("reportsHome");
       reportsHomeField.setRequired(true);
       form.add(reportsHomeField);
       
       ContextImage homeImage = new ContextImage("homeImage","images/exclamation.png");        
       homeImage.add(new SimpleTooltipBehavior(getString("Settings.general.reportsHomeTooltip")));
       form.add(homeImage);
       
       final TextField<String> reportsUrlField = new TextField<String>("reportsUrl");
       reportsUrlField.add(new UrlValidator());
       reportsUrlField.setRequired(true);
       form.add(reportsUrlField);
       
       ContextImage repImage = new ContextImage("repImage","images/exclamation.png");        
       repImage.add(new SimpleTooltipBehavior(getString("Settings.general.reportsUrlTooltip")));
       form.add(repImage);
       
       final TextField<Integer> conTimeoutField = new TextField<Integer>("connectionTimeout");
       conTimeoutField.setRequired(true);
       form.add(conTimeoutField);
       ContextImage conImage = new ContextImage("conImage","images/information.png");        
       conImage.add(new SimpleTooltipBehavior(getString("Settings.general.connectTimeoutTooltip")));
       form.add(conImage);

       final TextField<Integer> timeoutField = new TextField<Integer>("queryTimeout");
       timeoutField.setRequired(true);
       form.add(timeoutField);
       ContextImage timeoutImage = new ContextImage("timeoutImage","images/information.png");        
       timeoutImage.add(new SimpleTooltipBehavior(getString("Settings.general.queryTimeoutTooltip")));
       form.add(timeoutImage);

       final TextField<Integer> updateIntervalField = new TextField<Integer>("updateInterval");
       updateIntervalField.setRequired(true);
       form.add(updateIntervalField);      
       ContextImage updateImage = new ContextImage("updateImage","images/information.png");        
       updateImage.add(new SimpleTooltipBehavior(getString("Settings.general.updateIntervalTooltip")));
       form.add(updateImage);
       
       final TextField<Integer> pollingIntervalField = new TextField<Integer>("pollingInterval");
       pollingIntervalField.setRequired(true);
       form.add(pollingIntervalField);      
       ContextImage poolingImage = new ContextImage("pollingImage","images/information.png");        
       poolingImage.add(new SimpleTooltipBehavior(getString("Settings.general.pollingIntervalTooltip")));
       form.add(poolingImage);
       
       final TextField<Integer> uploadSizeField = new TextField<Integer>("uploadSize");
       uploadSizeField.setRequired(true);
       form.add(uploadSizeField);      
       ContextImage uploadSizeImage = new ContextImage("uploadSizeImage","images/information.png");        
       uploadSizeImage.add(new SimpleTooltipBehavior(getString("Settings.general.uploadSizeTooltip")));
       form.add(uploadSizeImage);

       final CheckBox autoOpenField = new CheckBox("autoOpen");
       form.add(autoOpenField);

       Settings settings = storageService.getSettings();
       oldReportsHome = String.valueOf(settings.getReportsHome());        
   }
 
Example 19
Source Project: oodt   File: LoginPage.java    License: Apache License 2.0 4 votes vote down vote up
public LoginPage(PageParameters parameters) {
  super();
  final CurationApp app = (CurationApp)Application.get();
  final CurationSession session = (CurationSession)getSession();
  String ssoClass = app.getSSOImplClass();
  final AbstractWebBasedSingleSignOn sso = SingleSignOnFactory
      .getWebBasedSingleSignOn(ssoClass);
  sso.setReq(((WebRequest) RequestCycle.get().getRequest())
      .getHttpServletRequest());
  sso.setRes(((WebResponse) RequestCycle.get().getResponse())
      .getHttpServletResponse());
  
  String action = parameters.getString("action");
  String appNameString = app.getProjectName()+" CAS Curation Interface";
  add(new Label("login_project_name", appNameString));
  replace(new Label("crumb_name", "Login"));
  final WebMarkupContainer creds = new WebMarkupContainer("invalid_creds");
  final WebMarkupContainer connect = new WebMarkupContainer("connect_error");
  creds.setVisible(false);
  connect.setVisible(false);
  final TextField<String> loginUser = new TextField<String>("login_username", new Model<String>(""));
  final PasswordTextField pass = new PasswordTextField("password", new Model<String>(""));
  
  
  Form<?> form = new Form<Void>("login_form"){

    private static final long serialVersionUID = 1L;
    
    @Override
    protected void onSubmit() {
      String username = loginUser.getModelObject();
      String password = pass.getModelObject();
      
      if(sso.login(username, password)){
        session.setLoggedIn(true);
        session.setLoginUsername(username);
        setResponsePage(WorkbenchPage.class);
      }
      else{
        session.setLoggedIn(false);
        if (session.getLoginUsername() == null){
          connect.setVisible(true);
        }
        else{
          creds.setVisible(true);
        }
      }
      
    }
    
  };
  
  form.add(loginUser);
  form.add(pass);
  form.add(creds);
  form.add(connect);
  add(form);
  
  if(action.equals("logout")){
    sso.logout();
    session.setLoginUsername(null);
    session.setLoggedIn(false);
    PageParameters params = new PageParameters();
    params.add("action", "login");
    setResponsePage(LoginPage.class, params);
  }

}
 
Example 20
public ConceptFeatureTraitsEditor(String aId, ConceptFeatureSupport aFS,
        IModel<AnnotationFeature> aFeatureModel)
{
    super(aId, aFeatureModel);
    
    // We cannot retain a reference to the actual ConceptFeatureSupport instance because that
    // is not serializable, but we can retain its ID and look it up again from the registry
    // when required.
    featureSupportId = aFS.getId();
    feature = aFeatureModel;
    traits = CompoundPropertyModel.of(readTraits());

    Form<Traits> form = new Form<Traits>(MID_FORM, traits)
    {
        private static final long serialVersionUID = -3109239605783291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            writeTraits();
        }
    };
    
    form.add(new KnowledgeBaseItemAutoCompleteField(MID_SCOPE,
        _query -> listSearchResults(_query, CONCEPT)).setOutputMarkupPlaceholderTag(true));

    form.add(
        new BootstrapSelect<>(MID_KNOWLEDGE_BASE, 
                LambdaModel.of(this::listKnowledgeBases), 
                new LambdaChoiceRenderer<>(KnowledgeBase::getName))
        .setNullValid(true)
        .add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::refresh)));
    form.add(
        new BootstrapSelect<>(MID_ALLOWED_VALUE_TYPE, LambdaModel.of(this::listAllowedTypes))
        .add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::refresh)));

    form.add(new DisabledKBWarning("disabledKBWarning", feature));
    add(form);

    add(new KeyBindingsConfigurationPanel("keyBindings", aFeatureModel,
            traits.bind("keyBindings")));
}