12 Replies Latest reply on Aug 22, 2007 8:04 AM by yohann Normandin

    Exception when i want to fill a form !!

    yohann Normandin Newbie

      Hello !!!

      I have a little problem. I'am developping a web application (with Netbeans, glassfish and hibernate). In a page, the client must fill a form and when I click on the button, there is this exception :

      Exception during request processing: javax.servlet.ServletException: /abonnement_contact.xhtml @45,70 value="#{contactel.firstName}": Target Unreachable, identifier 'contactel' resolved to null

      my jsf page :

      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:f="http://java.sun.com/jsf/core">
      
       <body>
      
       <ui:composition template="templates/client.xhtml">
      
       <ui:define name="servicesclients">
      
       <h:form>
       <h3>Please fill the Contact form</h3>
      
       <h:dataTable id="contact" value="#{conts}" var="cont" rendered="#{cont.size>0}">
       <h:column>
       <f:facet name="header">Contacts</f:facet>
       <h:outputLabel value="#{cont.firstName} #{cont.lastName}"/>
       </h:column>
       </h:dataTable>
      
      
       <h:panelGrid columns="2">
       <h:outputLabel value="FirstName :"/>
       <h:inputText value="#{contactel.firstName}"/>
       <h:outputLabel value="LastName :"/>
       <h:inputText value="#{contactel.lastName}"/>
       <h:outputLabel value="Phone :"/>
       <h:inputText value="#{contactel.phone}"/>
       <h:outputLabel value="Other Phone :"/>
       <h:inputText value="#{contactel.otherPhone}"/>
       <h:outputLabel value="Mail :"/>
       <h:inputText value="#{contactel.mail}"/>
       <h:outputLabel value="Username :"/>
       <h:inputText value="#{contactel.username}"/>
       <h:outputLabel value="Password :"/>
       <h:inputText value="#{contactel.password}"/>
       </h:panelGrid>
      
       <h:commandButton value="Save" action="#{ContactManager.createContact}"/>
      
       </h:form>
      
       </ui:define>
      
      
      
       </ui:composition>
      
       </body>
      </html>
      


      and my bean :
       */
      @Stateful
      @Name("ContactManager")
      @Scope(CONVERSATION)
      public class ContactManager implements com.pingwy.web.front.ContactManagerLocal, Serializable{
      
      
      
       @In
       private EntityManager em;
      
       @DataModel("contacts")
       List<Contact> contacts;
      
       @In(required = false) @Out (required = false)
       Contact currentContact;
      
      
       @DataModelSelection("conts")
       @In (required = false)
       Contact contactel = new Contact();
      
       @DataModel("conts")
       private List<Contact> conts;
      
       @Factory("contacts")
       public String findContact(){
      
       Query query;
      
       query = em.createQuery("select c from Contact c where c.customerId=#{currentContact.customerId}");
      
       contacts = (List<Contact>) query.getResultList();
       return null;
      
      
       }
      
       public String updateContact(){
      
       em.merge(currentContact);
       return null;
      
       }
      
       public String removeContact (){
      
       System.out.println("contact bientot supprimé");
       em.remove(currentContact);
       return null;
       }
      
      
       @Begin(join = true)
       public String createContact(){
      
       conts.add(contactel);
      
       return "success";
      
       }
      
      
      
       public List<Contact> getConts() {
       return conts;
       }
      
       public void setConts(List<Contact> conts) {
       this.conts = conts;
      
       }
       public Contact getContactel() {
       return contactel;
       }
      
       public void setContactel(Contact contact) {
       this.contactel = contact;
       }
      
       @Remove @Destroy
       public void destroy(){
       }
      }


      Thanks for your help .