Clearing current WebView Content and reloading a different content in JavaFX -
i have webview displays html page, maingraph.html, , execute javascript function "false" parameter. on clicking 1 of menuitems, want same javascript function called "true" parameter.
when menuitem selected, there 2 outputs of same javascript instead of latest 1 replacing older one.
analysiscontroller.java
public class analysiscontroller implements initializable { public void displaymaingraph(webengine wemaingraph, boolean pblnfisheyelens) { system.out.println("analysiscontroller.displaymaingraph(): called"); string strdatafile = strcurrentinputfile + ".json"; final url urlloadmaingraph = getclass().getresource("html/maingraph.html"); wemaingraph.getloadworker().stateproperty().addlistener((ov, oldstate, newstate) -> { if (newstate == state.succeeded) { wemaingraph.executescript(" doeverything(' "+strdatafile+" ', "+pblnfisheyelens+") "); } }); wemaingraph.load(urlloadmaingraph.toexternalform()); } }
and menuitemsfisheyelens.java place invoking function based on menuitem click.
public class menuitemfisheyelens extends welcomemenubar.menuitemgeneric implements imenuitem{ public menuitemfisheyelens(string pstrmenuitemdisplay, string pstrmenuitemclass, string pstrmenuitemiconpath) { super(pstrmenuitemdisplay, pstrmenuitemclass, pstrmenuitemiconpath); } @override public void click(tabpane ptabpane, analysiscontroller pcontroller, boolean pblnselected) { string strcallingmethod = "analysismenubar.menuitemfisheyelens.click(): "; pcontroller.displaymaingraph(pcontroller.getcurrentwebengine(), pblnselected); system.out.println(strcallingmethod+"end"); } }
when menuitem clicked, output shows 2 same graphs, first 1 pblnfisheyelens value = false , second 1 true. output
welcomemenubar.menuitemopen.click(): end thi called parameter: false analysiscontroller.displaymaingraph(): called displaymaingraph(): test1.meerkat fisheyelens parameter: true analysismenubar.menuitemfisheyelens.click(): end thi called parameter: false thi called parameter: true
Comments
Post a Comment