You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bruno Borges <br...@gmail.com> on 2011/07/27 17:26:35 UTC

Scala DSL for Wicket

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

Re: Scala DSL for Wicket

Posted by Ben Tilford <be...@tilford.info>.
I started on something sililar about a month ago. Havnt had time to work on
it for a few weeks but maybe it would be usable by someone.

https://github.com/btilford/wicketstuff-core/branches/scala-wicket-builder

There's also a groovy builder if you browse my other repos.
sent from mobile
On Jul 27, 2011 12:56 PM, "Martin Grigorov" <mg...@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 <mg...@apache.org>
wrote:
>> Take a look at scala.swing.* sources.
>>
>> On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <br...@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.borges@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.swank@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.borges@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 <
mgrigorov@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 <
mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>>>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> >>
>>>>> >>
>>>>> >
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
Another interesting piece of code with this Scala DSL

    // gender radio button
    val gender = radioGroup[String]("gender")
    gender.radio("male", Model.of("Male"))
    gender.radio("female", Model.of("Female"))
    gender.setRequired(true)

The HTML:

<div wicket:id="sexo">
<span>
<input wicket:id="male" id="male" class="field radio" type="radio" />
<label class="choice" for="male">Masculino</label>
</span>

<span>
<input wicket:id="female" id="female" class="field radio" type="radio" />
<label class="choice" for="female">Female</label>
</span>
</div>

This way, the HTMLis exactly the way the designer sent it to me.


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

Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
The WicketStuff Scala project is the best way to put all this.

The project is more Scala-based components driven, like Fodel/SLabel and
SForm, but I think Scala can offer even more advantages like the one you
propose here.

DSL is the way to go IMO for this Scala-Wicket integration


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



On Mon, Aug 1, 2011 at 2:45 AM, Gary Thomas <7z...@gmail.com> wrote:

