Java Code Examples for org.apache.wicket.markup.html.form.TextField

The following examples show how to use org.apache.wicket.markup.html.form.TextField. 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
@Override
protected void addComponents(Form<Settings> form) {
	final TextField<String> cronField = new TextField<String>("cleanHistory.cronExpression");
	cronField.setRequired(true);
	form.add(cronField);
	//
	ContextImage cronImage = new ContextImage("cronImage", "images/information.png");
	cronImage.add(new SimpleTooltipBehavior(getString("Settings.synchronizer.cronTooltip")));
	form.add(cronImage);
	//
	System.out.println("settings = " + form.getModelObject());
	final TextField<Integer> daysToKeepField = new TextField<Integer>("cleanHistory.daysToKeep");
	form.add(daysToKeepField);
	//
	final TextField<Integer> daysToDeleteField = new TextField<Integer>("cleanHistory.daysToDelete");
	form.add(daysToDeleteField);
	//
	final CheckBox checkBoxEnable = new CheckBox("cleanHistory.shrinkDataFolder");
	form.add(checkBoxEnable);
	//
	CleanHistorySettings settings = storageService.getSettings().getCleanHistory();
	oldCronExpression = String.valueOf(settings.getCronExpression());
}
 
Example 2
@Override
@SuppressWarnings("unchecked")
public FormComponent<?> createFilterComponent(IModel<?> model) {
    OProperty property = getEntityModel().getObject();
    FormComponent<?> component;
    switch (property.getLinkedType()) {
        case BOOLEAN:
            component = new BooleanFilterPanel(getFilterId(), (IModel<Boolean>) model);
            break;
        case DATE:
            component = new BooleanFilterPanel(getFilterId(), (IModel<Boolean>) model);
            break;
        case DATETIME:
            component = new ODateField(getFilterId(), (IModel<Date>) model);
            break;
        default:
            component = new TextField<>(getFilterId(), model);
    }
    return component;
}
 
Example 3
public AdministrationUserSearchPanel(String id, IPageable pageable, IModel<String> searchTermModel) {
	super(id);
	
	this.pageable = pageable;
	
	this.searchTermModel = searchTermModel;
	
	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
			AdministrationUserSearchPanel.this.pageable.setCurrentPage(0);
			super.onSubmit();
		}
	};
	
	TextField<String> searchInput = new TextField<String>("searchInput", this.searchTermModel);
	form.add(searchInput);
	
	form.add(new SubmitLink("submit"));
	
	add(form);
}
 
Example 4
Source Project: nextreports-server   Source File: JasperSettingsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void addComponents(Form<Settings> form) {
	
	final TextField<String> homeField = new TextField<String>("jasper.home");
	homeField.setRequired(true);
    form.add(homeField);

	final CheckBox checkBoxD = new CheckBox("jasper.detectCellType");
	form.add(checkBoxD);

	final CheckBox checkBoxW = new CheckBox("jasper.whitePageBackground");
	form.add(checkBoxW);

	final CheckBox checkBoxR = new CheckBox("jasper.removeEmptySpaceBetweenRows");
	form.add(checkBoxR);

}
 
