Java Code Examples for org.apache.wicket.markup.html.form.TextField#setOutputMarkupId()

The following examples show how to use org.apache.wicket.markup.html.form.TextField#setOutputMarkupId() . 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 File: OClassSearchPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    setOutputMarkupPlaceholderTag(true);
    if ((selectedClassModel == null || selectedClassModel.getObject() == null) && !classesGetter.get().isEmpty())
        selectedClassModel = new OClassModel(classesGetter.get().get(0));

    Form<String> form = new Form<>("form", getModel());
    TextField<String> field = new TextField<>("query", getModel());
    field.setOutputMarkupId(true);
    field.add(AttributeModifier.replace("placeholder", new ResourceModel("page.search.placeholder").getObject()));
    form.add(field);
    form.add(createSearchButton("search"));
    form.add(createTabsPanel("tabs"));
    form.add(resultsContainer = createResultsContainer("resultsContainer"));
    add(form);
    resultsContainer.add(createEmptyLabel("resultsLabel"));
    prepareResults();
}
 
Example 2
Source File: RootConceptsPanel.java    From inception with Apache License 2.0 5 votes vote down vote up
private TextField<String> buildTextField(String id, IModel<IRI> model) {
    IModel<String> adapter = new LambdaModelAdapter<String>(
        () -> model.getObject().stringValue(),
        str -> model.setObject(SimpleValueFactory.getInstance().createIRI(str)));

    TextField<String> iriTextfield = new TextField<>(id, adapter);
    iriTextfield.setOutputMarkupId(true);
    iriTextfield.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> {
        // Do nothing just update the model values
    }));
    iriTextfield.setEnabled(false);
    return iriTextfield;
}
 
Example 3
Source File: AbstractInfoPanel.java    From inception with 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 4
Source File: StatementEditor.java    From inception with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new fragement for editing a statement.<br>
 * The editor has two slightly different behaviors, depending on the value of
 * {@code isNewStatement}:
 * <ul>
 * <li>{@code !isNewStatement}: Save button commits changes, cancel button discards unsaved
 * changes, delete button removes the statement from the KB.</li>
 * <li>{@code isNewStatement}: Save button commits changes (creates a new statement in the
 * KB), cancel button removes the statement from the UI, delete button is not visible.</li>
 * </ul>
 * 
 * @param aId
 *            markup ID
 * @param aStatement
 *            statement model
 * @param isNewStatement
 *            whether the statement being edited is new, meaning it has no corresponding
 *            statement in the KB backend
 */
public EditMode(String aId, IModel<KBStatement> aStatement, boolean isNewStatement) {
    super(aId, "editMode", StatementEditor.this, aStatement);

    Form<KBStatement> form = new Form<>("form", CompoundPropertyModel.of(aStatement));

    // text area for the statement value should receive focus
    Component valueTextArea = new TextArea<String>("value");
    valueTextArea.setOutputMarkupId(true);
    initialFocusComponent = valueTextArea;
    form.add(valueTextArea);

    // FIXME This field should only be visible if the selected datatype is
    // langString

    TextField<String> textField = new TextField<>("language");
    textField.setOutputMarkupId(true);
    form.add(textField);

    // FIXME Selection of the data type should only be possible if it is not
    // restricted to a single type in the property definition - take into account
    // inheritance?
    //form.add(new TextField<>("datatype"));

    // We do not allow the user to change the property

    // FIXME should offer different editors depending on the data type
    // in particular when the datatype is a concept type, then
    // it should be possible to select an instance of that concept using some
    // auto-completing dropdown box

    form.add(new LambdaAjaxButton<>("save", StatementEditor.this::actionSave));
    form.add(new LambdaAjaxLink("cancel", t -> {
        if (isNewStatement) {
            StatementEditor.this.actionCancelNewStatement(t);
        } else {
            StatementEditor.this.actionCancelExistingStatement(t);
        }
    }));
    form.add(new LambdaAjaxLink("delete", StatementEditor.this::actionDelete)
            .setVisibilityAllowed(!isNewStatement));
    add(form);
}
 
