Examples of FormComponent


Examples of org.apache.wicket.markup.html.form.FormComponent

    Bean bean = new Bean();
    Form<Bean> form = new Form<Bean>("form", new CompoundPropertyModel<Bean>(bean));
    add(form);
    form.setOutputMarkupId(true);

    FormComponent fc;

    // add form components to the form as usual

    fc = new RequiredTextField<String>("name");
    fc.add(new StringValidator(4, null));
    fc.setLabel(new ResourceModel("label.name"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));

    fc = new RequiredTextField<String>("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));

    // attach an ajax validation behavior to all form component's keydown
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

  {
    // initialize
    form.loadPersistentFormComponentValues();

    // validate
    FormComponent username = (FormComponent)panel.get("signInForm:username");

    Assert.assertNotNull(username);

    Assert.assertNotNull(cookieUsername);

    Assert.assertEquals(cookieUsername.getValue(), username.getModelObjectAsString());
  }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

   *            index of the selectable option, starting from 0
   */
  public void select(String formComponentId, int index)
  {
    checkClosed();
    FormComponent component = (FormComponent)workingForm.get(formComponentId);

    ChoiceSelector choiceSelector = choiceSelectorFactory.create(component);
    choiceSelector.doSelect(index);
    if (component instanceof DropDownChoice)
    {
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

   */
  public void setFile(final String formComponentId, final File file, final String contentType)
  {
    checkClosed();

    FormComponent formComponent = (FormComponent)workingForm.get(formComponentId);

    if (formComponent instanceof FileUploadField == false)
    {
      throw new IllegalArgumentException("'" + formComponentId + "' is not " +
        "a FileUploadField. You can only attach a file to form " +
        "component of this type.");
    }

    MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
    servletRequest.addFile(formComponent.getInputName(), file, contentType);
  }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

   *
   * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
   */
  protected final void respond(final AjaxRequestTarget target)
  {
    final FormComponent formComponent = getFormComponent();

    try
    {
      formComponent.inputChanged();
      formComponent.validate();
      if (formComponent.hasErrorMessage())
      {
        formComponent.invalid();

        onError(target, null);
      }
      else
      {
        formComponent.valid();
        formComponent.updateModel();
        onUpdate(target);
      }
    }
    catch (RuntimeException e)
    {
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

    private FormComponent addRasterTable(final CoverageStoreInfo storeInfo, final IModel paramsModel) {

        final String resourceKey = RESOURCE_KEY_PREFIX + "." + TABLE_NAME;

        boolean isNew = storeInfo.getId() == null;
        FormComponent tableComponent = addTableNameComponent(paramsModel, isNew);
        return tableComponent;
    }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

     * @return a combobox set up to display the list of available raster tables if the StoreInfo is
     *         new, or a non editable text box if we're editing an existing StoreInfo
     */
    private FormComponent addTableNameComponent(final IModel paramsModel, final boolean isNew) {

        final FormComponent tableNameComponent;
        final String panelId = "tableNamePanel";

        if (isNew) {
            RasterTableSelectionPanel selectionPanel;
            selectionPanel = new RasterTableSelectionPanel(panelId, paramsModel, storeEditForm,
                    server, port, instance, user, password);
            add(selectionPanel);

            DropDownChoice tableDropDown = selectionPanel.getFormComponent();
            tableNameComponent = tableDropDown;
        } else {
            /*
             * We're editing an existing store. Don't allow to change the table name, it could be
             * catastrophic for the Catalog/ResourcePool as ability to get to the coverage is really
             * based on the Store's URL and the CoverageInfo is tied to it
             */
            final IModel paramValue = new MapModel(paramsModel, TABLE_NAME);
            final String resourceKey = RESOURCE_KEY_PREFIX + "." + TABLE_NAME;
            final IModel paramLabelModel = new ResourceModel(resourceKey, TABLE_NAME);
            final boolean required = true;
            TextParamPanel tableNamePanel;
            tableNamePanel = new TextParamPanel(panelId, paramValue, paramLabelModel, required);
            add(tableNamePanel);

            tableNameComponent = tableNamePanel.getFormComponent();
            tableNameComponent.setEnabled(false);

            final String titleKey = resourceKey + ".title";
            ResourceModel titleModel = new ResourceModel(titleKey);
            String title = String.valueOf(titleModel.getObject());

View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

        Form form = tester.getForm();
        form.visitChildren(new Component.IVisitor() {
           
            public Object component(Component component) {
                if(component instanceof FormComponent) {
                    FormComponent fc = (FormComponent) component;
                    String name = fc.getInputName();
                    String value = fc.getValue();
                   
                    tester.setValue(name, value);
                }
                return Component.IVisitor.CONTINUE_TRAVERSAL;
            }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

     *
     * @see IFormValidator#validate(Form)
     */
    public void validate(final Form form) {
        final FormComponent[] components = getDependentFormComponents();
        final FormComponent wsComponent = components[0];
        final FormComponent nameComponent = components[1];

        WorkspaceInfo workspace = (WorkspaceInfo) wsComponent.getConvertedInput();
        String name = (String) nameComponent.getConvertedInput();
       
        if(name == null) {
            ValidationError error = new ValidationError();
            error.addMessageKey("StoreNameValidator.storeNameRequired");
            nameComponent.error((IValidationError) error);
            return;
        }

        Catalog catalog = GeoServerApplication.get().getCatalog();

        final StoreInfo existing = catalog.getStoreByName(workspace, name, StoreInfo.class);
        if (existing != null) {
            final String existingId = existing.getId();
            if (!existingId.equals(edittingStoreId)) {
                ValidationError error = new ValidationError();
                error.addMessageKey("StoreNameValidator.storeExistsInWorkspace");
                error.setVariable("workspace", workspace.getName());
                error.setVariable("storeName", name);
                nameComponent.error((IValidationError) error);
            }
        }
    }
View Full Code Here

Examples of org.apache.wicket.markup.html.form.FormComponent

   * @see org.apache.wicket.ajax.AjaxEventBehavior#onEvent(org.apache.wicket.ajax.AjaxRequestTarget)
   */
  @Override
  protected final void onEvent(final AjaxRequestTarget target)
  {
    final FormComponent formComponent = getFormComponent();

    if (getEvent().toLowerCase().equals("onblur") && disableFocusOnBlur())
    {
      target.focusComponent(null);
    }

    try
    {
      formComponent.inputChanged();
      formComponent.validate();
      if (formComponent.hasErrorMessage())
      {
        formComponent.invalid();

        onError(target, null);
      }
      else
      {
        formComponent.valid();
        if (getUpdateModel())
        {
          formComponent.updateModel();
        }

        onUpdate(target);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.