Example 5
Source Project: onedev   Source File: ProjectQueryEditor.java    License: MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
   	
   	input = new TextField<String>("input", getModel());
       input.add(new ProjectQueryBehavior());
       
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
       
       add(input);
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example 6
void init(final HRPlanningEntryDO entry)
{
  final boolean deleted = entry.isDeleted();
  final TextField<BigDecimal> unassignedHours = new TextField<BigDecimal>("unassignedHours", new PropertyModel<BigDecimal>(entry,
      "unassignedHours"));
  add(unassignedHours.setEnabled(!deleted));
  final TextField<BigDecimal> mondayHours = new TextField<BigDecimal>("mondayHours", new PropertyModel<BigDecimal>(entry, "mondayHours"));
  add(mondayHours.setEnabled(!deleted));
  final TextField<BigDecimal> tuesdayHours = new TextField<BigDecimal>("tuesdayHours", new PropertyModel<BigDecimal>(entry,
      "tuesdayHours"));
  add(tuesdayHours.setEnabled(!deleted));
  final TextField<BigDecimal> wednesdayHours = new TextField<BigDecimal>("wednesdayHours", new PropertyModel<BigDecimal>(entry,
      "wednesdayHours"));
  add(wednesdayHours.setEnabled(!deleted));
  final TextField<BigDecimal> thursdayHours = new TextField<BigDecimal>("thursdayHours", new PropertyModel<BigDecimal>(entry,
      "thursdayHours"));
  add(thursdayHours.setEnabled(!deleted));
  final TextField<BigDecimal> fridayHours = new TextField<BigDecimal>("fridayHours", new PropertyModel<BigDecimal>(entry, "fridayHours"));
  add(fridayHours.setEnabled(!deleted));
  final TextField<BigDecimal> weekendHours = new TextField<BigDecimal>("weekendHours", new PropertyModel<BigDecimal>(entry,
      "weekendHours"));
  add(weekendHours.setEnabled(!deleted));
}
 
Example 7
Source Project: nextreports-server   Source File: AnalysisRuntimePanel.java    License: Apache License 2.0 6 votes vote down vote up
public AnalysisRuntimePanel(String id, ReportRuntimeModel model) {
	super(id);

	Label label = new Label("analysisLabel", getString("Analysis.run.name"));
	add(label);
	
	TextField<String> analysisText = new TextField<String>("analysisText", new PropertyModel(model, "analysisName"));    	
   	add(analysisText);
   	
   	AjaxLink analysisLink = new AjaxLink("analysisLink") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			// TODO Auto-generated method stub
			
		}
   		
   	}; 
   	add(analysisLink);
}
 
Example 8
Source Project: Orienteer   Source File: SelectDialogPanel.java    License: Apache License 2.0 6 votes vote down vote up
private Command<ODocument> createSelectAndSearchCommand(OrienteerDataTable<ODocument, String> table, OClassSearchPanel searchPanel) {
	return new AbstractCheckBoxEnabledCommand<ODocument>(new ResourceModel("command.selectAndSearchMode"), table) {
		@Override
		protected void onInitialize() {
			super.onInitialize();
			setBootstrapType(BootstrapType.SUCCESS);
			setIcon(FAIconType.hand_o_right);
			setAutoNotify(false);
		}

		@Override
		protected void performMultiAction(AjaxRequestTarget target, List<ODocument> objects) {
			if (onSelect(target, objects, true)) {
				TextField<String> field = searchPanel.getQueryField();
				resetSelection();
				target.add(getTable());
				target.focusComponent(field);
				target.appendJavaScript(String.format("$('#%s').select()", field.getMarkupId()));
			}
		}
	};
}
 
Example 9
Source Project: Orienteer   Source File: DefaultRegistrationPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    IModel<OrienteerUser> model = getModel();

    Form<?> form = new Form<>("form");

    form.add(new TextField<>("firstName", new PropertyModel<>(model, "firstName")).setRequired(true));
    form.add(new TextField<>("lastName", new PropertyModel<>(model, "lastName")).setRequired(true));
    form.add(createEmailField("email", new PropertyModel<>(model, "email")));

    TextField<String> passwordField = new PasswordTextField("password", passwordModel);
    TextField<String> confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));

    form.add(passwordField);
    form.add(confirmPasswordField);
    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));
    form.add(createRegisterButton("registerButton"));
    form.add(createSocialNetworksPanel("socialNetworks"));

    add(form);
    add(createFeedbackPanel("feedback"));
    setOutputMarkupPlaceholderTag(true);
}
 
