Example usage for org.apache.wicket.ajax.form AjaxFormSubmitBehavior AjaxFormSubmitBehavior

List of usage examples for org.apache.wicket.ajax.form AjaxFormSubmitBehavior AjaxFormSubmitBehavior

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.form AjaxFormSubmitBehavior AjaxFormSubmitBehavior.

Prototype

public AjaxFormSubmitBehavior(Form<?> form, String event) 

Source Link

Document

Construct.

Usage

From source file:guru.mmp.application.web.template.components.ExtensibleFormDialogImplementation.java

License:Apache License

/**
 * Returns the buttons associated with the extensible dialog.
 *
 * @return the buttons associated with the extensible dialog
 *//*  w w w  .j ava 2  s .c  o  m*/
@Override
protected List<ExtensibleDialogButton> getButtons() {
    ExtensibleDialogButton cancelButton = new ExtensibleDialogButton(cancelText);

    cancelButton.add(new AjaxEventBehavior("click") {
        @Override
        protected void onEvent(AjaxRequestTarget target) {
            System.out.println("[DEBUG][cancelButton][onSubmit] HERE!!!!");

            ExtensibleFormDialogImplementation.this.onCancel(target, form);

            // resetExtensibleFormDialogImplementation(target);

            getDialog().hide(target);
        }
    });

    ExtensibleDialogButton submitButton = new ExtensibleDialogButton(submitText, true);

    submitButton.add(new AjaxFormSubmitBehavior(form, "click") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            if (target != null) {
                resetFeedbackMessages(target);
            }

            if (ExtensibleFormDialogImplementation.this.onSubmit(target,
                    ExtensibleFormDialogImplementation.this.form)) {
                getDialog().hide(target);
            } else {
                target.add(ExtensibleFormDialogImplementation.this.alerts);
            }
        }

        @Override
        protected void onAfterSubmit(AjaxRequestTarget target) {
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            if (target != null) {
                // Visit each form component and if it is visible re-render it.
                // NOTE: We have to re-render every component to remove stale validation error messages.
                form.visitFormComponents((formComponent, iVisit) -> {
                    if ((formComponent.getParent() != null) && formComponent.getParent().isVisible()
                            && formComponent.isVisible()) {
                        target.add(formComponent);
                    }
                });
            }

            ExtensibleFormDialogImplementation.this.onError(target, form);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);

            // Do not allow normal form submit to happen
            attributes.setPreventDefault(true);
        }

        @Override
        public boolean getDefaultProcessing() {
            return submitButton.getDefaultFormProcessing();
        }

        @Override
        public boolean getStatelessHint(Component component) {
            return false;
        }
    });
    submitButton.setDefaultFormProcessing(true);

    List<ExtensibleDialogButton> buttons = new ArrayList<>();
    buttons.add(submitButton);
    buttons.add(cancelButton);

    return buttons;
}

From source file:jp.go.nict.langrid.management.web.view.component.link.AjaxNonSubmitLink.java

License:Open Source License

/**
 * //from w w  w  .jav  a2  s.co m
 * 
 */
