Re: Scala DSL for Wicket

2011-08-02 Thread Bruno Borges
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

Re: Scala DSL for Wicket

2011-08-01 Thread Bruno Borges
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

Re: Scala DSL for Wicket

2011-07-31 Thread Bruno Borges
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

Re: Scala DSL for Wicket

2011-07-31 Thread Gary Thomas
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

Re: Scala DSL for Wicket

2011-07-29 Thread Martin Grigorov
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 bruno.bor...@gmail.com wrote: Just wanted to share my experience playing

Re: Scala DSL for Wicket

2011-07-29 Thread Bruno Borges
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

Re: Scala DSL for Wicket

2011-07-29 Thread Ben Tilford
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 =

Re: Scala DSL for Wicket

2011-07-28 Thread Bruno Borges
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

Re: Scala DSL for Wicket

2011-07-27 Thread Martin Grigorov
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 }

Re: Scala DSL for Wicket

2011-07-27 Thread Martin Grigorov
def button(id: String, submit: () ⇒ Void): Button = { it should be () = Unit, no ? On Wed, Jul 27, 2011 at 6:51 PM, Martin Grigorov mgrigo...@apache.org wrote: Adding some usage examples at the bottom will help us evaluate it. Why not add type to def textField(id: String): TextField[_] = {

Re: Scala DSL for Wicket

2011-07-27 Thread Bruno Borges
No, the function must return void, not another function (unit). But there's also the option of () = Nothing. Which one should I use for this case? *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Wed, Jul 27, 2011 at 12:54 PM, Martin Grigorov mgrigo...@apache.orgwrote: def

Re: Scala DSL for Wicket

2011-07-27 Thread Martin Grigorov
Read the manual again ;-) On Wed, Jul 27, 2011 at 8:14 PM, Bruno Borges bruno.bor...@gmail.com wrote: No, the function must return void, not another function (unit). But there's also the option of () = Nothing. Which one should I use for this case? *Bruno Borges* www.brunoborges.com.br

Re: Scala DSL for Wicket

2011-07-27 Thread Scott Swank
I think you do want Unit, which as I understand it is closest equivalent to void in Scala. http://www.scala-lang.org/api/current/scala/Unit.html Scott On Wed, Jul 27, 2011 at 10:14 AM, Bruno Borges bruno.bor...@gmail.com wrote: No, the function must return void, not another function (unit).

Re: Scala DSL for Wicket

2011-07-27 Thread Bruno Borges
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

Re: Scala DSL for Wicket

2011-07-27 Thread Bruno Borges
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*

Re: Scala DSL for Wicket

2011-07-27 Thread Martin Grigorov
Take a look at scala.swing.* sources. On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges bruno.bor...@gmail.com wrote: Can some Scala expert help me to make this DSL available as PML (pimp my library)? I've tried to code it that way but things didn't quite worked out the way they should. The

Re: Scala DSL for Wicket

2011-07-27 Thread Martin Grigorov
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

Re: Scala DSL for Wicket

2011-07-27 Thread Ben Tilford
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

Re: Scala DSL for Wicket

2011-07-27 Thread Bruno Borges
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