>
> I've written some Scala utilities as well, but instead of a DSL I'm using
> implicit conversions via traits, which I've found to be a really nice fit
> with Wicket.
>
> An example:
>
> import org.apache.wicket.model.IModel
> import org.apache.wicket.model.**LoadableDetachableModel
> import org.apache.wicket.model.**PropertyModel
>
> trait WicketConversions {
>   // transparent PropertyModel conversion
>    implicit def tuple2model[T](tuple: (AnyRef, String)): PropertyModel[T] =
> {
>        new PropertyModel[T](tuple._1, tuple._2)
>    }
>
>    // transparent function/closure to LoadableDetachableModel conversion
>    implicit def function2model[T](f: => T): IModel[T] = {
>        new LoadableDetachableModel[T] {
>            def load: T = f
>        }
>    }
> }
>
> Usage:
>
> class MyPanel extends Panel("id") with WicketConversions {
>
>    // transparent PropertyModel conversion using article.rating):
>    add(new RatingPanel("rating", article -> "rating") // so pretty
>
>    // transparent LoadableDetachableModel conversion (expects
> IModel[Boolean]):
>    add(new AjaxCheckBox("selected", { dao.get(id).isAdmin }) {
>        def onUpdate(target: AjaxRequestTarget) { ... }
>    })
> }
>
>
> I have more code as well for Spring integration, etc.
> If anyone is interested, I could add mine to this or to a new GitHub
> project.
>
>
> Thanks,
> Gary
>
>
>
> On 7/29/11 5:22 PM, Ben Tilford wrote:
>
>> For LDM
>>
>> class Ldm[T](provider:()=>  T) extends LoadableDetachable... {
>>   def load():T {
>>     provider()
>>   }
>> }
>>
>> object Ldm {
>>   def apply(provider:()=>T) = new Ldm[T](provider)
>> }
>>
>> could be used as
>>
>> ...
>> val id = 1
>> val model = Ldm(()=>{dao.get(id)})
>>
>> or
>>
>> val id = 1
>> def provider = dao.get(id)
>> val model = Ldm(provider)
>>
>>
>> On Fri, Jul 29, 2011 at 6:44 AM, Martin Grigorov<mg...@apache.org>**
>> wrote:
>>
>>  Bruno,
>>>
>>> Yet another idea for the dsl:
>>>
>>> def ldm[R, ID](id: ID = null, f: (ID) =>  R) = {new
>>> LoadableDetachableModel(id) { override def load() : R = { f(id); } } }
>>>
>>> P.S. Not tested.
>>>
>>> On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges<br...@gmail.com>
>>> wrote:
>>>
>>>> Just wanted to share my experience playing a little more with Scala and
>>>> Wicket>  A few minutes ago I got this excelent code:
>>>>
>>>> I know it is too simple, and it can be accomplished as well in Java with
>>>> static imports. But still, for my project it's being great (and cool) to
>>>>
>>> do
>>>
>>>> such things.
>>>>
>>>>     object btnEditar extends Button("btnEditar") {
>>>>       override def onSubmit() = {
>>>> -        /* show fields */
>>>> -        camposForm.**setVisibilityAllowed(true)
>>>> -        btnSalvar.**setVisibilityAllowed(true)
>>>> -        cancelar.setVisibilityAllowed(**true)
>>>> -
>>>> -        /* hide them */
>>>> -        camposTela.**setVisibilityAllowed(false)
>>>> -        btnEditar.**setVisibilityAllowed(false)
>>>> +        show(camposForm, btnSalvar, cancelar)
>>>> +        hide(camposTela, btnEditar)
>>>>       }
>>>>     }
>>>>     add(btnEditar)
>>>>
>>>> Methods show/hide are imported as "import code.DSLWicket._"
>>>>
>>>>
>>>>
>>>> *Bruno Borges*
>>>> www.brunoborges.com.br
>>>> +55 21 76727099
>>>>
>>>>
>>>>
>>>> On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges<bruno.borges@gmail.com
>>>> wrote:
>>>>
>>>>  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<mgrigorov@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<mgrigorov@apache.org
>>>>>>
>>>>>
>>>>  wrote:
>>>>>>
>>>>>>> Take a look at scala.swing.* sources.
>>>>>>>
>>>>>>> On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges<
>>>>>>>
>>>>>> bruno.borges@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.borges@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<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.swank@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<http://www.scala-lang.org/api/current/scala/Unit.html>
>>>>>>>>>>
>>>>>>>>>> Scott
>>>>>>>>>>
>>>>>>>>>> On Wed, Jul 27, 2011 at 10:14 AM, Bruno Borges<
>>>>>>>>>>
>>>>>>>>> bruno.borges@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<
>>>>>>>>>>>
>>>>>>>>>> mgrigorov@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<
>>>>>>>>>>>>
>>>>>>>>>>> mgrigorov@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.borges@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<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-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  ------------------------------**------------------------------**
>>> ---------
>>>
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>>>>>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Martin Grigorov
>>> jWeekend
>>> Training, Consulting, Development
>>> http://jWeekend.com
>>>
>>> ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>

Re: Scala DSL for Wicket

Posted by Gary Thomas <7z...@gmail.com>.
I've written some Scala utilities as well, but instead of a DSL I'm 
using implicit conversions via traits, which I've found to be a really 
nice fit with Wicket.

An example:

import org.apache.wicket.model.IModel
import org.apache.wicket.model.LoadableDetachableModel
import org.apache.wicket.model.PropertyModel

trait WicketConversions {
    // transparent PropertyModel conversion
     implicit def tuple2model[T](tuple: (AnyRef, String)): 
PropertyModel[T] = {
         new PropertyModel[T](tuple._1, tuple._2)
     }

     // transparent function/closure to LoadableDetachableModel conversion
     implicit def function2model[T](f: => T): IModel[T] = {
         new LoadableDetachableModel[T] {
             def load: T = f
         }
     }
}

Usage:

class MyPanel extends Panel("id") with WicketConversions {

     // transparent PropertyModel conversion using article.rating):
     add(new RatingPanel("rating", article -> "rating") // so pretty

     // transparent LoadableDetachableModel conversion (expects 
IModel[Boolean]):
     add(new AjaxCheckBox("selected", { dao.get(id).isAdmin }) {
         def onUpdate(target: AjaxRequestTarget) { ... }
     })
}