public AjaxNonSubmitLink(String componentId, Form form) {
    super(componentId);
    add(new AjaxFormSubmitBehavior(form, "onclick") {
        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return AjaxNonSubmitLink.this.getAjaxCallDecorator();
        }

        @Override
        protected CharSequence getEventHandler() {
            return new AppendingStringBuffer(super.getEventHandler()).append("; return false;");
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {
            // write the onclick handler only if link is enabled
            if (isLinkEnabled()) {
                super.onComponentTag(tag);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            AjaxNonSubmitLink.this.onError(target, getForm());
        }

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            if (getDefaultFormProcessing()) {
                super.onEvent(target);
            } else {
                onSubmit(target);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            AjaxNonSubmitLink.this.onSubmit(target, getForm());
        }

        private static final long serialVersionUID = 1L;
    });
}

From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.AjaxSubmitButtonLink.java

License:Apache License

public AjaxSubmitButtonLink(String id, IModel<T> model, IModel<String> labelModel, Form<?> form) {

    super(id, model, labelModel, form);

    this.add(new AjaxFormSubmitBehavior(form, "click") {

        private static final long serialVersionUID = 1L;

        @Override/*  w w  w .  j a v a 2  s .  c  om*/
        protected void onError(AjaxRequestTarget target) {

            AjaxSubmitButtonLink.this.onError(target, this.getForm());
        }

        @Override
        protected Form<?> findForm() {

            return AjaxSubmitButtonLink.this.getForm();
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {

            /* write the onclick handler only if link is enabled */
            if (AjaxSubmitButtonLink.this.isLinkEnabled()) {
                super.onComponentTag(tag);
            }
        }

        @Override
        public boolean getDefaultProcessing() {

            return AjaxSubmitButtonLink.this.getDefaultFormProcessing();
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {

            super.updateAjaxAttributes(attributes);
            AjaxSubmitButtonLink.this.updateAjaxAttributes(attributes);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {

            AjaxSubmitButtonLink.this.onSubmit(target, this.getForm());
        }

        @Override
        protected void onAfterSubmit(AjaxRequestTarget target) {

            AjaxSubmitButtonLink.this.onAfterSubmit(target, this.getForm());
        }
    });
}

From source file:net.kornr.swit.site.buttoneditor.ButtonEditor.java

License:Apache License

private void init() {
    this.innerAdd(new Image("logo", ButtonResource.getReference(),
            ButtonResource.getValueMap(s_logoTemplate, "The Swit Buttons Generator")));

    m_codeEncoder = new ButtonCodeMaker(m_selectedDescriptor, m_currentProperties,
            new PropertyModel<String>(this, "text"));

    final Form form = new Form("form") {

        @Override//from w w w .  j  a  va  2 s . c  o  m
        protected void onSubmit() {
            if (((WebRequest) (WebRequestCycle.get().getRequest())).isAjax() == false)
                createButton(null);
        }
    };
    this.innerAdd(form);

    Border sampleborder = new TableImageBorder("sampleborder", s_border3, Color.white);
    form.add(sampleborder);
    WebMarkupContainer samplecont = new WebMarkupContainer("samplecontainer");
    sampleborder.add(samplecont);
    samplecont.add((m_sample = new Image("sample")).setOutputMarkupId(true));
    sampleborder
            .add(new ColorPickerField("samplebgcolor", new PropertyModel<String>(this, "bgcolor"), samplecont));
    ImageButton submit = new ImageButton("submit", ButtonResource.getReference(),
            ButtonResource.getValueMap(s_buttonTemplate, "Update that button, now!"));
    sampleborder.add(submit);
    submit.add(new AjaxFormSubmitBehavior(form, "onclick") {
        @Override
        protected void onError(AjaxRequestTarget arg0) {
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            createButton(target);
        }

        @Override
        protected CharSequence getEventHandler() {
            return new AppendingStringBuffer(super.getEventHandler()).append("; return false;");
        }
    });
    sampleborder.add(m_downloadLink = new MutableResourceReferenceLink("downloadbutton",
            ButtonResource.getReference(), null));
    m_downloadLink.setOutputMarkupId(true);

    //      this.innerAdd(m_codeLabel = new Label("code", new PropertyModel(m_codeEncoder, "code")));
    //      m_codeLabel.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true).setEscapeModelStrings(false);
    //      m_codeLabel.setVisible(true);
    final ModalWindow codewindow = new ModalWindow("code");
    this.innerAdd(codewindow);
    Fragment codefrag = new Fragment(codewindow.getContentId(), "codepanel", this);
    Label lcode = new Label("code", new PropertyModel(m_codeEncoder, "code"));
    codefrag.add(lcode);
    codewindow.setContent(codefrag);
    codewindow.setTitle("Java Code");
    codewindow.setCookieName("switjavacodewindow");

    sampleborder.add(new AjaxLink("showwindowcode") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            codewindow.show(target);
        }
    });

    form.add((m_feedback = new FeedbackPanel("feedback")).setOutputMarkupId(true)
            .setOutputMarkupPlaceholderTag(true));

    ThreeColumnsLayoutManager layout = new ThreeColumnsLayoutManager("2col-layout", s_layout);
    form.add(layout);
    ColumnPanel rightcol = layout.getRightColumn();
    ColumnPanel leftcol = layout.getLeftColumn();

    Border textborder = new TableImageBorder("textborder", s_shadow, s_blocColor);
    layout.add(textborder);
    textborder.add(new TextField<String>("button-text", new PropertyModel<String>(this, "text")));

    Border buttonsborder = new TableImageBorder("buttonsborder", s_shadow, s_blocColor);
    layout.add(buttonsborder);
    buttonsborder.add(new ListView<ButtonDescriptor>("types", s_buttons) {
        @Override
        protected void populateItem(ListItem<ButtonDescriptor> item) {
            final IModel<ButtonDescriptor> model = item.getModel();
            ButtonDescriptor bd = item.getModelObject();

            ButtonTemplate tmpl = s_buttonsTemplates.get(bd.getName());
            if (tmpl == null) {
                tmpl = bd.createTemplate();
                try {
                    List<ButtonProperty> props = bd.getProperties();
                    bd.applyProperties(tmpl, props);
                    tmpl.setWidth(200);
                    tmpl.setFont(s_defaultButtonFont);
                    tmpl.setFontColor(Color.white);
                    tmpl.setShadowDisplayed(true);
                    tmpl.addEffect(new ShadowBorder(4, 0, 0, Color.black));
                    tmpl.setAutoExtend(true);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                s_buttonsTemplates.put(bd.getName(), tmpl);
            }

            ImageButton button = new ImageButton("sample", ButtonResource.getReference(),
                    ButtonResource.getValueMap(tmpl, bd.getName()));
            item.add(button);
            button.add(new AjaxFormSubmitBehavior(form, "onclick") {
                @Override
                protected void onError(AjaxRequestTarget arg0) {
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    m_selectedDescriptor = model.getObject();
                    m_currentProperties = m_selectedDescriptor.getProperties();
                    if (target != null) {
                        // target.addComponent(m_properties);
                    }
                    createButton(target);
                }

                @Override
                protected CharSequence getEventHandler() {
                    String hider = getJQueryCodeForPropertiesHiding(model.getObject());
                    return new AppendingStringBuffer(hider + ";" + super.getEventHandler())
                            .append("; return false;");
                }
            });

        }
    });

    m_properties = new TableImageBorder("propertiesborder", s_shadow, s_blocColor);
    layout.add(m_properties);
    m_properties.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true);
    m_currentProperties = m_selectedDescriptor.getProperties();

    m_propEditors = new ListView<ButtonDescriptor>("property", s_buttons) {
        @Override
        protected void populateItem(ListItem<ButtonDescriptor> item) {
            ButtonDescriptor desc = item.getModelObject();
            WebMarkupContainer container = new WebMarkupContainer("container");
            item.add(container);
            PropertyListEditor lst = new PropertyListEditor("lst", desc.getProperties());
            container.add(lst);
            container.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true);
            m_propertiesContainer.add(new Pair(desc.getName(), container));
        }
    };

    m_properties.add(m_propEditors);

    //      Border fontborder = new TableImageBorder("fontborder", s_shadow, s_blocColor);
    //      form.add(fontborder);
    //      fontborder.add(new ButtonPropertyEditorPanel("fontselector", PROPERTY_FONT, false));
    //      fontborder.add(new ButtonPropertyEditorPanel("fontcolor", PROPERTY_FONT_COLOR, false));
    //      fontborder.add(new ButtonPropertyEditorPanel("fontshadow", PROPERTY_FONT_SHADOW, true));

    rightcol.addContent(createFragment(ColumnPanel.CONTENT_ID,
            Arrays.asList(new Component[] { new ButtonPropertyEditorPanel("element", PROPERTY_WIDTH, true),
                    new ButtonPropertyEditorPanel("element", PROPERTY_HEIGHT, true),
                    new ButtonPropertyEditorPanel("element", PROPERTY_AUTO_EXTEND, true) }),
            "Button Size"));

    rightcol.addContent(createFragment(rightcol.CONTENT_ID,
            Arrays.asList(new Component[] { new ButtonPropertyEditorPanel("element", PROPERTY_FONT, false),
                    new ButtonPropertyEditorPanel("element", PROPERTY_FONT_COLOR, true),
                    new ButtonPropertyEditorPanel("element", PROPERTY_FONT_SHADOW, true) }),
            "Font Selection"));

    rightcol.addContent(createFragment(
            rightcol.CONTENT_ID, new EffectChoicePanel("element",
                    new PropertyModel<Integer>(this, "shadowEffect"), EffectUtils.getShadowEffects()),
            "Shadow Effect"));
    rightcol.addContent(createFragment(
            rightcol.CONTENT_ID, new EffectChoicePanel("element",
                    new PropertyModel<Integer>(this, "mirrorEffect"), EffectUtils.getMirrorEffects()),
            "Mirror Effect"));

    createButton(null);
}

From source file:net.kornr.swit.site.widget.AjaxImageRadio.java

License:Apache License

public AjaxImageRadio(String id, ResourceReference resourceReference, ValueMap resourceParameters, Form form,
        Radio radio) {// w w  w.  j a v a 2  s .c o m
    super(id, resourceReference, resourceParameters);

    radio.setOutputMarkupId(true);
    m_radioId = radio.getMarkupId();

    this.add(new AjaxFormSubmitBehavior(form, "onclick") {
        @Override
        protected void onError(AjaxRequestTarget arg0) {
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            AjaxImageRadio.this.onSubmit(target);
        }

        @Override
        protected CharSequence getEventHandler() {
            String seq = "$('#" + m_radioId + "').attr('checked',true);";
            return seq + super.getEventHandler();
        }
    });
}

From source file:net.unit8.longadeseo.page.plugin.PluginTestPage.java

License:Apache License

public PluginTestPage(final PluginRegistry pluginRegistry) {
    final Label testResult = new Label("testResult", "");
    testResult.setOutputMarkupId(true);//from  ww  w. j  a v a2 s .com
    add(testResult);
    add(new Label("pluginName", pluginRegistry.getName()));

    Form<ValueMap> uploadForm = new Form<ValueMap>("uploadForm");
    final FileUploadField fileUploadField = new FileUploadField("testFile");
    fileUploadField.add(new AjaxFormSubmitBehavior(uploadForm, "onchange") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            FileUpload file = fileUploadField.getFileUpload();
            Plugin plugin = pluginRegistry.getPlugin();
            MockDavResource resource = new MockDavResource(file.getClientFileName());
            StringWriter error = new StringWriter();
            try {
                plugin.init();
                plugin.beforeService(resource);
                plugin.afterService(resource, file.getInputStream());
            } catch (IOException e) {
                logger.error("???????", e);
            } catch (Exception e) {
                e.printStackTrace(new PrintWriter(error));
            } finally {
                file.delete();
            }
            testResult.setDefaultModelObject(error.toString());
            target.add(testResult);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            // TODO ???
        }
    });
    uploadForm.add(fileUploadField);
    add(uploadForm);
}

