I use this home brew Behavior: import java.io.File;
import org.apache.wicket.Component; import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.OnDomReadyHeaderItem; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.http.WebRequest; import org.apache.wicket.util.string.StringValue; public abstract class FileSelectedBehavior extends AbstractDefaultAjaxBehavior { public static final String FILE_SELECTED_REQUEST_PARAMETER_NAME = "val"; @Override public void respond( AjaxRequestTarget target ) { // get the web request RequestCycle cycle = RequestCycle.get(); WebRequest webRequest = (WebRequest) cycle.getRequest(); // get the parameter StringValue term = webRequest.getQueryParameters().getParameterValue( FILE_SELECTED_REQUEST_PARAMETER_NAME ); // term contains full (fake) path File file = new File( term.toString() ); // process the parameter this.processRequest( target, file.getName() ); } /** * This method will be called when a file is selected. * * @param target * @param fileName will contain the filename with extension (without path) */ public abstract void processRequest( AjaxRequestTarget target, String fileName ); @Override public void renderHead( Component component, IHeaderResponse response ) { // after selecting a file the onRequest of this class is called String script = "document.getElementById('" + component.getMarkupId() + "').onchange = function () { Wicket.Ajax.get({ 'u' : \"" + this.getCallbackUrl() + "\", 'ep' : {'" + FILE_SELECTED_REQUEST_PARAMETER_NAME + "' : this.value } });};"; // add the javascript response.render( OnDomReadyHeaderItem.forScript( script ) ); } } On Thu, Aug 24, 2017 at 9:57 AM, lucast <lucastol...@hotmail.com> wrote: > I had the same requirement,I wanted to display the contents of the file, > once > the file has been selected. > I found the code on > https://github.com/apache/openmeetings/blob/4a5e859f886253086e51a2ac26bbc5 > 01d621e590/openmeetings-web/src/main/java/org/apache/ > openmeetings/web/common/UploadableImagePanel.java > <https://github.com/apache/openmeetings/blob/ > 4a5e859f886253086e51a2ac26bbc501d621e590/openmeetings-web/ > src/main/java/org/apache/openmeetings/web/common/UploadableImagePanel.java > > > , line 77, new AjaxFormSubmitBehavior(form, "change") to be extremely > helpful and just what I was looking for. > > > > > -- > View this message in context: http://apache-wicket.1842946. > n4.nabble.com/FileUploadField-with-AJAX-Behavior-tp4677874p4678594.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >