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 <[email protected]>:
> 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
>
>>
>> On Wed, Sep 16, 2009 at 11:32 PM, Martin Makundi <
>> [email protected]> wrote:
>>
>>> 1. You know how to upload file?
>>> http://www.wicket-library.com/wicket-examples/upload/single
>>> -> or ajax upload
>>>
>>> http://blog.demay-fr.net/index.php/2007/12/07/93-simulate-ajax-file-upload-with-wicket
>>>
>>> 2. Just put the file contents into textarea with jafa reflection.
>>>
>>> 3. AJax update the textarea:
>>> http://www.wicket-library.com/wicket-examples/ajax/clock.2
>>> -> This is timed update..but similarly just add the textarea into ajax
>>> target.
>>>
>>> **
>>> Martin
>>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]