From source file:ontopoly.components.AjaxRadioGroupPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public AjaxRadioGroupPanel(String id, final Form<?> form, List choices, IModel model) {
    super(id);//  w  ww .  ja v  a  2  s.c  o  m
    final RadioGroup rg = new RadioGroup("radiochoicegroup", model);
    rg.setRenderBodyOnly(false);
    rg.add(new ListView("radiochoices", choices) {
        @Override
        protected void populateItem(ListItem item) {
            final Serializable radioitem = (Serializable) item.getModelObject();
            final Radio rc = new Radio("radiochoice", new Model(radioitem));
            // Must use AjaxFormSubmitBehavior for this type of component    
            rc.add(new AjaxFormSubmitBehavior(form, "onclick") {
                protected void onSubmit(AjaxRequestTarget target) {
                    if (target != null) {
                        int size = ajaxTargets.size();
                        for (int i = 0; i < size; i++) {
                            target.addComponent(ajaxTargets.get(i));
                        }
                    }
                }

                @Override
                protected void onError(AjaxRequestTarget target) {
                }
            });
            // Add label for radio button    
            String label = radioitem.toString();
            String display = label;
            if (localizeDisplayValues()) {
                display = getLocalizer().getString(label, this, label);
            }
            item.add(rc);
            item.add(new Label("radiolabel", display));
            item.add(new Label("suffix", getSuffix()).setRenderBodyOnly(true).setEscapeModelStrings(false));
        }
    });
    add(rg);
}