Example 10
@Override
protected void onInitialize() {
    super.onInitialize();

    TextField<String> textField = new TextField<>("input", new Model<String>());

    Form<Void> form = new Form<Void>("form"){
        @Override
        protected void onSubmit() {
            super.onSubmit();
            textField.error("this is an error from textfield with tabs (\t), new lines (\r\n), double quotes (\"hey\")");
            error("this is an error from form");
        }
    };
    BootstrapFeedbackPopover feedback = new BootstrapFeedbackPopover("feedback");

    add(form);
    form.add(feedback);
    feedback.add(textField);
}
 
Example 11
Source Project: syncope   Source File: UsersITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void filteredSearch() {
    TESTER.clickLink("body:realmsLI:realms");
    TESTER.clickLink("body:content:body:container:content:tabbedPanel:tabs-container:tabs:1:link");

    TESTER.clickLink(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:title");

    TESTER.executeAjaxEvent(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:body:"
            + "content:searchFormContainer:search:multiValueContainer:innerForm:content:view:0:panelPlus:add",
            Constants.ON_CLICK);

    TESTER.assertComponent(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:body:content:"
            + "searchFormContainer:search:multiValueContainer:innerForm:content:view:0:panel:container:value:"
            + "textField", TextField.class);
    TESTER.assertComponent(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:body:content:"
            + "searchFormContainer:search:multiValueContainer:innerForm:content:view:1:panel:container:value:"
            + "textField", TextField.class);
}
 
Example 12
@Override
protected Component createBody(String wicketId) {
	DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, ArtifactNotificationRuleFormPopupPanel.class);
	
	ruleForm = new Form<ArtifactNotificationRule>("form", getModel());
	body.add(ruleForm);
	
	TextField<String> regexField = new RequiredTextField<String>("regex", BindingModel.of(ruleForm.getModel(),
			Binding.artifactNotificationRule().regex()));
	regexField.setLabel(new ResourceModel("artifact.rules.field.regex"));
	ruleForm.add(regexField);
	
	ArtifactNotificationRuleTypeDropDownChoice typeField = new ArtifactNotificationRuleTypeDropDownChoice("type",
			BindingModel.of(ruleForm.getModel(), Binding.artifactNotificationRule().type()));
	typeField.setLabel(new ResourceModel("artifact.rules.field.type"));
	typeField.setRequired(true);
	ruleForm.add(typeField);
	
	return body;
}
 
Example 13
Source Project: Orienteer   Source File: OClusterMetaPanel.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected Component resolveComponent(String id, DisplayMode mode, String critery) {

    if(DisplayMode.EDIT.equals(mode) && !OSecurityHelper.isAllowed(ORule.ResourceGeneric.SCHEMA, null, OrientPermission.UPDATE))
    {
        mode = DisplayMode.VIEW;
    }
    if(DisplayMode.VIEW.equals(mode))
    {
        return new Label(id, getModel());
    }
    else if(DisplayMode.EDIT.equals(mode)) {
        if (OClustersWidget.COMPRESSION.equals(critery)) {
            return new DropDownChoice<String>(id, (IModel<String>)getModel(), COMPRESSIONS);
        }
        else if(OClustersWidget.COUNT.equals(critery) || OClustersWidget.ID.equals(critery)){
            return resolveComponent(id, DisplayMode.VIEW, critery);
        } else {
            return new TextField<V>(id, getModel()).setType(String.class);
        }
    }
    return null;
}
 
