Java Reference
In-Depth Information
newsBrief.getEngine().loadContent(content);
// write to disk if not already.
DBUtils.saveRssFeed(rssFeed);
As in the previous recipes, you will be responding to HTML WebEvent s when the
new headline View button is pressed, which calls a JavaScript's alert() function.
The following code snippet handles a web event ( WebEvent ) containing the URL that
links to the entire article viewed in the lower-right region:
newsBrief.getEngine().setOnAlert((WebEvent<String> evt)
-> {
websiteView.getEngine().load(evt.getData());
}); // end of newsBrief setOnAlert()
When creating the headlines region (upper right), which contains the HTML but-
tons to render the article's web page, notice the alert() function containing the URL
to be loaded and rendered in the lower split frame region. The following code is an ex-
ample of the HTML generated for an headline news containing a View button that can
notify the web engine's OnAlert web event ( WebEvent ).
<input type="button"
onclick="alert('http://carlfx.wordpress.com/2009/08/03/
javafx-forms-framework-part-2/')" value="View" />
One last thing to point out is that the RSS application is missing some features. One
feature that comes to mind is the ability to delete individual RSS hyperlinks from the
left column region. A workaround is to remove all links by deleting the database on the
file system. Because Derby is an embedded database, you can delete the directory con-
taining the database. The JavaFX RSS application will re-create an empty database if
one doesn't exist. Hopefully, you can add new features to enhance this fun and useful
application.
Summary
JavaFX works well within the context of web applications. In this chapter, we looked
at a few different ways to combine the realm of web applications and client applica-
tions with the convergence of HTML and JavaFX. JavaFX 8 has been tailored for easy
Search WWH ::




Custom Search