java - Update a table data in maven + seam -


i want update record in user table.. seam+jsf project configured in maven. tried make failed more.

i here favor friends. hope me.

thanks in advance..

my update page:

        <!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"         xmlns:clrp="http://panorosys.com/products/clrp/taglib"         xmlns:p="http://primefaces.prime.com.tr/ui">     <ui:composition>         <div class="panel-content">             <h:form class="input-list" id="createuser">                  <h:panelgrid border="1" class="creatuserdetailstable">                     <f:facet name="header">                         <h:outputtext value="personal details" />                     </f:facet>                     <s:decorate id="firstnamedec" template="../../../secure/edit.xhtml">                         <ui:define name="label">first name:</ui:define>                         <h:inputtext tabindex="1" id="firstname" type="text"                             value="#{currentuser.firstname}" required="true">                             <f:validatelength minimum="3" maximum="20" />                         </h:inputtext>                     </s:decorate>                      <s:decorate id="lastnamedec" template="../../../secure/edit.xhtml">                         <ui:define name="label">last name:</ui:define>                         <h:inputtext tabindex="2" id="lastname" type="text"                             value="#{currentuser.lastname}" required="true">                             <f:validatelength maximum="20" />                         </h:inputtext>                     </s:decorate>                      <s:decorate id="emailiddec" template="../../../secure/edit.xhtml">                         <ui:define name="label">email id:</ui:define>                         <h:inputtext tabindex="3" id="emailid" type="text"                             value="#{currentuser.emailaddress}">                             <f:validatelength maximum="20" />                         </h:inputtext>                     </s:decorate>                     <s:decorate id="homenumberdec" template="../../../secure/edit.xhtml">                         <ui:define name="label">home number:</ui:define>                         <h:inputtext tabindex="4" id="homenumber" type="text"                             value="#{currentuser.homenumber}">                             <f:validatelength maximum="20" />                         </h:inputtext>                     </s:decorate>                      <s:decorate id="cellnumberdec" template="../../../secure/edit.xhtml">                         <ui:define name="label">cell number:</ui:define>                         <h:inputtext tabindex="5" id="cellnumber" type="text"                             value="#{currentuser.cellnumber}" required="true">                             <f:validatelength maximum="20" />                         </h:inputtext>                     </s:decorate>                      <s:decorate id="officenumberdec"                         template="../../../secure/edit.xhtml">                         <ui:define name="label">office number:</ui:define>                         <h:inputtext tabindex="6" id="officenumber" type="text"                             value="#{currentuser.officenumber}">                             <f:validatelength maximum="20" />                         </h:inputtext>                     </s:decorate>                 </h:panelgrid>                   <h:panelgrid border="1" columns="2" class="createuseraddresstable1">                     <f:facet name="header">                         <h:outputtext value="address" />                     </f:facet>                     <h:panelgrid border="1" class="createcurrentuseraddresstable">                         <f:facet name="header">                             <h:outputtext value="residential" />                         </f:facet>                         <s:decorate id="residentialaddress1dec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">address 1:</ui:define>                             <h:inputtext tabindex="7" id="residentialaddress1" type="text"                                 value="#{currentuser.residentialaddress.address1}"                                 required="true">                                 <f:validatelength maximum="20" />                             </h:inputtext>                         </s:decorate>                         <s:decorate id="residentialaddress2dec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">address 2:</ui:define>                             <h:inputtext tabindex="7" id="residentialaddress2" type="text"                                 value="#{currentuser.residentialaddress.address2}"                                 required="true">                                 <f:validatelength maximum="20" />                             </h:inputtext>                         </s:decorate>                         <s:decorate id="residentialcitydec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">city:</ui:define>                             <h:inputtext tabindex="9" id="residentialcity" type="text"                                 value="#{currentuser.residentialaddress.city}" required="true">                                 <f:validatelength maximum="20" />                             </h:inputtext>                         </s:decorate>                         <s:decorate id="residentialcountrydec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">country :</ui:define>                             <h:inputtext tabindex="10"                                 value="#{currentuser.residentialaddress.countryid}"                                 id="residentialcountry" type="text"                                 class="resi-country-class cntry" required="true">                             </h:inputtext>                         </s:decorate>                         <s:decorate id="residentialstatedec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">state :</ui:define>                             <h:inputtext tabindex="11"                                 value="#{currentuser.residentialaddress.stateid}"                                 id="residentialstate" type="text" required="true">                             </h:inputtext>                         </s:decorate>                         <s:decorate id="residentialzipcodedec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">zip code :</ui:define>                             <h:inputtext tabindex="12" id="residentialzipcode" type="text"                                 value="#{currentuser.residentialaddress.zipcode}" required="true">                                 <f:validatelength minimum="0" maximum="6" />                             </h:inputtext>                         </s:decorate>                     </h:panelgrid>                     <h:panelgrid border="1" class="createuseraddresstable">                         <f:facet name="header">                             <h:outputtext value="shipping" />                         </f:facet>                          <s:decorate id="shippingaddress1dec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">address 1:</ui:define>                             <h:inputtext tabindex="14" id="shippingaddress1" type="text"                                 value="#{currentuser.shippingaddress.address1}" required="true">                                 <f:validatelength maximum="20" />                             </h:inputtext>                         </s:decorate>                         <s:decorate id="shippingaddress2dec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">address 2:</ui:define>                             <h:inputtext tabindex="15" id="shippingaddress2" type="text"                                 value="#{currentuser.shippingaddress.address2}" required="true">                                 <f:validatelength maximum="20" />                             </h:inputtext>                         </s:decorate>                         <s:decorate id="shippingcitydec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">city:</ui:define>                             <h:inputtext tabindex="16" id="shippingcity" type="text"                                 value="#{currentuser.shippingaddress.city}" required="true">                                 <f:validatelength maximum="20" />                             </h:inputtext>                         </s:decorate>                         <s:decorate id="shippingcountrydec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">country :</ui:define>                             <h:inputtext tabindex="17"                                 value="#{currentuser.shippingaddress.countryid}"                                 id="shippingcountry" type="text"                                 class="shipp-country-class cntry" required="true">                             </h:inputtext>                         </s:decorate>                         <s:decorate id="shippingstatedec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">state :</ui:define>                             <h:inputtext tabindex="18"                                 value="#{currentuser.shippingaddress.stateid}" id="shippingstate"                                 type="text" class="shipp-state-class state" required="true">                             </h:inputtext>                         </s:decorate>                         <s:decorate id="shippingzipcodedec"                             template="../../../secure/edit.xhtml">                             <ui:define name="label">zip code :</ui:define>                             <h:inputtext tabindex="19" id="shippingzipcode" type="text"                                 value="#{currentuser.shippingaddress.zipcode}" required="true">                                 <f:validatelength minimum="0" maximum="6" />                             </h:inputtext>                         </s:decorate>                     </h:panelgrid>                 </h:panelgrid>                  <h:commandbutton value="update" tabindex="20"                     action="#{useraction.update}" class="usersubmit">                     <f:param name="userid" value="#{currentuser.userid}" />                 </h:commandbutton>             </h:form>             <h:messages globalonly="true" />             <s:remote include="currentuserlistaction" />             <script type="text/javascript">         $().ready(function() {                 loadcountries("#{resteasypath}/lookup/country/");                 $(".shipp-country-class").val(#{currentuseraction.currentuser.shippingaddress.countryid});                 $(".resi-country-class").val(#{currentuseraction.currentuser.residentialaddress.countryid});              $('#firstname').focus();             $("#mydropdownlist").val("thevalue");         });              $(".shipp-country-class").change(function(e){                 var countryid=$(".shipp-country-class").val();                 loadstate("#{resteasypath}/lookup/state/"+countryid+'/',"shipp" );             });             $(".resi-country-class").change(function(e){             var countryid=$(".resi-country-class").val();             loadstate("#{resteasypath}/lookup/state/"+countryid+'/',"resi" );         });     </script>         </div>     </ui:composition>     </html> 