I have more code as well for Spring integration, etc.
If anyone is interested, I could add mine to this or to a new GitHub 
project.


Thanks,
Gary


On 7/29/11 5:22 PM, Ben Tilford wrote:
> For LDM
>
> class Ldm[T](provider:()=>  T) extends LoadableDetachable... {
>    def load():T {
>      provider()
>    }
> }
>
> object Ldm {
>    def apply(provider:()=>T) = new Ldm[T](provider)
> }
>
> could be used as
>
> ...
> val id = 1
> val model = Ldm(()=>{dao.get(id)})
>
> or
>
> val id = 1
> def provider = dao.get(id)
> val model = Ldm(provider)
>
>
> On Fri, Jul 29, 2011 at 6:44 AM, Martin Grigorov<mg...@apache.org>wrote:
>
>> Bruno,
>>
>> Yet another idea for the dsl:
>>
>> def ldm[R, ID](id: ID = null, f: (ID) =>  R) = {new
>> LoadableDetachableModel(id) { override def load() : R = { f(id); } } }
>>
>> P.S. Not tested.
>>
>> On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges<br...@gmail.com>
>> wrote:
>>> Just wanted to share my experience playing a little more with Scala and
>>> Wicket>  A few minutes ago I got this excelent code:
>>>
>>> I know it is too simple, and it can be accomplished as well in Java with
>>> static imports. But still, for my project it's being great (and cool) to
>> do
>>> such things.
>>>
>>>      object btnEditar extends Button("btnEditar") {
>>>        override def onSubmit() = {
>>> -        /* show fields */
>>> -        camposForm.setVisibilityAllowed(true)
>>> -        btnSalvar.setVisibilityAllowed(true)
>>> -        cancelar.setVisibilityAllowed(true)
>>> -
>>> -        /* hide them */
>>> -        camposTela.setVisibilityAllowed(false)
>>> -        btnEditar.setVisibilityAllowed(false)
>>> +        show(camposForm, btnSalvar, cancelar)
>>> +        hide(camposTela, btnEditar)
>>>        }
>>>      }
>>>      add(btnEditar)
>>>
>>> Methods show/hide are imported as "import code.DSLWicket._"
>>>
>>>
>>>
>>> *Bruno Borges*
>>> www.brunoborges.com.br
>>> +55 21 76727099
>>>
>>>
>>>
>>> On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges<bruno.borges@gmail.com
>>> wrote:
>>>
>>>> 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<mgrigorov@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<mgrigorov@apache.org
>>>
>>>>> wrote:
>>>>>> Take a look at scala.swing.* sources.
>>>>>>
>>>>>> On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges<
>> bruno.borges@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.borges@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.swank@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.borges@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<
>>>>> mgrigorov@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<
>>>>> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
This is an excellent piece of code.

What I had was similar, but in a trait as a method:

def ldm( loadF() => T ): IModel[T] = {
   ...
}

I guess breaking the DSL will make it easier to maintain. :-) And your
approach is much better


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



On Fri, Jul 29, 2011 at 9:22 PM, Ben Tilford <be...@tilford.info> wrote:

