Java Wicket - Prevent Form From Creating New Tab When Exception Occurs -


i creating reports using jasper right , goes well. set in way if user preview report, report(pdf) shown on new tab. problem if error occurs, new tab still opened instead of showing feedback panel on original page.

how can form setup in such way feedback panel shown on original page instead of newly opened tab?

form<?> form = new form<void>("form"); form.add(new attributeappender("target", model.of("_blank")));  submitlink view= new submitlink("view") {     @override     public void onsubmit() {         //code inside try-catch generate report using jasper} };      cptidownloadbutton download = new cptidownloadbutton("download", new abstractreadonlymodel<file>(){  //cptidownloadbutton extends submitlink button , modification of mr ivaynberg's downloadlink };   <form wicket:id="form">     <a href="#" wicket:id="submit"><input type="button" wicket:message="value:search"/></a>     <a href="#" wicket:id="download"><input type="button"  wicket:message="value:download"/></a> </form> 

thanks in advance who'll answer. ^^

if form submission form target="_blank", browser automatically open new tab render response form submission. intended behavior, , trying prevent breaking standard target="_blank" behavior. guess i'm saying should think whether breaking standard behavior want do.

if is, here's how go it. warning: ain't gonna clean.

use ajax (ajaxbutton or ajaxformsubmitbehavior) submit form. since done via ajax, browser not invoke default form submission behavior, hence not opening new tab.

ajax invokes form processing. on error, re-render feedback panel , return. on success append javascript invoke default form submission on respective link when request returns. perform standard form submission behavior, hence performing target="_blank". once more validate form, proceed perform intended behavior.

the way invoke default form submission on link desire can done in few different ways , entirely you. quick , dirty way can hide buttons have right (visually) , perform javascript click button. or can use hidden form field identify button has been clicked if don't want ugly hidden clicking behavior.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -