[ 
https://issues.apache.org/jira/browse/WICKET-6002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14962273#comment-14962273
 ] 

Martin Grigorov commented on WICKET-6002:
-----------------------------------------

The app starts fine now.
But in ChainCode page there are neither 'Load Biasa' nor 'Load 3' 
labels/buttons.

Selecting a file in the file upload, a radio button and entering some text in 
the text field leads to these INFOs:

2015-10-18 12:32:20.249  INFO 348 --- [nio-8080-exec-9] 
i.a.i.s.p.web.ChainCodePage              : mode: BLACK_ON_WHITE 
2015-10-18 12:32:20.249  INFO 348 --- [nio-8080-exec-9] 
i.a.i.s.p.web.ChainCodePage              : Message: jji 
2015-10-18 12:32:20.249  INFO 348 --- [nio-8080-exec-9] 
i.a.i.s.p.web.ChainCodePage              : Loaded file 20150221_102929.jpg 
(image/jpeg)
2015-10-18 12:32:41.295  INFO 348 --- [nio-8080-exec-9] 
i.a.i.s.pengenalanpola.ChainCodeService  : Processing input image image/jpeg: 
1267512 bytes ...
2015-10-18 12:32:41.470  INFO 348 --- [nio-8080-exec-9] 
i.a.i.s.pengenalanpola.ChainCodeService  : Image mat: rows=1836 cols=3264 
depth=0 type=16
2015-10-18 12:32:41.702  INFO 348 --- [nio-8080-exec-9] 
i.a.i.s.p.ChainCodeWhiteConverter        : ukuran gambar rows=1836 cols=3264 
type=0 depth=0

I've copied 
{code}
info("Loaded file " + first.getClientFileName() + " (" + first.getContentType() 
+ ")");
{code}

to 
{code}
log.info("Loaded file " + first.getClientFileName() + " (" + 
first.getContentType() + ")");
{code}
and put it before the call to 
"chainCodeService.loadInput(first.getContentType(), first.getBytes(), mode)"

So everything looks OK until here. Wicker property updates the model objects. 
You can verify this by setting a breakpoint at FormComponent#updateModel().

But right after that the app breaks with:

Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:653)
        at java.util.ArrayList.get(ArrayList.java:429)
        at 
id.ac.itb.sigit.pengenalanpola.RelKodeBelok.penyederhanaanKodeBelok(RelKodeBelok.java:34)
        at 
id.ac.itb.sigit.pengenalanpola.RelKodeBelok.<init>(RelKodeBelok.java:16)
        at 
id.ac.itb.sigit.pengenalanpola.ChainCodeWhiteConverter.getChainCode(ChainCodeWhiteConverter.java:67)
        at 
id.ac.itb.sigit.pengenalanpola.ChainCodeService.processChainCode(ChainCodeService.java:80)
        at 
id.ac.itb.sigit.pengenalanpola.ChainCodeService.loadInput(ChainCodeService.java:58)
        at 
id.ac.itb.sigit.pengenalanpola.ChainCodeService.loadInput(ChainCodeService.java:50)
        at 
WICKET_id.ac.itb.sigit.pengenalanpola.ChainCodeService$$FastClassByCGLIB$$aa228630.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at 
org.apache.wicket.proxy.LazyInitProxyFactory$AbstractCGLibInterceptor.intercept(LazyInitProxyFactory.java:350)
        at 
WICKET_id.ac.itb.sigit.pengenalanpola.ChainCodeService$$EnhancerByCGLIB$$e75ed40d.loadInput(<generated>)
        at 
id.ac.itb.sigit.pengenalanpola.web.ChainCodePage$4.onSubmit(ChainCodePage.java:132)
        at 
org.apache.wicket.ajax.markup.html.form.AjaxButton$1.onSubmit(AjaxButton.java:113)
        at 
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior$AjaxFormSubmitter.onSubmit(AjaxFormSubmitBehavior.java:215)
        at 
org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1307)
        at org.apache.wicket.markup.html.form.Form.process(Form.java:974)

For me everything looks fine.

> FileUploadField makes form-component models become null on submit
> -----------------------------------------------------------------
>
>                 Key: WICKET-6002
>                 URL: https://issues.apache.org/jira/browse/WICKET-6002
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.0.0
>         Environment: Spring Boot 1.2.6, wicket-bootstrap 0.10.3, Tomcat 8
>            Reporter: Hendy Irawan
>            Assignee: Martin Grigorov
>
> First form: (not working)
> {code:java}
>         final Form<Void> form = new Form<>("form");
>         final ListModel<FileUpload> filesModel = new ListModel<>();
>         final FileUploadField fileFld = new FileUploadField("fileFld", 
> filesModel);
>         form.add(fileFld);
>         final Model<GrayscaleMode> modeImageModel = new 
> Model<>(GrayscaleMode.WHITE_ON_BLACK);
>         final RadioChoice<GrayscaleMode> modeImage = new 
> RadioChoice<>("modeImage",
>                 modeImageModel, ImmutableList.copyOf(GrayscaleMode.values()));
>         form.add(modeImage);
>         form.add(new AjaxButton("loadBtn2") {
>             @Override
>             protected void onAfterSubmit(AjaxRequestTarget target, Form<?> 
> form) {
>                 super.onAfterSubmit(target, form);
>                 log.info("modeimageModel: {}", modeImageModel.getObject());
>             }
>         });
>         add(form);
> {code}
> Second form: exactly same as above, but remove the fileUploadField.
> {code:java}
> final Form<Void> form2 = new Form<>("form2");
> final Model<GrayscaleMode> modeImage2Model = new 
> Model<>(GrayscaleMode.WHITE_ON_BLACK);
> final RadioChoice<GrayscaleMode> modeImage2 = new RadioChoice<>("modeImage2",
>         modeImage2Model, ImmutableList.copyOf(GrayscaleMode.values()));
> form2.add(modeImage2);
> form2.add(new AjaxButton("loadBtn3") {
>     @Override
>     protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
>         super.onAfterSubmit(target, form);
>         log.info("modeimageModel: {}", modeImage2Model.getObject());
>     }
> });
> add(form2);
> {code}
> Markup:
> {code}
> <form class="col-md-3" wicket:id="form">
>     <p><strong>Original</strong></p>
>     <div>
>         <input type="file" wicket:id="fileFld" accept="image/*"/>
>         <p>
>             <label>Mode</label>:
>             <span wicket:id="modeImage"></span>
>         </p>
>         <button class="button" wicket:id="loadBtn2">Load Biasa</button>
>     </div>
> </form>
> <form class="col-md-3" wicket:id="form2">
>     <p><strong>Original</strong></p>
>     <div>
>         <p>
>             <label>Mode</label>:
>             <span wicket:id="modeImage2"></span>
>         </p>
>         <button class="button" wicket:id="loadBtn3">Load 3</button>
>     </div>
> </form>
> {code}
> With the non-working form, the request is multipart. This seems to cause all 
> form components' model.getObject() become null.
> {noformat}
> POST 
> /chaincode?0-1.IBehaviorListener.0-form-loadBtn2&wicket-ajax=true&wicket-ajax-baseurl=chaincode%3F0
>  HTTP/1.1
> Host: localhost:8080
> Connection: keep-alive
> Content-Length: 576
> Cache-Control: max-age=0
> Accept: 
> text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
> Origin: http://localhost:8080
> Upgrade-Insecure-Requests: 1
> User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 
> (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
> Content-Type: multipart/form-data; 
> boundary=----WebKitFormBoundaryv78rJ8mvP8YbHtBy
> Referer: http://localhost:8080/chaincode?0
> Accept-Encoding: gzip, deflate
> Accept-Language: id,en-US;q=0.8,en;q=0.6,ms;q=0.4
> Cookie: JSESSIONID=746B6931A8791427E02FCE5C1D20F1B7
> ------WebKitFormBoundaryv78rJ8mvP8YbHtBy
> Content-Disposition: form-data; name="form3_hf_0"
> ------WebKitFormBoundaryv78rJ8mvP8YbHtBy
> Content-Disposition: form-data; name="fileFld"; filename=""
> Content-Type: application/octet-stream
> ------WebKitFormBoundaryv78rJ8mvP8YbHtBy
> Content-Disposition: form-data; name="modeImage"
> 0
> ------WebKitFormBoundaryv78rJ8mvP8YbHtBy
> Content-Disposition: form-data; name="msgImage"
> ------WebKitFormBoundaryv78rJ8mvP8YbHtBy
> Content-Disposition: form-data; name="loadBtn2"
> 1
> ------WebKitFormBoundaryv78rJ8mvP8YbHtBy--
> {noformat}
> With the working form, the request is urlencoded form:
> {noformat}
> POST /chaincode?0-1.IBehaviorListener.0-form2-loadBtn3 HTTP/1.1
> Host: localhost:8080
> Connection: keep-alive
> Content-Length: 36
> Origin: http://localhost:8080
> Wicket-FocusedElementId: loadBtn32
> User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 
> (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
> Accept: application/xml, text/xml, */*; q=0.01
> X-Requested-With: XMLHttpRequest
> Wicket-Ajax: true
> Wicket-Ajax-BaseURL: chaincode?0
> Referer: http://localhost:8080/chaincode?0
> Accept-Encoding: gzip, deflate
> Accept-Language: id,en-US;q=0.8,en;q=0.6,ms;q=0.4
> Cookie: JSESSIONID=746B6931A8791427E02FCE5C1D20F1B7
> form21_hf_0=&modeImage2=0&loadBtn3=1
> {noformat}
> "Probably" related with WICKET-5924, but I don't have issue with 
> FileUploadField, my issue is with other form components in the same form as 
> FileUploadField. Probably related to: 
> http://stackoverflow.com/questions/28784942/fileupload-field-wicket-error
> *Test case:*
> {code}
> git clone https://github.com/tmdgitb/pengenalan_pola_shih.git -t WICKET-6002
> {code}
> 1. Run {{DaemonApp}}
> 2. Go to "ChainCode" page 
> 3. click "Load Biasa" on the left, you'll see "modeimageModel: null". --> not 
> working: using FileUploadField + multipart
> 4. click "Load 3" on the right, you'll see "modeimageModel: WHITE_ON_BLACK" 
> --> works: using urlencoded



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to