Adding data to datable from a dialog box - jsf - primafaces : i'm new to JSF and having this problem of adding data to my datatable from a dialog box. I click on a commandButton "add" , a dialog box should appear and then i should save the data entries , but when i check them i find them empty - (datatble single row selection).
the code :

    <p:commandButton process="singleDT" update=":form:add" icon="ui-icon-plus" value="Add" oncomplete="PF('addDialog').show()" />

  

    <p:dataTable id="singleDT" var="o" value="#{UserBean.listE}" selectionMode="single" selection="#{UserBean.selectedEvent}" rowKey="#{o.id_event}">
          <p:column headerText="Id">
                <h:outputText value="#{o.id_event}" />
            </p:column>
            <p:column headerText="Event">
                <h:outputText value="#{o.event}" />
            </p:column>
            <p:column headerText="Date">
                <h:outputText value="#{o.date_event}" />
            </p:column>
            
        </p:dataTable>

 the dialog box when the button "add" is clicked :

     <p:dialog header="Addevent" widgetVar="addDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
        <p:outputPanel id="ajouter" style="text-align:center;">
         
            <p:panelGrid  columns="2"  columnClasses="label,value">
             <h:outputText value="Id:" />
                <h:inputText value="#{UserBean.selectedEvent.id_event}" />
 
                <h:outputText value="Event" />
                <h:inputText value="#{UserBean.selectedEvent.event}" />
 
                <h:outputText value="Date " />
                <h:inputText value="#{UserBean.selectedEvent.date_event}" />
            </p:panelGrid>
           </p:outputPanel>
        <p:commandButton action="#{UserBean.Add}" icon="ui-icon-edit" value="Add"  />
        <p:commandButton process="singleDT" update=":form:add" icon="ui-icon-cancel" value="Cancel" oncomplete="PF('addDialog').hide()" />
    </p:dialog>

the UserBean method add() :

    public void Add()
	{
		System.out.println("adding");
		event e=new event();
		e.setId_event(id_event);
		e.setEvent(event);
		e.setDate_event(date_event);
		serviceevent.add(e);
		System.out.println("added to database ");
		listE= serviceevent.findAll();
		System.out.println("refrech ");
		
				
	}
the stack error :

 

       juin 29, 2017 8:56:52 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
    AVERTISSEMENT: /test2.xhtml @84,75 value="#{UserBean.selectedEvent.id_event}": Target Unreachable, 'selectedEvent' returned null
    javax.el.PropertyNotFoundException: /test2.xhtml @84,75 value="#{UserBean.selectedEvent.id_event}": Target Unreachable, 'selectedEvent' returned null
    	at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
    	at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
    	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
    	at javax.faces.component.UIInput.validate(UIInput.java:960)
    	at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
    	at javax.faces.component.UIInput.processValidators(UIInput.java:698)
    	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    	at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:423)
    	at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
    	at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    	at java.lang.Thread.run(Unknown Source)

If any one can help ,or explain what im missing , Thank you! 