Example 14
Source Project: syncope   Source File: AnyObjectsITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void filteredSearch() {
    TESTER.clickLink("body:realmsLI:realms");

    TESTER.clickLink("body:content:body:container:content:tabbedPanel:tabs-container:tabs:3:link");

    TESTER.clickLink(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:title");

    TESTER.executeAjaxEvent(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:body:"
            + "content:searchFormContainer:search:multiValueContainer:innerForm:content:view:0:panelPlus:add",
            Constants.ON_CLICK);

    TESTER.assertComponent(
            "body:content:body:container:content:tabbedPanel:panel:accordionPanel:tabs:0:body:content:"
            + "searchFormContainer:search:multiValueContainer:innerForm:content:view:0:panel:container:value:"
            + "textField", TextField.class);
}
 
Example 15
Source Project: nextreports-server   Source File: MinutelyJobPanel.java    License: Apache License 2.0 6 votes vote down vote up
public MinutelyJobPanel(String id, SchedulerJob schedulerJob) {
    super(id);
    this.schedulerJob = schedulerJob;

    add(minuteLabel = new Label("minuteLabel", getString("JobPanel.everyMinute")));

    add(hoursLabel = new Label("hoursLabel", getString("hours")));
    add(daysLabel = new Label("daysLabel", getString("days")));
    add(monthsLabel = new Label("monthsLabel", getString("months")));

    minuteText = new TextField<Integer>("minuteText", new PropertyModel<Integer>(schedulerJob, "time.gap"));
    minuteText.setLabel(new Model<String>(getString("JobPanel.everyMinute")));
    minuteText.add(new RangeValidator<Integer>(1, 59));
    add(minuteText);
   
    add(hoursPanel = new IntervalFieldPanel("hoursPanel", new PropertyModel(schedulerJob, "time.hours"), SelectIntervalPanel.HOUR_ENTITY, null));
    add(daysPanel = new IntervalFieldPanel("daysPanel", new PropertyModel(schedulerJob, "time.days"), SelectIntervalPanel.DAY_ENTITY, null));
    add(monthsPanel = new IntervalFieldPanel("monthsPanel", new PropertyModel(schedulerJob, "time.months"), SelectIntervalPanel.MONTH_ENTITY, null));

    setAdvancedType(false);
}
 
Example 16
Source Project: syncope   Source File: ReportsITCase.java    License: Apache License 2.0 6 votes vote down vote up
private static void createReport(final String name) {
    TESTER.clickLink(
            "body:content:tabbedPanel:panel:firstLevelContainer:first:container:content:add");

    TESTER.assertComponent(
            "body:content:tabbedPanel:panel:firstLevelContainer:first:outerObjectsRepeater:0:outer", Modal.class);

    FormTester formTester = TESTER.newFormTester(
            "body:content:tabbedPanel:panel:firstLevelContainer:first:outerObjectsRepeater:0:outer:form");
    formTester.setValue("content:form:view:name:textField", name);
    formTester.setValue("content:form:view:template:dropDownChoiceField", "0");
    formTester.submit("content:form:buttons:next");

    TESTER.assertComponent(
            "body:content:tabbedPanel:panel:firstLevelContainer:first:outerObjectsRepeater"
            + ":0:outer:form:content:form:view:schedule:seconds:textField", TextField.class);

    formTester = TESTER.newFormTester(
            "body:content:tabbedPanel:panel:firstLevelContainer:first:outerObjectsRepeater:0:outer:form");
    formTester.submit("content:form:buttons:finish");

    assertSuccessMessage();
    TESTER.cleanupFeedbackMessages();

    TESTER.clickLink("body:reportsLI:reports");
}
 
Example 17
Source Project: sakai   Source File: CreateWorksitePanel.java    License: Educational Community License v2.0 6 votes vote down vote up
private void resetPanel(AjaxRequestTarget target,
		final TextField<String> siteNameField,
		final Palette<Person> palette, Label formFeedback) {

	siteNameField.setModelObject("");

	// there is quite possibly a better way of doing this
	List<Person> remove = new ArrayList<Person>();
	for (Person person : palette.getModelCollection()) {
		remove.add(person);
	}
	palette.getModelCollection().removeAll(remove);

	formFeedback.setVisible(false);
	
	target.add(siteNameField);
	target.appendJavaScript("$('#" + CreateWorksitePanel.this.getMarkupId()
			+ "').slideUp();");
	target.appendJavaScript("fixWindowVertical();");
}
 
Example 18
Source Project: inception   Source 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 19
Source Project: inception   Source File: QualifierEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new fragement for editing a qualifier.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewQualifier}:
 * <ul>
 * <li>{@code !isNewQualifier}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the qualifier from the statement.</li>
 * <li>{@code isNewQualifier}: Save button commits changes (creates a new qualifier in the
 * statement), cancel button removes the qualifier from the UI, delete button is not visible
 * .</li>
 * </ul>
 *
 * @param aId
 *            markup ID
 * @param aQualifier
 *            qualifier model
 * @param isNewQualifier
 *            whether the qualifier being edited is new, meaning it has no corresponding
 *            qualifier in the KB backend
 */
