moved handler code generator in AbstractWidget into its own class