Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Monday, March 27, 2017

Kotlin Elements in TorandoFX Type Safe Builders

While the Kotlin-based TornadoFX framework supports many styles to construct a JavaFX UI, the Type Safe Builders are preferred.  Borrowing from a popular Groovy syntax, the TornadoFX Type Safe Builders are Kotlin Extension Functions that use Lambdas to write cleaner programs.

This is an example TornadoFX View which is an HBox containing three Labels.

class GridDemosMainView : View() {

    override val root = hbox {

        label("Label 1")
        label("Label 2")
        label("Label 3")

Monday, January 16, 2017

C# WebClient Parsing JSON Array

This is a snippet of code that calls a RESTful web service and parses the JSON result.  The JSON payload is a list of objects.  The solution uses the .NET class DataContractJsonSerializer and an annotated DataContract.

Saturday, December 3, 2016

Kotlin Callable Reference Notes

Method references were added to Java 8 and you may already be using the double-colon (::) syntax to use a method reference as a parameter.  The semantics in Kotlin are different although a change in 1.1 will address these differences.

This article presents a few examples of passing function references in Kotlin 1.0.

Sunday, November 6, 2016

Securing JavaFX Content Based on Role

This is an example where a MainView contains two child views, AllAccessView and AdminOnlyView.  All of the views are in .fxml and AllAccessView and AdminOnlyView are fx:included in MainView.

A setRole() method is provided by MainViewController.  This method sets an internal field which is tied to a ChangeListener.  The ChangeListener will decide, based on role, whether or not to show both views (for Admin) or just one (for User).

The fx:include code is wrapped up in Boxes to make the adding and removing easier.

I'll expand upon this later.

The code will explain things better.

SecuredApp Source

Monday, October 24, 2016

Disambiguiating Nil Arguments in Swift

Overloading functions in Swift enables you to use the same function name with arguments of different types.  This can lead to an easier-to-use API, especially with code completion.  Instead of having a complement of functions like

  saveAnotherClass(anotherclass), and

you'd just use a single save() function that would accept the three different types.  The previous example becomes

  save(anotherclass), and