2 Replies Latest reply on Sep 8, 2008 3:37 PM by socken

    Dynamic field size


      Hi all

      I'm looking for a way to create fields with a dynamic size. I'm using hibernate and want to take the length of the fields in the database into account. Let's say I have a varchar2 field with a maximum length of 40 in the database, I want to have a inputText field in Seam with a size of 40.
      Is this possible? If so, how?
      Or is this rather a JSF question than Seam?

      Thanks for any input on this one..

        • 1. Re: Dynamic field size
          Samuel Mendenhall Apprentice
          So, you could get all fancy with this and write custom EL functions to look at the annotations on the field and such.  Or, you could take the simple and preferable route, and add @Transient fields to your entity like so:

          @Transient int firstnameFieldSize = 10;
          @Transient int lastNameFieldSize = 20;

          Then do something like:

          <h:inputText value="#{personHome.instance.firstName}" size="#{personHome.instance.firstNameFieldSize}" />

          • 2. Re: Dynamic field size

            Thanks for the quick answer. The @Transient-way actually looks like a good solution to me! I'll try that, thanks!