BCS JavaFX Scene Builder

The Scene Builder allows the user to create Java FX scenes in an automated fashion.  To add java object to the Scene Builder click on the option control next to the Library control identifier and the following drop down will appear.

When you click on the option the following dialog will appear.

Click on the Add Library FXML from file system.

The scene builder is available from Eclipse in both the Windows and Ubuntu versions. It appears as a pop up option when it is successfully configured.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

BCS Java

amb01Java programming language was employed to develop many computer applications.  Applications developed are stand alone as well as web based.

Grails is employed using Groovy programming language as well as other technologies to deliver rich internet applications via the Java Virtual Machine (JVM).

To read more about Java as a programming language click here.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

BCS Eclipse Mars IDE

Well folks Eclipse has done it again. The newest release Mars is available. I have used Mars for the first three milestones and I could not be more pleased. I initially downloaded the Eclipse Mars M3 Packages beginning with the IDE for Java EE Developers. The initial install can be located at the link below.

Of course I install the 64 bit version of Eclipse. To make the spelling checker function properly make sure the JDT plugin is installed. The Eclipse Java Development Tools houses the engine for the spell checker.

Install Grails and the associated servers via the Eclipse Marketplace. Be sure to use the latest version. This option give you a nice Java development stack.

Be sure to install the PHP Development Tool (PDT). This feature allows me to program all things PHP like WordPress, Yii, CodeIgniter and other PHP applications.

The tool plugin continue with installing c++, Ruby, Tcl/Tk and Python to round out the development stack.

Since this is the 64bit stack the FlashBuilder plugin will not function properly in a 64 bit stack. A separate 32 bit stack of Eclipse is used to support FlashBuilder.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

BCS Flash Builder 4.5 Execute URL Routine

There are those occasions when our flex application will need to interface with existing sites on the world wide web.  To invoke a URL in flash builder is slightly different than any other programming scenario I have used.

I have written a small routing that handles URL requests.  The code is as follows”

protected function XQTCmd(cmd : String): void
				var urlReq:URLRequest = new URLRequest(cmd);
				navigateToURL(urlReq, "_blank");

Place the routine in the root MXML and invoke the routine by using a coded statement indicated below.

protected function ABWBtn_clickHandler(event:MouseEvent):void

This code can be initiated from any event available to the MXML application.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems authored this article.

BCS STS Grails Authentication

Invoke the SpringSource Tool Suite and make sure the Grails perspective is active.  Create a new grails project and name it BCSBookStore.
Invoke the Grails command prompt and issue the following command
install-plugin spring-security-core

This action installed the spring security core.  Now we are ready to invoke the quick start by issuing the following command
s2-quickstart com.bcsbooks User Role

Three new domains were created in com.bcsbooks.

package com.bcsbooks
class Role {
	String authority
	static mapping = {
		cache true
	static constraints = {
		authority blank: false, unique: true
package com.bcsbooks
class User {
	String username
	String password
	boolean enabled
	boolean accountExpired
	boolean accountLocked
	boolean passwordExpired
	static constraints = {
		username blank: false, unique: true
		password blank: false
	static mapping = { password column: '`password`' }
	Set<Role> getAuthorities() {
		UserRole.findAllByUser(this).collect { it.role } as Set
package com.bcsbooks
import org.apache.commons.lang.builder.HashCodeBuilder
class UserRole implements Serializable {
	User user
	Role role
	boolean equals(other) {
		if (!(other instanceof UserRole)) {
			return false
		other.user?.id == user?.id &&
				other.role?.id == role?.id
	int hashCode() {
		def builder = new HashCodeBuilder()
		if (user) builder.append(user.id)
		if (role) builder.append(role.id)
	static UserRole get(long userId, long roleId) {
		find 'from UserRole where user.id=:userId and role.id=:roleId',
				[userId: userId, roleId: roleId]
	static UserRole create(User user, Role role, boolean flush = false) {
		new UserRole(user: user, role: role).save(flush: flush, insert: true)
	static boolean remove(User user, Role role, boolean flush = false) {
		UserRole instance = UserRole.findByUserAndRole(user, role)
		instance ? instance.delete(flush: flush) : false
	static void removeAll(User user) {
		executeUpdate 'DELETE FROM UserRole WHERE user=:user', [user: user]
	static void removeAll(Role role) {
		executeUpdate 'DELETE FROM UserRole WHERE role=:role', [role: role]
	static mapping = {
		id composite: ['role', 'user']
		version false
It also creates some UI controllers and GSPs:
  • grails-app/controllers/LoginController.groovy
  • grails-app/controllers/LogoutController.groovy
  • grails-app/views/auth.gsp
  • grails-app/views/denied.gsp
The script has edited grails-app/conf/Config.groovy and added the configuration for your domain classes. Make sure that the changes are correct.
Create a controller that will be restricted by role.
create-controller com.bcsbooks.Secure
package com.bcsbooks
class SecureController {
	def index = { }
Modify the controller so it produces output.
package com.bcsbooks
class SecureController {
	def index = { render 'Secure access only' }
Start the server

Before you secure the page, navigate to http://localhost:8080/bookstore/secure to verify that you can see the page without being logged in.

Shut down the app (using CTRL-C) and edit grails-app/conf/BootStrap.groovy to add the security objects that you need.

import com.bcsbooks.Role
import com.bcsbooks.User
import com.bcsbooks.UserRole
class BootStrap {
	def springSecurityService
	def init = { servletContext ->
		def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
		def userRole = new Role(authority: 'ROLE_USER').save(flush: true)
		String password = springSecurityService.encodePassword('password')
		def testUser = new User(username: 'me', enabled: true, password: password)
		testUser.save(flush: true)
		UserRole.create testUser, adminRole, true
		assert User.count() == 1
		assert Role.count() == 2
		assert UserRole.count() == 1

Some things to note about the preceding BootStrap.groovy:

  • springSecurityService is used to encrypt the password.
  • The example does not use a traditional GORM many-to-many mapping for the User<->Role relationship; instead you are mapping the join table with the UserRole class. This performance optimization helps significantly when many users have one or more common roles.

We explicitly flushed the creates because BootStrap does not run in a transaction or OpenSessionInView.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems authored this article.