2 Replies Latest reply on Oct 16, 2007 11:33 AM by Pete Muir

    creating Edit forms for transaltable entities  - and keep ma

    Marius Oancea Novice

      If you edit simple objects like Users, you can have thinks like:
      <h:inputText value="#{user.username}" required="true"/>

      This is very simple because user.username is a simple string and binding to the input fields is evident.

      How one would approach the following problem:

      I have a entity named "Word". Word has a name that is different in every language. So I have the following structure:

      Word Translation
      ==== ==========
      name : Translation --------------> language: String
      text: String


      Binding input fields like below, is not possible:

      <h:inputText value="#{word.name(selectedLanguage)}" required="true"/>


      What is the most elegant way to solve that?

      Note:
      selectedLanguage is a statefull component.

      One posibility is to create a WordWrapper component in wich I inject selectedLanguage, and a word object. Then I provide methods for binding (set/get for name in selected language). This will work I think but I have very many Classes like Word and will be much work.

      Any better approach to write less code ?