> For LDM
>
> class Ldm[T](provider:()=> T) extends LoadableDetachable... {
>  def load():T {
>    provider()
>  }
> }
>
> object Ldm {
>  def apply(provider:()=>T) = new Ldm[T](provider)
> }
>
> could be used as
>
> ...
> val id = 1
> val model = Ldm(()=>{dao.get(id)})
>
> or
>
> val id = 1
> def provider = dao.get(id)
> val model = Ldm(provider)
>
>
> On Fri, Jul 29, 2011 at 6:44 AM, Martin Grigorov <mgrigorov@apache.org
> >wrote:
>
> > Bruno,
> >
> > Yet another idea for the dsl:
> >
> > def ldm[R, ID](id: ID = null, f: (ID) => R) = {new
> > LoadableDetachableModel(id) { override def load() : R = { f(id); } } }
> >
> > P.S. Not tested.
> >
> > On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges <br...@gmail.com>
> > wrote:
> > > Just wanted to share my experience playing a little more with Scala and
> > > Wicket> A few minutes ago I got this excelent code:
> > >
> > > I know it is too simple, and it can be accomplished as well in Java
> with
> > > static imports. But still, for my project it's being great (and cool)
> to
> > do
> > > such things.
> > >
> > >     object btnEditar extends Button("btnEditar") {
> > >       override def onSubmit() = {
> > > -        /* show fields */
> > > -        camposForm.setVisibilityAllowed(true)
> > > -        btnSalvar.setVisibilityAllowed(true)
> > > -        cancelar.setVisibilityAllowed(true)
> > > -
> > > -        /* hide them */
> > > -        camposTela.setVisibilityAllowed(false)
> > > -        btnEditar.setVisibilityAllowed(false)
> > > +        show(camposForm, btnSalvar, cancelar)
> > > +        hide(camposTela, btnEditar)
> > >       }
> > >     }
> > >     add(btnEditar)
> > >
> > > Methods show/hide are imported as "import code.DSLWicket._"
> > >
> > >
> > >
> > > *Bruno Borges*
> > > www.brunoborges.com.br
> > > +55 21 76727099
> > >
> > >
> > >
> > > On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges <bruno.borges@gmail.com
> > >wrote:
> > >
> > >> 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 <
> mgrigorov@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 <
> mgrigorov@apache.org
> > >
> > >>> wrote:
> > >>> > Take a look at scala.swing.* sources.
> > >>> >
> > >>> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <
> > bruno.borges@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.borges@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.swank@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.borges@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 <
> > >>> mgrigorov@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 <
> > >>> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
> > >>> >>>> >> For additional commands, e-mail:
> users-help@wicket.apache.org
> > >>> >>>> >>
> > >>> >>>> >>
> > >>> >>>> >
> > >>> >>>>
> > >>> >>>>
> > ---------------------------------------------------------------------
> > >>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >>> >>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> > >>> For additional commands, e-mail: users-help@wicket.apache.org
> > >>>
> > >>>
> > >>
> > >
> >
> >
> >
> > --
> > Martin Grigorov
> > jWeekend
> > Training, Consulting, Development
> > http://jWeekend.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: Scala DSL for Wicket

Posted by Ben Tilford <be...@tilford.info>.
For LDM

class Ldm[T](provider:()=> T) extends LoadableDetachable... {
  def load():T {
    provider()
  }
}

object Ldm {
  def apply(provider:()=>T) = new Ldm[T](provider)
}

could be used as

...
val id = 1
val model = Ldm(()=>{dao.get(id)})

or

val id = 1
def provider = dao.get(id)
val model = Ldm(provider)


On Fri, Jul 29, 2011 at 6:44 AM, Martin Grigorov <mg...@apache.org>wrote:

> Bruno,
>
> Yet another idea for the dsl:
>
> def ldm[R, ID](id: ID = null, f: (ID) => R) = {new
> LoadableDetachableModel(id) { override def load() : R = { f(id); } } }
>
> P.S. Not tested.
>
> On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges <br...@gmail.com>
> wrote:
> > Just wanted to share my experience playing a little more with Scala and
> > Wicket> A few minutes ago I got this excelent code:
> >
> > I know it is too simple, and it can be accomplished as well in Java with
> > static imports. But still, for my project it's being great (and cool) to
> do
> > such things.
> >
> >     object btnEditar extends Button("btnEditar") {
> >       override def onSubmit() = {
> > -        /* show fields */
> > -        camposForm.setVisibilityAllowed(true)
> > -        btnSalvar.setVisibilityAllowed(true)
> > -        cancelar.setVisibilityAllowed(true)
> > -
> > -        /* hide them */
> > -        camposTela.setVisibilityAllowed(false)
> > -        btnEditar.setVisibilityAllowed(false)
> > +        show(camposForm, btnSalvar, cancelar)
> > +        hide(camposTela, btnEditar)
> >       }
> >     }
> >     add(btnEditar)
> >
> > Methods show/hide are imported as "import code.DSLWicket._"
> >
> >
> >
> > *Bruno Borges*
> > www.brunoborges.com.br
> > +55 21 76727099
> >
> >
> >
> > On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges <bruno.borges@gmail.com
> >wrote:
> >
> >> 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 <mgrigorov@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 <mgrigorov@apache.org
> >
> >>> wrote:
> >>> > Take a look at scala.swing.* sources.
> >>> >
> >>> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <
> bruno.borges@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.borges@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.swank@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.borges@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 <
> >>> mgrigorov@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 <
> >>> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
> >>> >>>> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>> >>>> >>
> >>> >>>> >>
> >>> >>>> >
> >>> >>>>
> >>> >>>>
> ---------------------------------------------------------------------
> >>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> >>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
I thought about this yesterday but maybe overloading the method is better.