public EditMode(String aId, IModel<KBQualifier> aQualifier, boolean isNewQualifier)
{
    super(aId, "editMode", QualifierEditor.this, aQualifier);

    IModel<KBQualifier> compoundModel = CompoundPropertyModel.of(aQualifier);

    Form<KBQualifier> form = new Form<>("form", compoundModel);
    DropDownChoice<KBProperty> type = new BootstrapSelect<>("property");
    type.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    type.setChoices(kbService.listProperties(kbModel.getObject(), false));
    type.setRequired(true);
    type.setOutputMarkupId(true);
    form.add(type);
    initialFocusComponent = type;

    form.add(new TextField<>("language"));

    Component valueTextArea = new TextArea<String>("value");
    form.add(valueTextArea);

    form.add(new LambdaAjaxButton<>("create", QualifierEditor.this::actionSave));
    form.add(new LambdaAjaxLink("cancel", t -> {
        if (isNewQualifier) {
            QualifierEditor.this.actionCancelNewQualifier(t);
        } else {
            QualifierEditor.this.actionCancelExistingQualifier(t);
        }
    }));
    form.add(new LambdaAjaxLink("delete", QualifierEditor.this::actionDelete)
        .setVisibilityAllowed(!isNewQualifier));

    add(form);
}
 
Example 20
Source Project: inception   Source File: RecommenderEditorPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void autoUpdateName(AjaxRequestTarget aTarget, TextField<String> aField,
        Recommender aRecommender)
{
    if (!autoGenerateName || aRecommender == null) {
        return;
    }

    aField.setModelObject(generateName(aRecommender));
    
    if (aTarget != null) {
        aTarget.add(aField);
    }
}
 
Example 21
Source Project: inception   Source File: ExternalRecommenderTraitsEditor.java    License: Apache License 2.0 5 votes vote down vote up
public ExternalRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender)
{
    super(aId, aRecommender);
    
    traits = toolFactory.readTraits(aRecommender.getObject());

    Form<ExternalRecommenderTraits> form = new Form<ExternalRecommenderTraits>(MID_FORM,
            CompoundPropertyModel.of(Model.of(traits)))
    {
        private static final long serialVersionUID = -3109239605742291123L;

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

    TextField<String> remoteUrl = new TextField<>("remoteUrl");
    remoteUrl.setRequired(true);
    remoteUrl.add(new UrlValidator());
    form.add(remoteUrl);

    CheckBox trainable = new CheckBox("trainable");
    trainable.setOutputMarkupId(true);
    trainable.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> 
            _target.add(getTrainingStatesChoice())));
    form.add(trainable);
    
    getTrainingStatesChoice().add(visibleWhen(() -> trainable.getModelObject() == true));
    
    add(form);
}
 
Example 22
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 23
Source Project: onedev   Source File: NumericPropertyEditor.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new TextField<Number>("input", Model.of(getModelObject()));
	input.setType(getDescriptor().getPropertyClass());
	add(input);
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
	
	Method getter = getDescriptor().getPropertyGetter();
	if (getter.getAnnotation(OmitName.class) != null) {
		input.add(AttributeModifier.replace("placeholder", EditableUtils.getDisplayName(getter)));
	} else {
		NameOfEmptyValue nameOfEmptyValue = getter.getAnnotation(NameOfEmptyValue.class);
		if (nameOfEmptyValue != null)
			input.add(AttributeModifier.replace("placeholder", nameOfEmptyValue.value()));
	}
}
 
