Dienstag, 9. August 2016

Angular2: How to use an enum in a view template

A TypeScript enum can be used in an Angular2 template by aliasing the type in the component. Thus it is known when binding the model. Otherwise it is recognized as string literal.
import {Component} from '@angular/core';
import {SexEnum} from '../shared/models/sex.enum';
import {RadioButton} from 'primeng/components/radiobutton/radiobutton';

@Component({
      selector: 'some-form',
      template: `
<div class="ui-grid-col-8">
   <p-radiobutton name="sexGroup" label="Woman" [value]="SexEnum.w" [(ngModel)]="sex" ></p-radiobutton>
   <p-radiobutton name="sexGroup" label="Man"   [value]="SexEnum.m"   [(ngModel)]="sex" ></p-radiobutton>
</div>
`,
     directives: [RadioButton]
})
export class SomeFormComponent {
  SexEnum = SexEnum; // Export enum to view
  sex : SexEnum;
}

Donnerstag, 14. März 2013

Groovy-Console with GTK-L&F under Linux?

It's easy. Simply put a file startup into the directory $HOME/.groovy with content:

JAVA_OPTS+=" -Dswing.aatext=true"
JAVA_OPTS+=" -Dswing.systemlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"

Sonntag, 25. Dezember 2011

Goovy & Unix: How to find a program?

How to find out in Groovy whether a program is installed?

I've tried this:

// Check for availability of "formail", which should be included in packages for "procmail"
def formailPath = 'which formail'.execute().text.trim()
assert formailPath > '', 'Programm "formail" is needed. Please install package procmail'

and it worked quite well, since the expression 'which formail'.execute().text.trim() returns either the empty string or the path to the executable.

Sonntag, 19. Juli 2009

Netbeans Module for Hibernates-Entitymanager

Trying to develop a little application with the Netbeans-Platform I encountered a little problem with Netbeans module structure. Since I don't want to have the database module (Derby) included in the JPA-Provider module (Hibernate-Entitymanger) I tried to simply let the derby-module export the token "java.sql.Driver" and let the JPA-mdodule require that token. But this led to runtime exception, since the DriverManager inside of the JPA-module couldn't see the driver included in the derby-module.
Finally I wrote my own LookupConnectionProvider (implementing org.hibernate.connection.ConnectionProvider), which uses Netbeans Lookup mechanism to find the required driver. With this new connection provider no "hard" reference to the derby module is needed to let the JPA-module find the driver.