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

Reply via email to