Example 24
Source Project: onedev   Source File: AccessTokenPanel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	IModel<String> valueModel = new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			return getUser().getAccessToken();
		}
		
	};
	add(new TextField<String>("value", valueModel) {

		@Override
		protected String[] getInputTypes() {
			return new String[] {"password"};
		}
		
	});
	
	add(new CopyToClipboardLink("copy", valueModel));
	
	add(new Link<Void>("regenerate") {

		@Override
		public void onClick() {
			getUser().setAccessToken(RandomStringUtils.randomAlphanumeric(User.ACCESS_TOKEN_LEN));
			OneDev.getInstance(UserManager.class).save(getUser());
			Session.get().success("Access token regenerated");
			setResponsePage(getPage());
		}
		
	}.add(new ConfirmClickModifier("This will invalidate current token and generate a new one, do you want to continue?")));
}
 
Example 25
Source Project: onedev   Source File: AvatarUploadField.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(dataField = new TextField<String>("data", Model.of(getModelObject())));
	
	WebComponent fileInput = new WebComponent("fileInput");
	fileInput.setOutputMarkupId(true);
	add(fileInput);
	
	add(new WebMarkupContainer("fileLabel") {

		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			tag.put("for", fileInput.getMarkupId());
		}
		
	});
	
	add(behavior = new AbstractPostAjaxBehavior() {
		
		@Override
		protected void respond(AjaxRequestTarget target) {
			send(AvatarUploadField.this, Broadcast.BUBBLE, new AvatarFileSelected(target));	
		}
		
	});
}
 
Example 26
@Override
protected void addComponents(Form<Settings> form) {

	final TextField<String> mailServerIpField = new TextField<String>("mailServer.ip");
       form.add(mailServerIpField);
       final TextField<Integer> mailServerPortField = new TextField<Integer>("mailServer.port");
       form.add(mailServerPortField);
       final TextField<String> mailServerSenderField = new TextField<String>("mailServer.from");
       form.add(mailServerSenderField);
       final TextField<String> mailServerUsernameField = new TextField<String>("mailServer.username");
       form.add(mailServerUsernameField);
       final PasswordTextField mailServerPasswordField = new PasswordTextField("mailServer.password");
       mailServerPasswordField.setResetPassword(false);
       mailServerPasswordField.setRequired(false);
       form.add(mailServerPasswordField);
       final CheckBox tlsCheckField = new CheckBox("mailServer.enableTls");
       form.add(tlsCheckField);        
       form.add(new MailServerValidator(new FormComponent[] {mailServerIpField, mailServerPortField, mailServerSenderField}));
       
       final TextField<String> distributorDatePatternField = new TextField<String>("distributor.datePattern");
       distributorDatePatternField.add(new JcrNameValidator(getString("Settings.general.distributorDatePattern.error")));
       form.add(distributorDatePatternField);
       final TextField<String> distributorTimePatternField = new TextField<String>("distributor.timePattern");
       distributorTimePatternField.add(new JcrNameValidator(getString("Settings.general.distributorTimePattern.error")));
       form.add(distributorTimePatternField);
       
       Settings settings = storageService.getSettings();
       oldMailPort = settings.getMailServer().getPort();
       oldMailIp = settings.getMailServer().getIp();
       
}
 
Example 27
Source Project: yes-cart   Source File: ShoppingCartItemsList.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adjust quantity.
 *
 * @param productSkuCode sku code
 * @param supplier       supplier
 * @param qtyField       quantity input box  @return BookmarkablePageLink for remove one sku from cart command
 */