Because this way the function must have to be passed as of expecting an id
argument, even if the id argument for ldm() is optional.

I just haven't added yet because of lack of usecase. :-)

But thanks!!

This DSL is saving me a lot of coding, even if is not actually a DSL, but a
"way to go". :-)

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



On Fri, Jul 29, 2011 at 9:44 AM, Martin Grigorov <mg...@apache.org>wrote:

> Bruno,
>
> Yet another idea for the dsl:
>
> def ldm[R, ID](id: ID = null, f: (ID) => R) = {new
> LoadableDetachableModel(id) { override def load() : R = { f(id); } } }
>
> P.S. Not tested.
>
> On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges <br...@gmail.com>
> wrote:
> > Just wanted to share my experience playing a little more with Scala and
> > Wicket> A few minutes ago I got this excelent code:
> >
> > I know it is too simple, and it can be accomplished as well in Java with
> > static imports. But still, for my project it's being great (and cool) to
> do
> > such things.
> >
> >     object btnEditar extends Button("btnEditar") {
> >       override def onSubmit() = {
> > -        /* show fields */
> > -        camposForm.setVisibilityAllowed(true)
> > -        btnSalvar.setVisibilityAllowed(true)
> > -        cancelar.setVisibilityAllowed(true)
> > -
> > -        /* hide them */
> > -        camposTela.setVisibilityAllowed(false)
> > -        btnEditar.setVisibilityAllowed(false)
> > +        show(camposForm, btnSalvar, cancelar)
> > +        hide(camposTela, btnEditar)
> >       }
> >     }
> >     add(btnEditar)
> >
> > Methods show/hide are imported as "import code.DSLWicket._"
> >
> >
> >
> > *Bruno Borges*
> > www.brunoborges.com.br
> > +55 21 76727099
> >
> >
> >
> > On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges <bruno.borges@gmail.com
> >wrote:
> >
> >> 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 <mgrigorov@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 <mgrigorov@apache.org
> >
> >>> wrote:
> >>> > Take a look at scala.swing.* sources.
> >>> >
> >>> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <
> bruno.borges@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.borges@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.swank@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.borges@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 <
> >>> mgrigorov@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 <
> >>> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
> >>> >>>> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>> >>>> >>
> >>> >>>> >>
> >>> >>>> >
> >>> >>>>
> >>> >>>>
> ---------------------------------------------------------------------
> >>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> >>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Scala DSL for Wicket

Posted by Martin Grigorov <mg...@apache.org>.
Bruno,

Yet another idea for the dsl:

def ldm[R, ID](id: ID = null, f: (ID) => R) = {new
LoadableDetachableModel(id) { override def load() : R = { f(id); } } }

P.S. Not tested.