From source file:org.apache.openmeetings.web.admin.labels.LangPanel.java

License:Apache License

public LangPanel(String id) {
    super(id);//from  w  w  w .ja  va  2 s .  c o m

    // Create feedback panels
    add(feedback.setOutputMarkupId(true));
    language = new AbstractMap.SimpleEntry<Long, Locale>(1L, Locale.ENGLISH);

    final LabelsForm form = new LabelsForm("form", this, new StringLabel(null, null));
    form.showNewRecord();
    add(form);

    final SearchableDataView<StringLabel> dataView = new SearchableDataView<StringLabel>("langList",
            new SearchableDataProvider<StringLabel>(LabelDao.class) {
                private static final long serialVersionUID = 1L;

                @Override
                protected LabelDao getDao() {
                    return (LabelDao) super.getDao();
                }

                @Override
                public long size() {
                    return getDao().count(language.getValue(), search);
                }

                @Override
                public Iterator<? extends StringLabel> iterator(long first, long count) {
                    return getDao().get(language.getValue(), search, (int) first, (int) count, getSort())
                            .iterator();
                }
            }) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<StringLabel> item) {
            final StringLabel fv = item.getModelObject();
            item.add(new Label("key"));
            item.add(new Label("value"));
            item.add(new AjaxEventBehavior("click") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(fv);
                    form.hideNewRecord();
                    target.add(form, listContainer);
                    target.appendJavaScript("labelsInit();");
                }
            });
            item.add(AttributeModifier.append("class", getRowClass(fv.getId(), form.getModelObject().getId())));
        }
    };

    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            dataView.modelChanging();
            target.add(listContainer);
        }
    };
    DataViewContainer<StringLabel> container = new DataViewContainer<StringLabel>(listContainer, dataView,
            navigator);
    container.addLink(new OmOrderByBorder<StringLabel>("orderByName", "key", container))
            .addLink(new OmOrderByBorder<StringLabel>("orderByValue", "value", container));
    add(container.getLinks());
    add(navigator);
    langForm = new LangForm("langForm", listContainer, this);
    fileUploadField = new FileUploadField("fileInput");
    langForm.add(fileUploadField);
    langForm.add(new UploadProgressBar("progress", langForm, fileUploadField));
    fileUploadField.add(new AjaxFormSubmitBehavior(langForm, "change") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            FileUpload download = fileUploadField.getFileUpload();
            try {
                if (download == null || download.getInputStream() == null) {
                    feedback.error("File is empty");
                    return;
                }
                LabelDao.upload(language.getValue(), download.getInputStream());
            } catch (Exception e) {
                log.error("Exception on panel language editor import ", e);
                feedback.error(e);
            }

            // repaint the feedback panel so that it is hidden
            target.add(listContainer, feedback);
        }
    });

    // Add a component to download a file without page refresh
    final AjaxDownload download = new AjaxDownload();
    langForm.add(download);

    langForm.add(new AjaxButton("export") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            final String name = LabelDao.getLabelFileName(language.getValue());
            download.setFileName(name);
            download.setResourceStream(new AbstractResourceStream() {
                private static final long serialVersionUID = 1L;
                private transient InputStream is;

                @Override
                public InputStream getInputStream() throws ResourceStreamNotFoundException {
                    try {
                        is = Application.class.getResourceAsStream(name);
                        return is;
                    } catch (Exception e) {
                        throw new ResourceStreamNotFoundException(e);
                    }
                }

                @Override
                public void close() throws IOException {
                    if (is != null) {
                        is.close();
                        is = null;
                    }
                }
            });
            download.initiate(target);

            // repaint the feedback panel so that it is hidden
            target.add(feedback);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            // repaint the feedback panel so errors are shown
            target.add(feedback);
        }

    });

    add(langForm);
    final AddLanguageDialog addLang = new AddLanguageDialog("addLang", this);
    add(addLang, new AjaxLink<Void>("addLangBtn") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addLang.open(target);
        }
    });
    add(BootstrapFileUploadBehavior.INSTANCE);
}