private Button createAddSeveralSkuButton(final String productSkuCode, final String supplier, final TextField<BigDecimal> qtyField) {
    final Button adjustQuantityButton = new Button(QUANTITY_ADJUST_BUTTON) {
        @Override
        public void onSubmit() {
            String qty = qtyField.getInput();
            if (StringUtils.isNotBlank(qty)) {
                qty = qty.replace(',', '.');
            }
            /*try {
                skuCode = URLEncoder.encode(productSkuCode, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                skuCode = productSkuCode;
            }*/


            if (NumberUtils.isNumber(qty)) {
                qtyField.setConvertedInput(new BigDecimal(qty).setScale(Constants.MONEY_SCALE, BigDecimal.ROUND_HALF_UP));
                setResponsePage(
                        getPage().getPageClass(),
                        new PageParameters()
                                .add(ShoppingCartCommand.CMD_SETQTYSKU, productSkuCode)
                                .add(ShoppingCartCommand.CMD_P_SUPPLIER, supplier)
                                .add(ShoppingCartCommand.CMD_P_QTY, qty)
                );


            } else {
                qtyField.setConvertedInput(MoneyUtils.ONE);
                error(getLocalizer().getString("nonZeroDigits", this, "Need positive integer value"));
            }
        }
    };
    adjustQuantityButton.setDefaultFormProcessing(true);
    return adjustQuantityButton;
}
 
Example 28
/**
 * Creates a simple TextField and sets the focus on it. Overwrite this method if you want to add for example an auto completion text field
 * (ajax). Please don't forget to call addSearchFieldTooltip() in your method!
 */
protected TextField< ? > createSearchTextField()
{
  final TextField<String> searchField = new TextField<String>(InputPanel.WICKET_ID, new PropertyModel<String>(getSearchFilter(),
      "searchString"));
  createSearchFieldTooltip(searchField);
  searchField.add(WicketUtils.setFocus());
  return searchField;
}
 
Example 29
Source Project: openmeetings   Source File: OAuthForm.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	add(new CheckBox("isEnabled"));
	add(new RequiredTextField<String>("name").setLabel(new ResourceModel("165")));
	add(new TextField<String>("iconUrl").setLabel(new ResourceModel("1575")));
	add(new RequiredTextField<String>("clientId").setLabel(Model.of("client_id")));
	add(new RequiredTextField<String>("clientSecret").setLabel(Model.of("client_secret")));
	add(redirectUriText = (TextField<String>) new TextField<>("redirectUri", Model.of("")).setLabel(new ResourceModel("1587")));
	add(new RequiredTextField<String>("requestKeyUrl").setLabel(new ResourceModel("1578")));
	add(new DropDownChoice<>("requestTokenMethod", List.of(RequestTokenMethod.values()), new ChoiceRenderer<RequestTokenMethod>("name", "name")));
	add(new RequiredTextField<String>("requestTokenUrl").setLabel(new ResourceModel("1579")));
	add(new RequiredTextField<String>("requestTokenAttributes").setLabel(new ResourceModel("1586")));
	add(new RequiredTextField<String>("requestInfoUrl").setLabel(new ResourceModel("1580")));
	add(new DropDownChoice<>("requestInfoMethod", List.of(RequestInfoMethod.values()), new ChoiceRenderer<RequestInfoMethod>("name", "name")));
	Form<Void> mappingForm = new Form<>("mappingForm");
	final TextField<String> omAttr = new TextField<>("omAttr", Model.of(""));
	final TextField<String> oauthAttr = new TextField<>("oauthAttr", Model.of(""));
	add(mappingForm.add(omAttr, oauthAttr
			, new BootstrapAjaxButton("addMapping", new ResourceModel("1261"), mappingForm, Buttons.Type.Outline_Primary) {
				private static final long serialVersionUID = 1L;

				@Override
				protected void onSubmit(AjaxRequestTarget target) {
					if (Strings.isEmpty(omAttr.getModelObject()) || Strings.isEmpty(oauthAttr.getModelObject())) {
						return;
					}
					OAuthServer s = OAuthForm.this.getModelObject();
					s.addMapping(omAttr.getModelObject(), oauthAttr.getModelObject());
					updateMapping();
					target.add(attrsContainer, mappingForm);
				}
			}).setOutputMarkupId(true));
	add(attrsContainer.add(updateMapping()).setOutputMarkupId(true));
	super.onInitialize();
}
 
Example 30
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);
}