On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges <br...@gmail.com> wrote:
> Just wanted to share my experience playing a little more with Scala and
> Wicket> A few minutes ago I got this excelent code:
>
> I know it is too simple, and it can be accomplished as well in Java with
> static imports. But still, for my project it's being great (and cool) to do
> such things.
>
>     object btnEditar extends Button("btnEditar") {
>       override def onSubmit() = {
> -        /* show fields */
> -        camposForm.setVisibilityAllowed(true)
> -        btnSalvar.setVisibilityAllowed(true)
> -        cancelar.setVisibilityAllowed(true)
> -
> -        /* hide them */
> -        camposTela.setVisibilityAllowed(false)
> -        btnEditar.setVisibilityAllowed(false)
> +        show(camposForm, btnSalvar, cancelar)
> +        hide(camposTela, btnEditar)
>       }
>     }
>     add(btnEditar)
>
> Methods show/hide are imported as "import code.DSLWicket._"
>
>
>
> *Bruno Borges*
> www.brunoborges.com.br
> +55 21 76727099
>
>
>
> On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges <br...@gmail.com>wrote:
>
>> 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 <mg...@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 <mg...@apache.org>
>>> wrote:
>>> > Take a look at scala.swing.* sources.
>>> >
>>> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <br...@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.borges@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.swank@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.borges@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 <
>>> mgrigorov@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 <
>>> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>>> >>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>>> >>
>>> >>>> >>
>>> >>>> >
>>> >>>>
>>> >>>> ---------------------------------------------------------------------
>>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
Just wanted to share my experience playing a little more with Scala and
Wicket> A few minutes ago I got this excelent code:

I know it is too simple, and it can be accomplished as well in Java with
static imports. But still, for my project it's being great (and cool) to do
such things.

     object btnEditar extends Button("btnEditar") {
       override def onSubmit() = {
-        /* show fields */
-        camposForm.setVisibilityAllowed(true)
-        btnSalvar.setVisibilityAllowed(true)
-        cancelar.setVisibilityAllowed(true)
-
-        /* hide them */
-        camposTela.setVisibilityAllowed(false)
-        btnEditar.setVisibilityAllowed(false)
+        show(camposForm, btnSalvar, cancelar)
+        hide(camposTela, btnEditar)
       }
     }
     add(btnEditar)

Methods show/hide are imported as "import code.DSLWicket._"



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



On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges <br...@gmail.com>wrote:

> 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 <mg...@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 <mg...@apache.org>
>> wrote:
>> > Take a look at scala.swing.* sources.
>> >
>> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <br...@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.borges@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.swank@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.borges@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 <
>> mgrigorov@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 <
>> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>> >>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>> >>
>> >>>> >>
>> >>>> >
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
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 <mg...@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 <mg...@apache.org>
> wrote:
> > Take a look at scala.swing.* sources.
> >
> > On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <br...@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.borges@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.swank@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.borges@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 <
> mgrigorov@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 <
> mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
> >>>> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>>> >>
> >>>> >>
> >>>> >
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Scala DSL for Wicket

Posted by Martin Grigorov <mg...@apache.org>.
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 <mg...@apache.org> wrote:
> Take a look at scala.swing.* sources.
>
> On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <br...@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 <br...@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 <sc...@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 <br...@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 <mgrigorov@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 <mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>>> >>
>>>> >>
>>>> >
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Martin Grigorov <mg...@apache.org>.
Take a look at scala.swing.* sources.

On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges <br...@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 <br...@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 <sc...@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 <br...@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 <mgrigorov@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 <mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
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 <br...@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 <sc...@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 <br...@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 <mgrigorov@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 <mgrigorov@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.borges@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-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
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 <sc...@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 <br...@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 <mgrigorov@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 <mg...@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.borges@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-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Scala DSL for Wicket

Posted by Scott Swank <sc...@gmail.com>.
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 <br...@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 <mg...@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 <mg...@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 <br...@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Martin Grigorov <mg...@apache.org>.
Read the manual again ;-)

On Wed, Jul 27, 2011 at 8:14 PM, Bruno Borges <br...@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 <mg...@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 <mg...@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 <br...@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Bruno Borges <br...@gmail.com>.
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 <mg...@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 <mg...@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 <br...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Scala DSL for Wicket

Posted by Martin Grigorov <mg...@apache.org>.
 def button(id: String, submit: () ⇒ Void): Button = {

it should be () => Unit, no ?

On Wed, Jul 27, 2011 at 6:51 PM, Martin Grigorov <mg...@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 <br...@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Scala DSL for Wicket

Posted by Martin Grigorov <mg...@apache.org>.
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 <br...@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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org