Thanks Martin,

There was only a small little problem in your code. The correct syntax is:

def label[T](id: String, model: IModel[T] = null): Label = { val label = new
Label(id, model); add(label); label }

The suggestions were updated on Gist.

*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099



On Wed, Jul 27, 2011 at 3:55 PM, Martin Grigorov <mgrigo...@apache.org>wrote:

> Idea for simplification: use named parameters.
> For example
> def label[T](id: String, model: IModel[T]): Label = { val label = new
> Label(id, model); add(label); label }
> would become
> def label[T](id: String, model = _ : IModel[T]): Label = { val label =
> new Label(id, model); add(label); label }
>
> this way you'll have just one declaration of label function which will
> handle the current three
>
> additionally you may add a pimp:
> implicit def ser2model[S :< Serializable](ser: S): IModel[S] =
> Model.of(ser)
>
> now even when you pass String as second param to label() it will be
> converted to IModel
>
> On Wed, Jul 27, 2011 at 9:11 PM, Martin Grigorov <mgrigo...@apache.org>
> wrote:
> > Take a look at scala.swing.* sources.
> >
> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <bruno.bor...@gmail.com>
> wrote:
> >> Can some Scala expert help me to make this DSL available as PML (pimp my
> >> library)?
> >>
> >> I've tried to code it that way but things didn't quite worked out the
> way
> >> they should.
> >>
> >> The reason is that for every Wicket object I create, I must extend the
> trait
> >> DSLWicket
> >>
> >>
> >>
> >> *Bruno Borges*
> >> www.brunoborges.com.br
> >> +55 21 76727099
> >>
> >>
> >>
> >> On Wed, Jul 27, 2011 at 2:30 PM, Bruno Borges <bruno.bor...@gmail.com
> >wrote:
> >>
> >>> Not really.
> >>>
> >>> The method onSubmit() of button is void, as well onClick(), so there's
> no
> >>> need for the function be passed as () => Unit or anything else.
> >>>
> >>> I made a few changes to it and updated on Gist.
> >>>
> >>> I've also uploaded a page that uses this DSL at
> >>> https://gist.github.com/1109919
> >>>
> >>> Take a look
> >>>
> >>> *Bruno Borges*
> >>> www.brunoborges.com.br
> >>> +55 21 76727099
> >>>
> >>>
> >>>
> >>> On Wed, Jul 27, 2011 at 2:22 PM, Scott Swank <scott.sw...@gmail.com
> >wrote:
> >>>
> >>>> I think you do want Unit, which as I understand it is closest
> >>>> equivalent to "void" in Scala.
> >>>>
> >>>> http://www.scala-lang.org/api/current/scala/Unit.html
> >>>>
> >>>> Scott
> >>>>
> >>>> On Wed, Jul 27, 2011 at 10:14 AM, Bruno Borges <
> bruno.bor...@gmail.com>
> >>>> wrote:
> >>>> > No, the function must return void, not another function (unit).
> >>>> >
> >>>> > But there's also the option of () => Nothing. Which one should I use
> for
> >>>> > this case?
> >>>> >
> >>>> > *Bruno Borges*
> >>>> > www.brunoborges.com.br
> >>>> > +55 21 76727099
> >>>> >
> >>>> >
> >>>> >
> >>>> > On Wed, Jul 27, 2011 at 12:54 PM, Martin Grigorov <
> mgrigo...@apache.org
> >>>> >wrote:
> >>>> >
> >>>> >>  def button(id: String, submit: () => Void): Button = {
> >>>> >>
> >>>> >> it should be () => Unit, no ?
> >>>> >>
> >>>> >> On Wed, Jul 27, 2011 at 6:51 PM, Martin Grigorov <
> mgrigo...@apache.org
> >>>> >
> >>>> >> wrote:
> >>>> >> > Adding some usage examples at the bottom will help us evaluate
> it.
> >>>> >> >
> >>>> >> > Why not add type to
> >>>> >> > def textField(id: String): TextField[_] = { val field = new
> >>>> >> > TextField(id); add(field); field }
> >>>> >> > to become
> >>>> >> > def textField[T](id: String): TextField[T] = { val field = new
> >>>> >> > TextField[T](id); add(field); field }
> >>>> >> >
> >>>> >> > usage: textField[Int](someId)
> >>>> >> >
> >>>> >> > with using implicit Manifest for T you can also can automatically
> set
> >>>> >> > the type: field.setType(m.erasure)
> >>>> >> >
> >>>> >> > On Wed, Jul 27, 2011 at 6:26 PM, Bruno Borges <
> >>>> bruno.bor...@gmail.com>
> >>>> >> wrote:
> >>>> >> >> I've been playing with Wicket and Scala and I thought this could
> be
> >>>> >> added to
> >>>> >> >> the wicket-scala project at WicketStuff.
> >>>> >> >>
> >>>> >> >> What do you guys think?
> >>>> >> >>
> >>>> >> >> https://gist.github.com/1109603
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> *Bruno Borges*
> >>>> >> >> www.brunoborges.com.br
> >>>> >> >> +55 21 76727099
> >>>> >> >>
> >>>> >> >
> >>>> >> >
> >>>> >> >
> >>>> >> > --
> >>>> >> > Martin Grigorov
> >>>> >> > jWeekend
> >>>> >> > Training, Consulting, Development
> >>>> >> > http://jWeekend.com
> >>>> >> >
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> Martin Grigorov
> >>>> >> jWeekend
> >>>> >> Training, Consulting, Development
> >>>> >> http://jWeekend.com
> >>>> >>
> >>>> >>
> ---------------------------------------------------------------------
> >>>> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>> >>
> >>>> >>
> >>>> >
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>
> >>>>
> >>>
> >>
> >
> >
> >
> > --
> > Martin Grigorov
> > jWeekend
> > Training, Consulting, Development
> > http://jWeekend.com
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to