Posts

MySQL – “Your password has expired. To log in you must change it using a client that supports expired passwords”

What a hugely frustrating problem, to one day try to connect to your local MySQL instance only to find the password expired. I guess if it wasn’t my local instance it may not be such a bad thing from a security perspective but anyway…

After trying a number of things this one worked for me on Windows 7, MySQL version 5.7.

(1) Shutdown the MySQL service instance (Windows -> Run then type services.msc, right-click MySQL57 and stop)

(2) Open the “MySQL 5.7 Command Line Client” (Windows -> Run then type MySQL, it will appear in the list)

Diving Straight into TypeScript and PouchDB

Add PouchDB to your application

Deploy a fat jar to OpenShift… Hmmmmm

A NinjaFramework application is built and deployed as a fat jar by default. Given this fact, I popped this question on StackOverflow. I figured that one would need to be some kind of Maven guru in order to build some kind of configuration to deploy it on OpenShift. Not so as it turns out. The guys at NinjaFramework have once again come up trumps. It turns out the process is effortless. This blog describes the steps involved from beginning to end. This process uses Netbeans.

Introduction

The following details how JQuery-Mobile and AngularJS can play together seamlessly. Angular-Route (ngRoute) is used for navigation. A simple Angular directive invokes JQuery-Mobile styling and enhancements as each page is loaded. This includes pages loaded via
ng-include

The previous blogs led up to situation where the user is able to authenticate with Facebook thus receiving a Facebook authentication token. Authentication with Facebook results in a request being sent to our REST service. The intent of that request is to authenticate with our Rest service. The request contains the Facebook authentication token and the users Facebook email address (from their Facebook profile). The Rest Service will receive the Facebook authentication token from the client, it then invokes Facebook itself using RestFB to retrieve the users profile. The email address received from the client is now compared with the email address taken from the Facebook profile just retrieved via RestFB.

If the email addresses match, the user is authentic. (Now the REST service generates a token for the client which identifies that client. Any time the client wants to invoke the service, it supplies that token).

If the email addresses do not match, the client supplied a valid Facebook authentication token but for a different account; reject this user.

If the profile cannot be retrieved, the client may have supplied an invalid Facebook authentication token; reject this user.

If the email addresses match, the user is authentic. At this point in the previous blog, the server just responds to the client with an email address, i.e. the matched email address. The client stores this and passes it to the service in a request-header on each request. Our REST service will use this each time to extract the user from persistence.

There are a couple of problems with this approach.

The email address in transit is exposed unless HTTPS is used. HTTPS should be used so this is not such a big issue.

The email address alone may not be sufficient information. Date/Time issued or Date/Time expires may be of use so that the token can be expired after a defined idle period.

Data other than the email address may be required, i.e. a bunch of key-value pairs.

Introduction

The JavaScript AJAX call is described in terms of request headers and request data formatting.

Spring uses Jackson for JSON parsing. Jackson is configured to ignore extra JSON properties that do not match properties of the bean being populated at the @Controller request end-point method.

This blog demonstrates populating complex objects n levels deep thus overcoming some difficulties encountered as per many of the comments in this blog.

Unlike Spring 3 MVC – Adding Objects to a List element on the fly at form submit – (Generic method) a generic JavaScript library is not provided. Populating JSON objects is easily achieved with JavaScript. For that reason, the difficulties of the HTML form implementation described (and partially solved) in that blog do not arise in the first place. Therefore it is hugely favorable to use JSON over conventional HTML forms for complex objects (and in general).

This demonstration conforms to a useful and popular design pattern. Specifically, the form is submitted asynchronously, the response is handled by the client JavaScript.

This provides for:

A far better user experience as there is no page load. Feedback is immediate.

Introduction

This post will detail how to AngularJS can enhance the usage and functionality of Radio Buttons.

Three scenarios are covered.

Each radio button represents an object. For example, there may be a radio button for each element of an array. When one of the radio buttons is selected, a variable is assigned the corresponding array element. So, a variable called $scope.selectedPerson can be automatically assigned to the selected ‘person’ in an array of ‘person’ objects.

Similar to ‘1’ except instead of selecting a complete object, it’s possible to select just a property of an object. E.g. instead of $scope.selectedPerson, the variable can be $scope.selectedPersonName. This is a simple elaboration on the first scenario purely for emphasis.

This scenario is considerably different. Take elements being added to an array dynamically through a UI, the user adding the elements needs to assign one of them as the default element. This is achieved by setting a property (isDefault = true for example) in the array element object. The other array elements have their isDefault property set to false. Unlike the previous two examples, an external variable is not being set, the elements of the array themselves are being manipulated.

Introduction

This blog will explore the concept of passing object to angularJS directives / templates using by reference.
When an object is passed by reference both the parent (controller or parent directive) and the child directive/template have access to the object. The relationship is bidirectional.

This tutorial details creating directive/templates in general (without an isolated scope).
This tutorial demonstrates passing values by value to angular directives/templates (@).

This blog will go through the steps required to setup a basic Spring 4 MVC web application using Netbeans and Maven. The Spring 4 project will be configured using annotations and plain Java rather than XML.

It is a step by step guide to getting up and running quickly. There are plenty alternative methods to doing this but this one is simple, lightweight and to the point. A maven project is available for download at the end of this blog.

The purpose of this blog is to demonstrate how to use templates in AngularJS. A fully worked example is provided via jsFiddle. The example is simple and easy to follow. A detailed but succinct explanation of the code is provided.

The template is “complex html” that we’ll want to reuse. The directive will allow this complex html to be delivered anywhere without code duplication. This obviously has advantages in terms of code reuse and maintainability.