From source file:org.apache.openmeetings.web.common.UploadableImagePanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    form.setMultiPart(true);//w ww  .  jav  a  2  s . c  om
    form.setMaxSize(Bytes.bytes(getMaxUploadSize()));
    // Model is necessary here to avoid writing image to the User object
    form.add(fileUploadField);
    form.add(new UploadProgressBar("progress", form, fileUploadField));
    form.addOrReplace(getImage());
    if (delayed) {
        add(new WebMarkupContainer("remove").add(AttributeModifier.append("onclick",
                "$(this).parent().find('.fileinput').fileinput('clear');")));
    } else {
        add(new ConfirmableAjaxBorder("remove", getString("80"), getString("833")) {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onSubmit(AjaxRequestTarget target) {
                try {
                    deleteImage();
                } catch (Exception e) {
                    log.error("Error", e);
                }
                update(Optional.of(target));
            }
        });
        fileUploadField.add(new AjaxFormSubmitBehavior(form, "change") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onSubmit(AjaxRequestTarget target) {
                process(Optional.of(target));
            }
        });
    }
    add(form.setOutputMarkupId(true));
    add(BootstrapFileUploadBehavior.INSTANCE);
}

From source file:org.apache.openmeetings.web.common.UploadableProfileImagePanel.java

License:Apache License