Example 5
Source File: CompanyProfileEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public CompanyProfileEdit(String id, CompanyProfile companyProfile) {

		super(id, new Model(companyProfile));

		WebMarkupContainer companyNameContainer = new WebMarkupContainer(
				"companyNameContainer");
		companyNameContainer.add(new Label("companyNameLabel",
				new ResourceModel("profile.business.company.name")));
		TextField companyName = new TextField("companyName",
				new PropertyModel(companyProfile, "companyName"));
		companyName.setOutputMarkupId(true);
		companyNameContainer.add(companyName);
		String companyNameId = companyName.getMarkupId();
		Label companyNameAccessibilityLabel = new Label("companyNameAccessibilityLabel", new ResourceModel("accessibility.profile.companyname.input"));
		companyNameAccessibilityLabel.add(new AttributeAppender("for",new Model(companyNameId)," "));
		companyNameContainer.add(companyNameAccessibilityLabel);

		add(companyNameContainer);

		WebMarkupContainer companyWebAddressContainer = new WebMarkupContainer(
				"companyWebAddressContainer");
		companyWebAddressContainer.add(new Label("companyWebAddressLabel",
				new ResourceModel("profile.business.company.web")));

		TextField companyWebAddress = new TextField("companyWebAddress",
				new PropertyModel(companyProfile, "companyWebAddress")) {

			private static final long serialVersionUID = 1L;

			// add http:// if missing
			@Override
			protected void convertInput() {
				String input = getInput();

				if (StringUtils.isNotBlank(input)
						&& !(input.startsWith("http://") || input
								.startsWith("https://"))) {
					setConvertedInput("http://" + input);
				} else {
					setConvertedInput(StringUtils.isBlank(input) ? null : input);
				}
			}
		};
		companyWebAddress.setOutputMarkupId(true);
		companyWebAddress.add(new UrlValidator());
		companyWebAddressContainer.add(companyWebAddress);
		String companyUrlId = companyWebAddress.getMarkupId();
		Label companyUrlAccessibilityLabel = new Label("companyUrlAccessibilityLabel", new ResourceModel("accessibility.profile.companyurl.input"));
		companyUrlAccessibilityLabel.add(new AttributeAppender("for",new Model(companyUrlId)," "));
		companyWebAddressContainer.add(companyUrlAccessibilityLabel);

		final FeedbackLabel companyWebAddressFeedback = new FeedbackLabel(
				"companyWebAddressFeedback", companyWebAddress);
		companyWebAddressFeedback.setOutputMarkupId(true);
		companyWebAddressContainer.add(companyWebAddressFeedback);
		companyWebAddress.add(new ComponentVisualErrorBehaviour("onblur",
				companyWebAddressFeedback));
		companyWebAddress.add(new AttributeAppender("aria-describedby",new Model(companyWebAddressFeedback.getMarkupId())," "));

		add(companyWebAddressContainer);

		WebMarkupContainer companyDescriptionContainer = new WebMarkupContainer(
				"companyDescriptionContainer");
		companyDescriptionContainer.add(new Label("companyDescriptionLabel",
				new ResourceModel("profile.business.company.description")));
		TextArea companyDescription = new TextArea("companyDescription",
				new PropertyModel(companyProfile, "companyDescription"));
		companyDescription.setOutputMarkupId(true);
		companyDescriptionContainer.add(companyDescription);
		String companyDescriptionId = companyDescription.getMarkupId();
		Label companyDescriptionAccessibilityLabel = new Label("companyDescriptionAccessibilityLabel", new ResourceModel("accessibility.profile.companydescription.input"));
		companyDescriptionAccessibilityLabel.add(new AttributeAppender("for",new Model(companyDescriptionId)," "));
		companyDescriptionContainer.add(companyDescriptionAccessibilityLabel);

		add(companyDescriptionContainer);
	}
 
Example 6
Source File: CompanyProfileEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public CompanyProfileEdit(String id, CompanyProfile companyProfile) {

		super(id, new Model(companyProfile));

		WebMarkupContainer companyNameContainer = new WebMarkupContainer(
				"companyNameContainer");
		companyNameContainer.add(new Label("companyNameLabel",
				new ResourceModel("profile.business.company.name")));
		TextField companyName = new TextField("companyName",
				new PropertyModel(companyProfile, "companyName"));
		companyName.setOutputMarkupId(true);
		companyNameContainer.add(companyName);
		String companyNameId = companyName.getMarkupId();
		Label companyNameAccessibilityLabel = new Label("companyNameAccessibilityLabel", new ResourceModel("accessibility.profile.companyname.input"));
		companyNameAccessibilityLabel.add(new AttributeAppender("for",new Model(companyNameId)," "));
		companyNameContainer.add(companyNameAccessibilityLabel);

		add(companyNameContainer);

		WebMarkupContainer companyWebAddressContainer = new WebMarkupContainer(
				"companyWebAddressContainer");
		companyWebAddressContainer.add(new Label("companyWebAddressLabel",
				new ResourceModel("profile.business.company.web")));

		TextField companyWebAddress = new TextField("companyWebAddress",
				new PropertyModel(companyProfile, "companyWebAddress")) {

			private static final long serialVersionUID = 1L;

			// add http:// if missing
			@Override
			protected void convertInput() {
				String input = getInput();

				if (StringUtils.isNotBlank(input)
						&& !(input.startsWith("http://") || input
								.startsWith("https://"))) {
					setConvertedInput("http://" + input);
				} else {
					setConvertedInput(StringUtils.isBlank(input) ? null : input);
				}
			}
		};
		companyWebAddress.setOutputMarkupId(true);
		companyWebAddress.add(new UrlValidator());
		companyWebAddressContainer.add(companyWebAddress);
		String companyUrlId = companyWebAddress.getMarkupId();
		Label companyUrlAccessibilityLabel = new Label("companyUrlAccessibilityLabel", new ResourceModel("accessibility.profile.companyurl.input"));
		companyUrlAccessibilityLabel.add(new AttributeAppender("for",new Model(companyUrlId)," "));
		companyWebAddressContainer.add(companyUrlAccessibilityLabel);

		final FeedbackLabel companyWebAddressFeedback = new FeedbackLabel(
				"companyWebAddressFeedback", companyWebAddress);
		companyWebAddressFeedback.setOutputMarkupId(true);
		companyWebAddressContainer.add(companyWebAddressFeedback);
		companyWebAddress.add(new ComponentVisualErrorBehaviour("onblur",
				companyWebAddressFeedback));
		companyWebAddress.add(new AttributeAppender("aria-describedby",new Model(companyWebAddressFeedback.getMarkupId())," "));

		add(companyWebAddressContainer);

		WebMarkupContainer companyDescriptionContainer = new WebMarkupContainer(
				"companyDescriptionContainer");
		companyDescriptionContainer.add(new Label("companyDescriptionLabel",
				new ResourceModel("profile.business.company.description")));
		TextArea companyDescription = new TextArea("companyDescription",
				new PropertyModel(companyProfile, "companyDescription"));
		companyDescription.setOutputMarkupId(true);
		companyDescriptionContainer.add(companyDescription);
		String companyDescriptionId = companyDescription.getMarkupId();
		Label companyDescriptionAccessibilityLabel = new Label("companyDescriptionAccessibilityLabel", new ResourceModel("accessibility.profile.companydescription.input"));
		companyDescriptionAccessibilityLabel.add(new AttributeAppender("for",new Model(companyDescriptionId)," "));
		companyDescriptionContainer.add(companyDescriptionAccessibilityLabel);

		add(companyDescriptionContainer);
	}
 
