Hi Jan,

Thanks for that.  For your solution to work it looks like wicket would
need to only call getInputName at most once for each input (since
subsequent calls would return different names).  Is that how it works?

I'm still learning Scala, but so far I find it a compelling alternative to Java.

Cheers,
Ian.

On Mon, May 18, 2009 at 3:10 PM, Jan Kriesten
<kries...@mail.footprint.de> wrote:
>
> Hi Ian,
>
>> Is there a way to get wicket to generate shorter name attributes for
>> input elements?  I have a largish form and most of the data being sent
>> to the server is the names of the input elements.
>
> it is by overriding the method 'getInputName' on every FormComponent and
> returning a stable identifier over requests - though this is pretty horrible
> task to do.
>
> If you're using Scala instead of Java things are getting better, though. I
> defined the following trait (aka implemented interface):
>
> ---
> object FormInputNameId {
>  private var currId = 0
>
>  private def getName = {
>    if( currId==Integer.MAX_VALUE-1 ) currId=1 else currId = currId + 1
>    "fid:" + currId
>  }
> }
>
> trait FormInputNameId[T] extends FormComponent[T] {
>  override val getInputName: String = FormInputNameId.getName
> }
> ---
>
> This trait can be attached to any FormComponent with just something like
>
> val newFormComponent = new TextField( "id" ) with FormInputNameId
>
> The Scala compiler does the rest for you (one of my favorite features of Scala
> to have real reusable code!).
>
> Best regards, --- Jan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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

Reply via email to