action class:

        @name("useraction")     @stateless     @autocreate     public class useractionimpl implements useraction {          @out(value = "currentuser", scope = scopetype.conversation)         @in(value = "currentuser", scope = scopetype.conversation, required = false)         private clrpuser currentuser;             @in         private userservice userservice;              @requestparameter         private integer userid;          private static final long serialversionuid = 8282995226262125676l;          public string update() {             userservice.saveorupdate(currentuser);             return "success";         }          public string getclrp() {             return constants.success_str;         }          public clrpuser getcurrentuser() {             return currentuser;         }          public void setcurrentuser(clrpuser currentuser) {             this.currentuser = currentuser;         }      } 

service class:

        @name("userservice")     @stateless     @autocreate     public class userserviceimpl implements userservice {      private static final long serialversionuid = 1l;          @in         private userdao userdao;          @in         private loggedinuser loggedinuser = null;          public userdao getuserdao() {             return userdao;         }          public void setuserdao(userdao userdao) {             this.userdao = userdao;         }          public userserviceimpl() {             super();         }          public integer saveorupdate(clrpuser user) {             user.setlastupdatedby(loggedinuser.getid());             user.getresidentialaddress().setlastupdatedby(loggedinuser.getid());             user.getshippingaddress().setlastupdatedby(loggedinuser.getid());             user.getuserlogin().setlastupdatedby(loggedinuser.getid());             user.getuserroles().setlastupdatedby(loggedinuser.getid());             // user.gettransaction().setlastupdatedby(loggedinuser.getid());              userentity userentity = usermapper.mapuserentity(user);             integer userid = userdao.saveorupdate(userentity);             system.out.println("user id saved " + userid);             return userid;         }          }      } 

mapper class:

        public class usermapper {          public static userentity mapuserentity(clrpuser user) {             userentity userentity = new userentity();              userentity.setuserid(user.getuserid());             userentity.setemailaddress(user.getemailaddress());             userentity.setfirstname(user.getfirstname());             userentity.setlastname(user.getlastname());             userentity.sethomenumber(user.gethomenumber());             userentity.setofficenumber(user.getofficenumber());             userentity.setcellnumber(user.getcellnumber());             userentity.setcardid(user.getcardid());             auditinfo auditinfo = new auditinfo();             auditinfo.setlastupdatedby(user.getlastupdatedby());             auditinfo.setlastupdatedtime(user.getlastupdatedtime());             userentity.setauditinfo(auditinfo);             userentity.settype(user.gettype());             userentity.setpreferenceid(user.getpreferenceid());             userentity.setaspcustomerid(user.getaspcustomerid());              user.getresidentialaddress().setaddresstype("r");             user.getshippingaddress().setaddresstype("s");              addressentity residential = addressmapper.mapaddressentity(user                     .getresidentialaddress());             addressentity shipping = addressmapper.mapaddressentity(user                     .getshippingaddress());             list<addressentity> addressess = new arraylist<addressentity>();             addressess.add(residential);             addressess.add(shipping);             userentity.setaddresses(new hashset<addressentity>(addressess));              user.getuserlogin().setuserid(user.getuserid());             user.getuserlogin().setusername(user.getcellnumber());             user.getuserlogin().setpassword(user.getcellnumber());              userloginentity userlogin = userloginmapper.mapuserloginentity(user                     .getuserlogin());             list<userloginentity> userlogins = new arraylist<userloginentity>();             userlogins.add(userlogin);             userentity.setuserlogins(new hashset<userloginentity>(userlogins));              user.getuserroles().setuserid(user.getuserid());             user.getuserroles().setroleid(1);              userroleentity userroleentity = userrolemapper.mapuserroleentity(user.getuserroles());             list<userroleentity> roles = new arraylist<userroleentity>();             roles.add(userroleentity);             userentity.setroles(new hashset<userroleentity>(roles));              return userentity;         }       } 

jpa_dao class:

        @name("userdao")     @stateless     @autocreate     public class jpauserdaoimpl implements userdao {          private static final long serialversionuid = -6173881454668735683l;          @persistencecontext(unitname = "clrp")         private entitymanager entitymanager;          logger logger = logger.getlogger(this.getclass());          public void setentitymanager(entitymanager em) {             this.entitymanager = em;         }           public integer saveorupdate(userentity newuser) {             entitymanager.merge(newuser);             return newuser.getuserid();         }          }     } 


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -