2 Replies Latest reply on May 29, 2009 8:37 AM by simol

    Adding a object to database using modal panel

      I have following problem: I fill inputBoxes in modal panel and when action in my bean is called all fields related to inputBoxes return null. Here's some code:

      jsp Page:

      <rich:modalPanel id="profileAdd-mp" height="280" width="400" resizeable="false">
       <f:facet name="header">
       <h:panelGroup>
       <h:outputText value="Nowy Adres"></h:outputText>
       </h:panelGroup>
       </f:facet>
       <f:facet name="controls">
       <h:panelGroup>
       <h:graphicImage value="/resources/ico/close.png" id="profileAdd-hidelink"/>
       <rich:componentControl for="profileAdd-mp" attachTo="profileAdd-hidelink" operation="hide" event="onclick"/>
       </h:panelGroup>
       </f:facet>
       <h:panelGrid columns="2" id="profileAdd-pg14">
       <div align="center">
       <h:outputText value=" "/>
       <h:outputText styleClass="profile-ot" value="Kraj" id="profileAdd-ot-13"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.address.idkraj}" id="profileAdd-it-13">
      
       </h:inputText>
       <h:outputText styleClass="profile-ot" value="Miasto" id="profileAdd-ot-14"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.newaddress.miasto}" id="profileAdd-it-14">
      
       </h:inputText>
       <h:outputText styleClass="profile-ot" value="Kod pocztowy" id="profileAdd-ot-15"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.newaddress.kodpocztowy}" id="profileAdd-it-15">
      
       </h:inputText>
       <h:outputText styleClass="profile-ot" value="Ulica" id="profileAdd-ot-16"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.newaddress.ulica}" id="profileAdd-it-16">
      
       </h:inputText>
       <h:outputText styleClass="profile-ot" value="Nr domu" id="profileAdd-ot-17"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.newaddress.nrdomu}" id="profileAdd-it-17">
      
       </h:inputText>
       <h:outputText styleClass="profile-ot" value="Nr mieszkania" id="profileAdd-ot-18"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.newaddress.nrlokalu}" id="profileAdd-it-18">
      
       </h:inputText>
       <h:outputText styleClass="profile-ot" value="Nazwa" id="profileAdd-ot-19"/>
       <h:inputText styleClass="profile-it" value="#{Contractor.newaddress.typ}" id="profileAdd-it-19">
      
       </h:inputText>
       </div>
       <h:panelGroup>
       <a4j:commandButton style="margin-top: 50px" value="OK" id="profileAdd-OK" action="#{Contractor.newAddressSave}" reRender="newcontr-pg147">
       <rich:componentControl for="profileAdd-mp" attachTo="profileAdd-OK" operation="hide" event="onclick"/>
       </a4j:commandButton>
       &nbsp<a4j:commandButton style="margin-top: 50px" value="Anuluj" id="cancel" action="#{Contractor.newAddressDiscard}">
       <rich:componentControl for="profileAdd-mp" attachTo="profileAdd-Anuluj" operation="hide" event="onclick"/>
       </a4j:commandButton>
       </h:panelGroup>
       </h:panelGrid>
      </rich:modalPanel>
      


      Bean:

      
      public class Contractor extends AbstractPageBean {
      
       @EJB
       AddressManagerLocal manager;
      
       ...
      
       public Contractor() {
      
       newaddress = new Adres(); //newaddres is an entity bean
       }
      
       ...
      
       public Adres getNewaddress() {
       return newaddress;
       }
      
       public void setNewaddress(Adres newaddress) {
       this.newaddress = newaddress;
       }
      
       ...
      
       public void newAddressSave(){
       manager.addAddress(newaddress); //here it returns null
       this.newaddress = new Adres();
       }
      
       public void newAddresDiscard(){
       this.newaddress = new Adres();
       }
      }