AdminBean adminBean = getAdminBean(request);
Site site = adminBean.getSite();
initSiteProfiles(form, site);
ContactUs contactUs = new ContactUs();
if (!insertMode) {
contactUs = ContactUsDAO.load(site.getSiteId(), Format.getLong(form.getContactUsId()));
}
ActionMessages errors = validate(form, site.getSiteId());
if (errors.size() != 0) {
saveMessages(request, errors);
initSearchInfo(form, site.getSiteId());
return mapping.findForward("error");
}
if (insertMode) {
contactUs.setSite(site);
contactUs.setRecCreateBy(adminBean.getUser().getUserId());
contactUs.setRecCreateDatetime(new Date(System.currentTimeMillis()));
}
contactUs.setActive(new Character(Constants.ACTIVE_NO));
if (form.getActive() != null && form.getActive().equals(String.valueOf(Constants.ACTIVE_YES))) {
contactUs.setActive(new Character(Constants.ACTIVE_YES));
}
contactUs.setContactUsEmail(form.getContactUsEmail());
contactUs.setContactUsPhone(form.getContactUsPhone());
contactUs.setContactUsAddressLine1(form.getContactUsAddressLine1());
contactUs.setContactUsAddressLine2(form.getContactUsAddressLine2());
contactUs.setContactUsCityName(form.getContactUsCityName());
contactUs.setContactUsStateCode(form.getContactUsStateCode());
String stateName = Utility.getStateName(site.getSiteId(), form.getContactUsStateCode());
if (stateName == null) {
stateName = "";
}
contactUs.setContactUsStateName(stateName);
contactUs.setContactUsCountryCode(form.getContactUsCountryCode());
contactUs.setContactUsCountryName(Utility.getCountryName(site.getSiteId(), form.getContactUsCountryCode()));
contactUs.setContactUsZipCode(form.getContactUsZipCode());
if (!Format.isNullOrEmpty(form.getSeqNum())) {
contactUs.setSeqNum(Format.getIntObj(form.getSeqNum()));
}
else {
contactUs.setSeqNum(new Integer(0));
}
contactUs.setRecUpdateBy(adminBean.getUser().getUserId());
contactUs.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
if (form.isSiteProfileClassDefault()) {
saveDefault(contactUs, form, adminBean);
}
else {
saveLanguage(contactUs, form, adminBean);
}
if (insertMode) {
em.persist(contactUs);
}
else {
// em.update(contactUs);
}
form.setContactUsId(Format.getLong(contactUs.getContactUsId()));
form.setMode("U");
initSearchInfo(form, site.getSiteId());
FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
return mapping.findForward("success");
}