Search in sources :

Example 11 with FormComponent

use of org.apache.wicket.markup.html.form.FormComponent in project wicket by apache.

the class AjaxFormComponentUpdatingBehavior method onBind.

/**
 * @see org.apache.wicket.behavior.AbstractAjaxBehavior#onBind()
 */
@Override
protected void onBind() {
    super.onBind();
    Component component = getComponent();
    if (!(component instanceof FormComponent)) {
        throw new WicketRuntimeException("Behavior " + getClass().getName() + " can only be added to an instance of a FormComponent");
    }
    checkComponent((FormComponent<?>) component);
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) WicketRuntimeException(org.apache.wicket.WicketRuntimeException) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent)

Example 12 with FormComponent

use of org.apache.wicket.markup.html.form.FormComponent in project wicket by apache.

the class BaseWicketTester method serializeFormToRequest.

/**
 * Puts all not already scheduled (e.g. via {@link FormTester#setValue(String, String)}) form
 * component values in the post parameters for the next form submit
 *
 * @param form
 *            the {@link Form} which components should be submitted
 */
private void serializeFormToRequest(final Form<?> form) {
    final MockRequestParameters postParameters = request.getPostParameters();
    final Set<String> currentParameterNamesSet = postParameters.getParameterNames();
    form.visitFormComponents(new IVisitor<FormComponent<?>, Void>() {

        @Override
        public void component(final FormComponent<?> formComponent, final IVisit<Void> visit) {
            final String inputName = formComponent.getInputName();
            if (!currentParameterNamesSet.contains(inputName)) {
                String[] values = FormTester.getInputValue(formComponent);
                for (String value : values) {
                    postParameters.addParameterValue(inputName, value);
                }
            }
        }
    });
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) MockRequestParameters(org.apache.wicket.mock.MockRequestParameters)

Example 13 with FormComponent

use of org.apache.wicket.markup.html.form.FormComponent in project wicket by apache.

the class FormTester method setValue.

/**
 * Simulates filling in a field on a <code>Form</code>.
 *
 * @param formComponentId
 *            relative path (from <code>Form</code>) to the selectable
 *            <code>FormComponent</code> or <code>IFormSubmittingComponent</code>
 * @param value
 *            the field value
 * @return This
 */
public FormTester setValue(final String formComponentId, final String value) {
    Component component = workingForm.get(formComponentId);
    Assert.assertNotNull("Unable to set value. Couldn't find component with name: " + formComponentId, component);
    return setValue(component, value);
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) AbstractTextComponent(org.apache.wicket.markup.html.form.AbstractTextComponent) Component(org.apache.wicket.Component) IFormSubmittingComponent(org.apache.wicket.markup.html.form.IFormSubmittingComponent)

Example 14 with FormComponent

use of org.apache.wicket.markup.html.form.FormComponent in project wicket by apache.

the class AjaxEditableTest method testUpdateValue.

/**
 * A test that changes the value of the {@link AjaxEditableLabel}
 */
@SuppressWarnings({ "unchecked" })
@Test
public void testUpdateValue() {
    Page page = tester.getLastRenderedPage();
    AjaxEditableLabel<String> ajaxLabel = (AjaxEditableLabel<String>) page.get("ajaxLabel");
    tester.assertInvisible("ajaxLabel:editor");
    tester.assertVisible("ajaxLabel:label");
    // assert the initial value
    tester.assertLabel("ajaxLabel:label", "ajaxTest");
    // click on the label to go to edit mode
    tester.executeAjaxEvent("ajaxLabel:label", "click");
    tester.assertVisible("ajaxLabel:editor");
    tester.assertInvisible("ajaxLabel:label");
    FormComponent<?> editor = (FormComponent<?>) ajaxLabel.get("editor");
    // set some new value and submit it
    tester.getRequest().setParameter(editor.getInputName(), "something");
    tester.getRequest().setParameter("save", "true");
    tester.executeBehavior((AbstractAjaxBehavior) editor.getBehaviorById(0));
    tester.assertInvisible("ajaxLabel:editor");
    tester.assertVisible("ajaxLabel:label");
    tester.assertLabel("ajaxLabel:label", "something");
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) Page(org.apache.wicket.Page) Test(org.junit.Test)

Example 15 with FormComponent

use of org.apache.wicket.markup.html.form.FormComponent in project wicket by apache.

the class FormGroup method onConfigure.

@Override
protected void onConfigure() {
    super.onConfigure();
    // set all components visible
    help.setVisible(true);
    label.setVisible(true);
    feedback.setVisible(true);
    // clear feedback message and current state
    stateClassName = "";
    feedback.setDefaultModelObject("");
    final List<FormComponent<?>> formComponents = findFormComponents();
    for (final FormComponent<?> fc : formComponents) {
        final FeedbackMessages messages = fc.getFeedbackMessages();
        if (!messages.isEmpty()) {
            final FeedbackMessage worstMessage = getWorstMessage(messages);
            worstMessage.markRendered();
            feedback.setDefaultModelObject(worstMessage.getMessage());
            // render worst message of first found child component with feedback message
            break;
        }
    }
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) FeedbackMessages(org.apache.wicket.feedback.FeedbackMessages)

Aggregations

FormComponent (org.apache.wicket.markup.html.form.FormComponent)19 InputPanel (com.evolveum.midpoint.web.component.prism.InputPanel)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 Component (org.apache.wicket.Component)5 ArrayList (java.util.ArrayList)4 AttributeModifier (org.apache.wicket.AttributeModifier)4 PropertyModel (org.apache.wicket.model.PropertyModel)4 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)3 List (java.util.List)3 IModel (org.apache.wicket.model.IModel)3 ListModel (org.apache.wicket.model.util.ListModel)3 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)2 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)2 NotNullValidator (com.evolveum.midpoint.web.component.input.validator.NotNullValidator)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)2 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)2 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)2 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2