public UploadableProfileImagePanel(String id, final long userId) {
    super(id, userId);
    final Form<Void> form = new Form<Void>("form");
    form.setMultiPart(true);/*from   ww w .j  a  va2s.  c  o  m*/
    form.setMaxSize(Bytes.bytes(getBean(ConfigurationDao.class).getMaxUploadSize()));
    // Model is necessary here to avoid writing image to the User object
    form.add(fileUploadField = new FileUploadField("image", new IModel<List<FileUpload>>() {
        private static final long serialVersionUID = 1L;

        //FIXME this need to be eliminated
        @Override
        public void detach() {
        }

        @Override
        public void setObject(List<FileUpload> object) {
        }

        @Override
        public List<FileUpload> getObject() {
            return null;
        }
    }));
    form.add(new UploadProgressBar("progress", form, fileUploadField));
    fileUploadField.add(new AjaxFormSubmitBehavior(form, "change") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            FileUpload fu = fileUploadField.getFileUpload();
            if (fu != null) {
                StoredFile sf = new StoredFile(fu.getClientFileName());
                if (sf.isImage()) {
                    boolean asIs = sf.isAsIs();
                    try {
                        //FIXME need to work with InputStream !!!
                        getBean(GenerateImage.class).convertImageUserProfile(fu.writeToTempFile(), userId,
                                asIs);
                    } catch (Exception e) {
                        // TODO display error
                        log.error("Error", e);
                    }
                } else {
                    //TODO display error
                }
            }
            update();
            target.add(profile, form);
        }
    });
    add(form.setOutputMarkupId(true));
    add(BootstrapFileUploadBehavior.INSTANCE);
}