6 Replies Latest reply on Sep 19, 2006 11:53 AM by Barry Sheward

    One to one doubt

    fernando lins Newbie

      i having some problems trying to persist an object with a one to one relation, it is working, but there must be a better way. Let me show you:
      View:

      <tr>
       <td>Codigo</td>
       <td><h:inputText value="#{assuntoProcesso.codigo}" required="true" /></td>
       </tr>
       <tr>
       <td>Descrição</td>
       <td><h:inputText value="#{assuntoProcesso.descricao}" required="true" /></td>
       </tr>
       <tr>
       <td>Codigo Natureza</td>
       <td><h:inputText value="#{naturezaProcesso.codigo}" required="true" /></td>
       </tr>
       <tr>
       <td>Descrição Natureza</td>
       <td><h:inputText value="#{naturezaProcesso.descricao}" required="true" /></td>
       </tr>
      

      Action:
      @In
       @Out
       @Valid
       private AssuntoProcesso assuntoProcesso = new AssuntoProcesso();
      
       @In
       @Out
       @Valid
       private NaturezaProcesso naturezaProcesso;
      

      And setting the variable naturezaProcesso to assuntoProcesso then.
      but this looks kind of stupid, declaring the two variables, it would be much more simple to use a view like this:
      <tr>
       <td>Codigo</td>
       <td><h:inputText value="#{assuntoProcesso.codigo}" required="true" /></td>
       </tr>
       <tr>
       <td>Descrição</td>
       <td><h:inputText value="#{assuntoProcesso.descricao}" required="true" /></td>
       </tr>
       <tr>
       <td>Codigo Natureza</td>
       <td><h:inputText value="#{assuntoProcesso.naturezaProcesso.codigo}" required="true" /></td>
       </tr>
       <tr>
       <td>Descrição Natureza</td>
       <td><h:inputText value="#{assuntoProcesso.naturezaProcesso.descricao}" required="true" /></td>
       </tr>
      


      But i getting errors with this one, anybody can help me?