I'd rather use some other method than mine, because with mine the validation of input is done twice when uploading. first on the uploaded file, and then another time on the textarea when pressing the wizard's next button.
I tried replacing my "fixup" with this one but got a big fat java.lang.NoSuchFieldException on getDeclaredField( name) line in the code. I got this a couple of times using different names such as TextArea.class.getSimpleName() and "serials" (the wicket id for the textarea). Any ideas on what name I should be using? heres some code and the markup for the wizard page with the upload form/textarea : <wicket:panel> <table> <tr> <td> <form wicket:id="simpleUpload"> <fieldset> <label for="upload">File</label> <input wicket:id="fileInput" id="upload" type="file" /> <button wicket:id="uploadButton" ><span wicket:id="uploadLabel">upload</span></button> </fieldset> </form> </td> <td> <wicket:message key="serials.textareaInfo">info message</wicket:message> <br/> <textarea wicket:id="serials"></textarea> </td> </tr> </table> i'm using <button wicket:id="uploadButton" > in the markup instead of <input type="submit"> as per the example because pressing the latter button causes the whole wizard page to validate, including the text area which is usualy empty in the case of file upload. Button uploadButton = new Button("uploadButton") { @Override public void onSubmit() { final FileUpload upload = fileUploadField.getFileUpload(); if (upload != null) { String uploadedContent = new String(upload.getBytes()); try { Field f = FormComponent.class.getDeclaredField(TextArea.class.getSimpleName()); f.setAccessible(true); f.set(textArea, uploadedContent); } catch (Exception e) { e.printStackTrace(); } } } } On Thu, Sep 17, 2009 at 12:29 AM, Martin Makundi < martin.maku...@koodaripalvelut.com> wrote: > Ah.. forgot that crucial part, the reflection: > > public static <T extends FormComponent<?>> void fakeRawInput(T > formComponent, String value) { > try { > rawInputField.set(formComponent, value); > } catch (Exception e) { > Utils.errorLog(MarkupUtils.class, "Fatal Error: Form field > access failed.", e); > } > } > > where > rawInputField = FormComponent.class.getDeclaredField("rawInput"); > rawInputField.setAccessible(true); > > > 2009/9/17 Martin Makundi <martin.maku...@koodaripalvelut.com>: > > Hi! > > > >> I currently solved this problem by "filtering" the input from the > uploaded > >> file and creating a correct object model (Set<String>) out of it, > >> then setting the modelObject of the textarea to be this filtered one. > > > > Good, so you got the upload part working. > > > > By reflection I mean that instead of setting model object you could do > > this, if necessary: > > > > public static <T extends FormComponent<?>> void fakeRawInput(T > > formComponent, T existingComponent) { > > try { > > String rawInput = (String) rawInputField.get(existingComponent); > > fakeRawInput(formComponent, rawInput); > > } catch (Exception e) { > > Utils.errorLog(MarkupUtils.class, "Fatal Error: Form field > > access failed.", e); > > } > > } > > > > In this way your modelObject state does not change as compared to: > > > >> simply using setModelObject( (Set<String>) uploadedContent) ? > > > > But if you can change the model that's definitely cleaner. > > > > ** > > Martin > > >