Example 7
Source File: ODateTimeField.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
private TextField<Integer> createHoursField(String id, int hours) {
    TextField<Integer> field = new TextField<>(id, Model.of(hours), Integer.class);
    field.setOutputMarkupId(true);
    field.add(RangeValidator.range(0, isSupportAmPm() ? 12 : 23));
    return field;
}
 
Example 8
Source File: ODateTimeField.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
private TextField<Integer> createMinutesField(String id, int minutes) {
    TextField<Integer> field = new TextField<>(id, Model.of(minutes), Integer.class);
    field.setOutputMarkupId(true);
    field.add(RangeValidator.range(0, 59));
    return field;
}
 
Example 9
Source File: DefineDrillEntityPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public DefineDrillEntityPanel(String id, String type, final DrillDownEntity drillEntity, Entity entity) {
	super(id, new CompoundPropertyModel<DrillDownEntity>(drillEntity));
	
	this.type = type;
	
	final Label widgetLabel = new Label("entityLabel", getString(type));		
	add(widgetLabel);
	
	final DropDownChoice<Entity> entityChoice = new DropDownChoice<Entity>("entities", 
			new PropertyModel<Entity>(drillEntity, "entity"), new WidgetDropDownModel(), new EntityChoiceRenderer());
	entityChoice.setOutputMarkupPlaceholderTag(true);
	entityChoice.setOutputMarkupId(true);
	entityChoice.setRequired(true);
	add(entityChoice);
	
	final Label linkLabel = new Label("linkLabel", getString("ActionContributor.Drill.parameter"));
	linkLabel.setOutputMarkupId(true);
	linkLabel.setOutputMarkupPlaceholderTag(true);
	add(linkLabel);
	
	final DropDownChoice<String> paramChoice = new DropDownChoice<String>("parameters",
               new PropertyModel<String>(drillEntity, "linkParameter"), parameters, new ChoiceRenderer<String>());
       paramChoice.setRequired(true);
       paramChoice.setLabel(new Model<String>( getString("ActionContributor.Drill.parameter")));
       paramChoice.setOutputMarkupId(true);
       paramChoice.setOutputMarkupPlaceholderTag(true);
       add(paramChoice);
       
       final Label columnLabel = new Label("columnLabel",  getString("ActionContributor.Drill.column"));            
       columnLabel.setOutputMarkupId(true);
       columnLabel.setOutputMarkupPlaceholderTag(true);
	add(columnLabel);
                   
       final TextField<Integer> columnField = new TextField<Integer>("column");            
       columnField.setOutputMarkupId(true);
       columnField.setOutputMarkupPlaceholderTag(true);
       add(columnField);
       
       if (drillEntity.getIndex() == 0) {
       	if (entity instanceof Chart) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		 
       	}
       } else {
       	if (DrillDownUtil.getLastDrillType(entity) == DrillDownEntity.CHART_TYPE) {
       		columnLabel.setVisible(false);            	
       		columnField.setVisible(false);            		   
       	} 
       }
       
       entityChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

           @Override
           protected void onUpdate(AjaxRequestTarget target) {
          	updateParameters(drillEntity);                     
              target.add(paramChoice);
           }

       }); 
       
}