Monthly Archives: December 2015

Always use email as username

Don’t let your user input a "username" while registering.   It’s totally unnecessary.  And it can be awkward when user logins with an Open ID, such as Google or Facebook.  What will be the user name in this case?  If a user registers on your site, just use their email as username.  It will make […]

How to enable log4j when doing spring-based integration test?

Just put a log4j.xml on test’s class path and log4j will be activated. However, you may hate to have 2 "log4j.xml" in your eclipse. You want the log4j config for testing to be called log4j-test.xml. In that case, do the following: //create your own runner, withen which load log4j public class MySpringJunit4ClassRunner extends SpringJUnit4ClassRunner { […]

Design for Error Response in Web Services

The server side should send error code and error message.  Is that all?  Yes, basically it will work, but not perfect yet. What you need to do: 1. Differentiate known, user-readable errors from unknown, developer-readable errors.   2. Send an error ID to client side when there is an unknown error, with which the client […]

JavaFX: how to let one FXML include another

How to let one fxml include another, e.g. let every scene has a "header" ? Note you have to set "fx:id=…" There must be a controller for the included fxml file. Let’s call it HeaderController public class HeaderController { @FXML private Text errorText; … Include the HeaderController in your controller public class LoginController { //the […]