org.cap.selfService.myAccount.ui.bean.AddressBookBackingBean.java Source code

Java tutorial

Introduction

Here is the source code for org.cap.selfService.myAccount.ui.bean.AddressBookBackingBean.java

Source

package org.cap.selfService.myAccount.ui.bean;

import java.io.IOException;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.faces.application.FacesMessage;
import javax.faces.application.NavigationHandler;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseEvent;
import javax.faces.event.ValueChangeEvent;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;

import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.share.ADFContext;
import oracle.adf.view.rich.component.rich.RichDialog;
import oracle.adf.view.rich.component.rich.RichPopup;
import oracle.adf.view.rich.component.rich.RichQuery;
import oracle.adf.view.rich.component.rich.input.RichInputListOfValues;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.input.RichSelectItem;
import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;
import oracle.adf.view.rich.component.rich.input.RichSelectOneRadio;
import oracle.adf.view.rich.component.rich.layout.RichPanelFormLayout;
import oracle.adf.view.rich.component.rich.layout.RichPanelGroupLayout;
import oracle.adf.view.rich.component.rich.layout.RichPanelHeader;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import oracle.adf.view.rich.component.rich.nav.RichCommandImageLink;
import oracle.adf.view.rich.component.rich.nav.RichCommandLink;
import oracle.adf.view.rich.component.rich.output.RichImage;
import oracle.adf.view.rich.component.rich.output.RichOutputLabel;
import oracle.adf.view.rich.component.rich.output.RichOutputText;

import oracle.adf.view.rich.context.AdfFacesContext;
import oracle.adf.view.rich.event.DialogEvent;
import oracle.adf.view.rich.event.LaunchPopupEvent;
import oracle.adf.view.rich.event.PopupCanceledEvent;

import oracle.adf.view.rich.event.ReturnPopupEvent;

import oracle.adf.view.rich.render.ClientEvent;

import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;

import oracle.javatools.resourcebundle.BundleFactory;

import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewCriteria;
import oracle.jbo.ViewCriteriaRow;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.uicli.binding.JUCtrlAttrsBinding;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.cap.selfService.selfRegistration.selfRegModel.util.TrilliumValidations;
import org.cap.selfService.myAccount.ui.util.JSFUtils;
import org.cap.selfService.myAccount.ui.util.LoadPersonData;
import org.cap.selfService.selfRegistration.selfRegModel.bean.PhoneValues;

public class AddressBookBackingBean {
    private RichSelectOneRadio addressOptionsRdBtn;
    private RichPopup businessAddressConfirmPopup;
    private RichPopup homeAddressConfirmPopup;

    private RichOutputLabel homeOutputLabel;
    private RichOutputLabel businessOutputLabel;

    private RichInputText partyIdIpTx;

    private RichInputListOfValues partyNameIpLOV;
    private RichInputText address1PartyIpTx;
    private RichInputText address2PartyIpTx;
    private RichInputText address3PartyIpTx;
    private RichInputText address4PartyIpTx;
    private RichSelectOneChoice countryPartySelOneCho;
    private RichSelectOneChoice statesUSPartySelOneCho;
    private RichSelectOneChoice statesAUPartySelOneCho;
    private RichSelectOneChoice statesCAPartySelOneCho;
    private RichInputText statesOthersPartyIpTx;
    private RichInputText cityPartyIpTx;
    private RichInputText postalCodePartyIpTx;
    private RichInputText countyPartyIpTx;
    private RichInputText phonePartyIpTx;
    private RichInputText faxExtPartyIpTx;
    private RichInputText faxPartyIpTx;
    private RichInputText phoneExtPartyIpTx;

    private RichInputText institutionNameBusNewInstIpTx;
    private RichInputText address1BusNewInstIpTx;
    private RichInputText address2BusNewInstIpTx;
    private RichInputText address3BusNewInstIpTx;
    private RichInputText address4BusNewInstIpTx;
    private RichSelectOneChoice countryBusNewInstSelOneCho;
    private RichSelectOneChoice statesUSNewInstSelOneCho;
    private RichSelectOneChoice statesAUNewInstSelOneCho;
    private RichSelectOneChoice statesCANewInstSelOneCho;
    private RichInputText statesOtherNewInstIpTx;
    private RichInputText cityBusNewInstIpTx;
    private RichInputText postalCodeBusNewInstIpTx;
    private RichInputText countyBusNewInstIpTx;
    private RichInputText phoneBusNewInstIpTx;
    private RichInputText phoneExtBusNewInstIpTx;
    private RichInputText faxBusNewInstIpTx;
    private RichInputText faxExtBusNewInstIpTx;

    private RichInputText address1HomeIpTx;
    private RichInputText address2HomeIpTx;
    private RichInputText address3HomeIpTx;
    private RichInputText address4HomeIpTx;
    private RichSelectOneChoice countryHomeSelOneCho;
    private RichSelectOneChoice statesUSHomeSelOneCho;
    private RichSelectOneChoice statesAUHomeSelOneCho;
    private RichSelectOneChoice statesCAHomeSelOneCho;
    private RichInputText statesOtherHomeIpTx;
    private RichInputText cityHomeIpTx;
    private RichInputText postalCodeHomeIpTx;
    private RichInputText countyHomeIpTx;
    private RichInputText phoneHomeIpTx;
    private RichInputText faxHomeIpTx;

    TrilliumValidations tv = new TrilliumValidations();

    private RichPopup browseInstAddressConfirmPopup;
    private RichPopup newInstAddressConfirmPopup;

    private RichCommandLink browseInstCmdLnk;
    private RichOutputLabel browseInstOpLbl;
    private RichPanelFormLayout browseInstPnlFrm;
    private RichPanelFormLayout newInstPnlFrm;
    private RichCommandLink newInstCmdLnk;
    private RichOutputText newInstOpLbl;

    private RichPanelGroupLayout homeAddressPnlGrp;
    private RichPanelGroupLayout businessAddressPnlGrp;
    private static final String RESOURCE_BUNDLE_NAME = "view.MyAccountViewControllerBundle";
    ResourceBundle resourceBundle = BundleFactory.getBundle(RESOURCE_BUNDLE_NAME);

    DCBindingContainer bindings = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
    private RichSelectOneRadio institutionOptionsRdBtn;

    final Log sLog = LogFactory.getLog(this.getClass());

    String expr1 = "^[1-9]\\d{2}-\\d{3}-\\d{4}$";
    String expr2 = "^[1-9]\\d{9}$";
    String expr4 = "^\\d{5}(-?(?!(0000|9999))\\d{4})?$";
    String expr5 = "^[a-zA-Z]\\d[a-zA-Z]\\s?\\d[a-zA-Z]\\d$";
    private RichInputText partyNumberIpTx;
    private RichPanelGroupLayout floridaLicensePnlGrp;

    private RichPanelGroupLayout licensePnlGrp;
    private RichInputText licenseNumberIpTx;
    private RichImage floridaLicenseImgLbl;
    private RichCommandImageLink floridaLicenseCmdImgLnk;
    private RichPopup cancelChangesConfirmPopup;
    private RichPanelFormLayout updateNoteInstPnlFrm;
    private RichPanelFormLayout dontUpdateNoteInstPnlFrm;
    private RichSelectItem businessAddrOptionRdBtn;
    private RichSelectItem homeAddrOptionRdBtn;
    private RichSelectItem bothAddrOptionRdBtn;
    private RichPanelGroupLayout buttonsPnlGrp;
    private RichSelectOneRadio addressPreferenceRdBtn;

    public AddressBookBackingBean() {
    }

    public void browseInstActionListener(ActionEvent actionEvent) {

        //check whether new institution info flds are not null then only display the confirmation   

        if (getInstitutionNameBusNewInstIpTx().getValue() != null
                && !getInstitutionNameBusNewInstIpTx().getValue().equals("")) {

            //priya
            showPopup(this.getBrowseInstAddressConfirmPopup(), actionEvent.getComponent());
        } else {
            //delete the new inst related info and disable the partyinfo fields            

            disablePartyInfoFlds();
            enableBusBrowstInstLayoutFlds();
            getInstitutionOptionsRdBtn().setValue("browseInst");
            disableBusNewInstLayoutFlds();
            clearNewInstitutionInformation();
            floridaFlds();
        }

    }

    public void newInstActionListener(ActionEvent actionEvent) {
        if (getPartyNameIpLOV().getValue() != null
                && (!getPartyNameIpLOV().getValue().toString().trim().equals(""))) {

            showPopup(this.getNewInstAddressConfirmPopup(), actionEvent.getComponent());

        } else {
            //delete the party related info    
            enableBusNewInstLayoutFlds();
            getInstitutionOptionsRdBtn().setValue("newInst");
            disableBusBrowstInstLayoutFlds();
            clearPartyInformation();
            floridaFlds();
        }
    }

    public void addressOptionRdBtnValueChangeListener(ValueChangeEvent valueChangeEvent) {

        getAddressOptionsRdBtn().setImmediate(false);
        Object value = valueChangeEvent.getNewValue();
        System.out.println("value is " + value);
        if (value != null) {
            if (value.equals("businesshome")) {
                enableHomeLayoutFlds();
                enableBusinessLayoutFlds();
                if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {
                    if (getPartyNameIpLOV().getValue() != null
                            && getPartyNameIpLOV().getValue().toString().trim().equals("")) {
                        disablePartyInfoFlds();
                    }
                }
            } else if (value.equals("business")) {
                if (getAddress1HomeIpTx().getValue() != null && !(getAddress1HomeIpTx().getValue().equals(""))) {
                    getAddressOptionsRdBtn().setImmediate(true);
                    showPopup(this.getBusinessAddressConfirmPopup(), valueChangeEvent.getComponent());
                } else {
                    disableHomeLayoutFlds();
                    enableBusinessLayoutFlds();
                    floridaFlds();
                    if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {

                        if (getPartyNameIpLOV() != null && getPartyNameIpLOV().getValue() != null
                                && getPartyNameIpLOV().getValue().toString().trim().equals("")) {

                            disablePartyInfoFlds();
                            disableBusNewInstLayoutFlds();
                        }
                    }
                    if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {

                        disablePartyInfoFlds();
                        disableBusBrowstInstLayoutFlds();
                    }
                    clearHomeInformation();
                }
            }

            else if (value.equals("home")) {

                if ((getInstitutionOptionsRdBtn().getValue().equals("browseInst")
                        && getPartyNameIpLOV().getValue() != null && !getPartyNameIpLOV().getValue().equals(" "))
                        || (getInstitutionOptionsRdBtn().getValue().equals("newInst")
                                && getInstitutionNameBusNewInstIpTx().getValue() != null
                                && !getInstitutionNameBusNewInstIpTx().getValue().equals(""))) {

                    getAddressOptionsRdBtn().setImmediate(true);
                    showPopup(this.getHomeAddressConfirmPopup(), valueChangeEvent.getComponent());
                } else {
                    enableHomeLayoutFlds();
                    disableBusinessLayoutFlds();
                    //  clearPartyInformation();
                    clearNewInstitutionInformation();
                    floridaFlds();
                }
            }
        }
    }

    public void newInstAddressConfirmDialogListener(DialogEvent dialogEvent) {
        if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {

            //delete the party related info             
            enableBusNewInstLayoutFlds();
            getInstitutionOptionsRdBtn().setValue("newInst");
            disableBusBrowstInstLayoutFlds();
            clearPartyInformation();
            floridaFlds();
        }
    }

    public void browseInstAddressConfirmDialogListener(DialogEvent dialogEvent) {
        if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {

            disablePartyInfoFlds();
            enableBusBrowstInstLayoutFlds();
            getInstitutionOptionsRdBtn().setValue("browseInst");
            disableBusNewInstLayoutFlds();
            clearNewInstitutionInformation();
            floridaFlds();
        }
    }

    public void deleteNewInstAddrPopupCancelListener(PopupCanceledEvent popupCanceledEvent) {

        getInstitutionOptionsRdBtn().setValue("newInst");
    }

    public void deleteBrowseInstAddrPopupCancelListener(PopupCanceledEvent popupCanceledEvent) {

        getInstitutionOptionsRdBtn().setValue("browseInst");
    }

    public void businessAddressConfirmDialogListener(DialogEvent dialogEvent) {

        if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {
            getAddressOptionsRdBtn().setValue("business");
            enableBusinessLayoutFlds();
            if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {
                if (getPartyNameIpLOV() != null
                        && (getPartyNameIpLOV().getValue() != null && getPartyNameIpLOV().getValue().equals(""))) {
                    disablePartyInfoFlds();
                }
                disableBusNewInstLayoutFlds(); //disable party info flds
            }
            if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {
                disablePartyInfoFlds();
                disableBusBrowstInstLayoutFlds();
            }
            disableHomeLayoutFlds();
            clearHomeInformation();
            floridaFlds();
        }
    }

    public void homeAddressConfirmDialogListener(DialogEvent dialogEvent) {

        if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {

            getAddressOptionsRdBtn().setValue("home");
            disableBusinessLayoutFlds();
            clearNewInstitutionInformation();
            enableHomeLayoutFlds();

            clearPartyInformation();

            floridaFlds();
        }
    }

    public void deleteBusinessAddrPopupCancelListener(PopupCanceledEvent popupCanceledEvent) {

        if (getBusinessAddressPnlGrp().isVisible() && getHomeAddressPnlGrp().isVisible()) {
            getAddressOptionsRdBtn().setValue("businesshome");
        } else if (getBusinessAddressPnlGrp().isVisible()) {
            getAddressOptionsRdBtn().setValue("business");
        }

    }

    public void deleteHomeAddrPopupCancelListener(PopupCanceledEvent popupCanceledEvent) {

        if (getHomeAddressPnlGrp().isVisible() && getBusinessAddressPnlGrp().isVisible()) {
            getAddressOptionsRdBtn().setValue("businesshome");
        } else if (getHomeAddressPnlGrp().isVisible()) {
            getAddressOptionsRdBtn().setValue("home");
        }
    }

    public String validateReqFlds() {
        FacesContext context = FacesContext.getCurrentInstance();

        String status = "sucess";
        try {
            if (getAddressOptionsRdBtn().getValue().equals("business")
                    || (getAddressOptionsRdBtn().getValue().equals("businesshome"))) {
                if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {

                    if (getPartyNameIpLOV().getValue() == null
                            || (getPartyNameIpLOV().getValue() != null
                                    && getPartyNameIpLOV().getValue().toString().trim().equals(""))
                            || (getPartyNameIpLOV().getValue() != null
                                    && getPartyNameIpLOV().getValue().toString().trim().equals(""))) {

                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_INSTNAME_REQ"));
                        context.addMessage(getPartyNameIpLOV().getClientId(context), message);
                    } else {
                        if (getAddress1PartyIpTx().getValue() == null || (getAddress1PartyIpTx().getValue() != null
                                && getAddress1PartyIpTx().getValue().toString().trim().equals(""))) {

                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_ADDR1_REQ"));
                            context.addMessage(getAddress1PartyIpTx().getClientId(context), message);
                        }
                        if (getCountryPartySelOneCho().getValue() == null
                                || (getCountryPartySelOneCho().getValue() != null
                                        && getCountryPartySelOneCho().getValue().equals(""))) {

                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_COUNTRY_REQ"));
                            context.addMessage(getCountryPartySelOneCho().getClientId(context), message);
                        }
                        if (getCityPartyIpTx().getValue() == null || (getCityPartyIpTx().getValue() != null
                                && getCityPartyIpTx().getValue().toString().trim().equals(""))) {

                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_CITY_REQ"));
                            context.addMessage(getCityPartyIpTx().getClientId(context), message);
                        }
                        if (getPhonePartyIpTx().getValue() == null || (getPhonePartyIpTx().getValue() != null
                                && getPhonePartyIpTx().getValue().toString().trim().equals(""))) {

                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_PHONE_REQ"));
                            context.addMessage(getPhonePartyIpTx().getClientId(context), message);
                        }

                        if (getPhonePartyIpTx().getValue() != null
                                && !getPhonePartyIpTx().getValue().toString().trim().equals("")) {
                            String phoneStatus = validatePartyPhone();
                            if (phoneStatus.equals("failure")) {
                                status = "failure";
                            }
                        }
                        if (getFaxPartyIpTx().getValue() != null
                                && !getFaxPartyIpTx().getValue().toString().trim().equals("")) {
                            String faxStatus = validatePartyFax();
                            if (faxStatus.equals("failure")) {
                                status = "failure";
                            }
                        }
                        if (getCountryPartySelOneCho().getValue() != null) {

                            if (getCountryPartySelOneCho().getValue().equals("US")) {

                                if (getStatesUSPartySelOneCho().getValue() == null
                                        || (getStatesUSPartySelOneCho().getValue() != null
                                                && getStatesUSPartySelOneCho().getValue().equals(""))) {

                                    status = "failure";
                                    FacesMessage message = new FacesMessage();
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                                    context.addMessage(getStatesUSPartySelOneCho().getClientId(context), message);
                                }
                                if (getPostalCodePartyIpTx().getValue() == null
                                        || (getPostalCodePartyIpTx().getValue() != null && getPostalCodePartyIpTx()
                                                .getValue().toString().trim().equals(""))) {

                                    status = "failure";
                                    FacesMessage message = new FacesMessage();
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                                    context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                                }
                            }
                            if (getCountryPartySelOneCho().getValue() != null
                                    && getCountryPartySelOneCho().getValue().equals("AU")) {

                                if (getStatesAUPartySelOneCho().getValue() == null
                                        || (getStatesAUPartySelOneCho().getValue() != null
                                                && getStatesAUPartySelOneCho().getValue().equals(""))) {

                                    status = "failure";
                                    FacesMessage message = new FacesMessage();
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                                    context.addMessage(getStatesAUPartySelOneCho().getClientId(context), message);
                                }
                            }
                            if (getCountryPartySelOneCho().getValue() != null
                                    && getCountryPartySelOneCho().getValue().equals("CA")) {
                                if (getStatesCAPartySelOneCho().getValue() == null
                                        || (getStatesCAPartySelOneCho().getValue() != null
                                                && getStatesCAPartySelOneCho().getValue().equals(""))) {

                                    status = "failure";
                                    FacesMessage message = new FacesMessage();
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                                    context.addMessage(getStatesCAPartySelOneCho().getClientId(context), message);
                                }
                                if (getPostalCodePartyIpTx().getValue() == null
                                        || (getPostalCodePartyIpTx().getValue() != null && getPostalCodePartyIpTx()
                                                .getValue().toString().trim().equals(""))) {

                                    status = "failure";
                                    FacesMessage message = new FacesMessage();
                                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                    message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                                    context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                                }
                            }

                            //party zipcode validation
                            if (getPostalCodePartyIpTx().getValue() != null
                                    && !getPostalCodePartyIpTx().getValue().toString().trim().equals("")) {
                                FacesMessage message = new FacesMessage();
                                Pattern p4 = Pattern.compile(expr4);
                                Pattern p5 = Pattern.compile(expr5);
                                Matcher m4 = p4.matcher((String) getPostalCodePartyIpTx().getValue());
                                Matcher m5 = p5.matcher((String) getPostalCodePartyIpTx().getValue());
                                if (getCountryPartySelOneCho() != null
                                        && getCountryPartySelOneCho().getValue().equals("US")) {
                                    if (!m4.find()) {
                                        message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                        context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                                        status = "failure";
                                    }
                                }
                                if (getCountryPartySelOneCho() != null
                                        && getCountryPartySelOneCho().getValue().equals("CA")) {
                                    if (!m5.find()) {
                                        message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                        context.addMessage(getPostalCodePartyIpTx().getClientId(context), message);
                                        status = "failure";
                                    }
                                }
                            }
                        }
                    }
                }
                if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {

                    if (getInstitutionNameBusNewInstIpTx().getValue() == null
                            || (getInstitutionNameBusNewInstIpTx().getValue() != null
                                    && getInstitutionNameBusNewInstIpTx().getValue().toString().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_INSTNAME_REQ"));
                        context.addMessage(getInstitutionNameBusNewInstIpTx().getClientId(context), message);
                    }
                    if (getAddress1BusNewInstIpTx().getValue() == null
                            || (getAddress1BusNewInstIpTx().getValue() != null
                                    && getAddress1BusNewInstIpTx().getValue().toString().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_ADDR1_REQ"));
                        context.addMessage(getAddress1BusNewInstIpTx().getClientId(context), message);
                    }
                    if (getCountryBusNewInstSelOneCho().getValue() == null
                            || (getCountryBusNewInstSelOneCho().getValue() != null
                                    && getCountryBusNewInstSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_COUNTRY_REQ"));
                        context.addMessage(getCountryBusNewInstSelOneCho().getClientId(context), message);
                    }
                    if (getCityBusNewInstIpTx().getValue() == null || (getCityBusNewInstIpTx().getValue() != null
                            && getCityBusNewInstIpTx().getValue().toString().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_CITY_REQ"));
                        context.addMessage(getCityBusNewInstIpTx().getClientId(context), message);
                    }
                    if (getPhoneBusNewInstIpTx().getValue() == null || (getPhoneBusNewInstIpTx().getValue() != null
                            && getPhoneBusNewInstIpTx().getValue().toString().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("BUS_PHONE_REQ"));
                        context.addMessage(getPhoneBusNewInstIpTx().getClientId(context), message);
                    }
                    if (getPhoneBusNewInstIpTx().getValue() != null
                            && !getPhoneBusNewInstIpTx().getValue().toString().equals("")) {
                        String phoneStatus = validateNewInstPhone();
                        if (phoneStatus.equals("failure")) {
                            status = "failure";
                        }
                    }
                    if (getFaxBusNewInstIpTx().getValue() != null
                            && !getFaxBusNewInstIpTx().getValue().toString().equals("")) {
                        String faxStatus = validateNewInstFax();
                        if (faxStatus.equals("failure")) {
                            status = "failure";
                        }
                    }
                    if (getCountryBusNewInstSelOneCho().getValue().equals("US")) {
                        if (getStatesUSNewInstSelOneCho().getValue() == null
                                || (getStatesUSNewInstSelOneCho().getValue() != null
                                        && getStatesUSNewInstSelOneCho().getValue().equals(""))) {
                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                            context.addMessage(getStatesUSNewInstSelOneCho().getClientId(context), message);
                        }
                        if (getPostalCodeBusNewInstIpTx().getValue() == null
                                || (getPostalCodeBusNewInstIpTx().getValue() != null
                                        && getPostalCodeBusNewInstIpTx().getValue().toString().trim().equals(""))) {
                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                            context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                        }
                    }
                    if (getCountryBusNewInstSelOneCho().getValue().equals("AU")) {
                        if (getStatesAUNewInstSelOneCho().getValue() == null
                                || (getStatesAUNewInstSelOneCho().getValue() != null
                                        && getStatesAUNewInstSelOneCho().getValue().equals(""))) {
                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                            context.addMessage(getStatesAUNewInstSelOneCho().getClientId(context), message);
                        }
                    }
                    if (getCountryBusNewInstSelOneCho().getValue().equals("CA")) {
                        if (getStatesCANewInstSelOneCho().getValue() == null
                                || (getStatesCANewInstSelOneCho().getValue() != null
                                        && getStatesCANewInstSelOneCho().getValue().equals(""))) {
                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_STATES_REQ"));
                            context.addMessage(getStatesCANewInstSelOneCho().getClientId(context), message);
                        }
                        if (getPostalCodeBusNewInstIpTx().getValue() == null
                                || (getPostalCodeBusNewInstIpTx().getValue() != null
                                        && getPostalCodeBusNewInstIpTx().getValue().toString().equals(""))) {
                            status = "failure";
                            FacesMessage message = new FacesMessage();
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            message.setDetail(resourceBundle.getString("BUS_ZIP_REQ"));
                            context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                        }
                    }
                    //new inst zipcode validation
                    if (getPostalCodeBusNewInstIpTx().getValue() != null
                            && !getPostalCodeBusNewInstIpTx().getValue().toString().trim().equals("")) {
                        FacesMessage message = new FacesMessage();
                        Pattern p4 = Pattern.compile(expr4);
                        Pattern p5 = Pattern.compile(expr5);
                        Matcher m4 = p4.matcher((String) getPostalCodeBusNewInstIpTx().getValue());
                        Matcher m5 = p5.matcher((String) getPostalCodeBusNewInstIpTx().getValue());
                        if (getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals("US")) {
                            if (!m4.find()) {
                                message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                                status = "failure";
                            }
                        }
                        if (getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals("CA")) {
                            if (!m5.find()) {
                                message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                                context.addMessage(getPostalCodeBusNewInstIpTx().getClientId(context), message);
                                status = "failure";
                            }
                        }
                    }
                }
            }
            //home
            if (getAddressOptionsRdBtn().getValue().equals("home")
                    || (getAddressOptionsRdBtn().getValue().equals("businesshome"))) {

                if (getAddress1HomeIpTx().getValue() == null || (getAddress1HomeIpTx().getValue() != null
                        && getAddress1HomeIpTx().getValue().toString().trim().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_ADDR1_REQ"));
                    context.addMessage(getAddress1HomeIpTx().getClientId(context), message);
                }
                if (getCountryHomeSelOneCho().getValue() == null || (getCountryHomeSelOneCho().getValue() != null
                        && getCountryHomeSelOneCho().getValue().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_COUNTRY_REQ"));
                    context.addMessage(getCountryHomeSelOneCho().getClientId(context), message);
                }
                if (getCityHomeIpTx().getValue() == null || (getCityHomeIpTx().getValue() != null
                        && getCityHomeIpTx().getValue().toString().trim().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_CITY_REQ"));
                    context.addMessage(getCityHomeIpTx().getClientId(context), message);
                }
                if (getPhoneHomeIpTx().getValue() == null || (getPhoneHomeIpTx().getValue() != null
                        && getPhoneHomeIpTx().getValue().toString().trim().equals(""))) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("HOME_PHONE_REQ"));
                    context.addMessage(getPhoneHomeIpTx().getClientId(context), message);
                }
                if (getPhoneHomeIpTx().getValue() != null
                        && !getPhoneHomeIpTx().getValue().toString().trim().equals("")) {
                    String phoneStatus = validateHomePhone();
                    if (phoneStatus.equals("failure")) {
                        status = "failure";
                    }
                }
                if (getFaxHomeIpTx().getValue() != null
                        && !getFaxHomeIpTx().getValue().toString().trim().equals("")) {
                    String faxStatus = validateHomeFax();
                    if (faxStatus.equals("failure")) {
                        status = "failure";
                    }
                }
                if (getCountryHomeSelOneCho().getValue().equals("US")) {
                    if (getStatesUSHomeSelOneCho().getValue() == null
                            || (getStatesUSHomeSelOneCho().getValue() != null
                                    && getStatesUSHomeSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("HOME_STATES_REQ"));
                        context.addMessage(getStatesUSHomeSelOneCho().getClientId(context), message);
                    }
                    if (getPostalCodeHomeIpTx().getValue() == null || (getPostalCodeHomeIpTx().getValue() != null
                            && getPostalCodeHomeIpTx().getValue().toString().trim().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("HOME_ZIP_REQ"));
                        context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                    }
                }
                if (getCountryHomeSelOneCho().getValue().equals("AU")) {
                    if (getStatesAUHomeSelOneCho().getValue() == null
                            || (getStatesAUHomeSelOneCho().getValue() != null
                                    && getStatesAUHomeSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("HOME_STATES_REQ"));
                        context.addMessage(getStatesAUHomeSelOneCho().getClientId(context), message);
                    }
                }
                if (getCountryHomeSelOneCho().getValue().equals("CA")) {
                    if (getStatesCAHomeSelOneCho().getValue() == null
                            || (getStatesCAHomeSelOneCho().getValue() != null
                                    && getStatesCAHomeSelOneCho().getValue().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("HOME_STATES_REQ"));
                        context.addMessage(getStatesCAHomeSelOneCho().getClientId(context), message);
                    }
                    if (getPostalCodeHomeIpTx().getValue() == null || (getPostalCodeHomeIpTx().getValue() != null
                            && getPostalCodeHomeIpTx().getValue().toString().trim().equals(""))) {
                        status = "failure";
                        FacesMessage message = new FacesMessage();
                        message.setSeverity(FacesMessage.SEVERITY_ERROR);
                        message.setDetail(resourceBundle.getString("HOME_ZIP_REQ"));
                        context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                    }
                }
                //home zipcode validation
                if (getPostalCodeHomeIpTx().getValue() != null
                        && !getPostalCodeHomeIpTx().getValue().toString().trim().equals("")) {
                    FacesMessage message = new FacesMessage();
                    Pattern p4 = Pattern.compile(expr4);
                    Pattern p5 = Pattern.compile(expr5);
                    Matcher m4 = p4.matcher((String) getPostalCodeHomeIpTx().getValue());
                    Matcher m5 = p5.matcher((String) getPostalCodeHomeIpTx().getValue());
                    if (getCountryHomeSelOneCho() != null && getCountryHomeSelOneCho().getValue().equals("US")) {
                        if (!m4.find()) {

                            message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                            status = "failure";
                        }
                    }
                    if (getCountryHomeSelOneCho() != null && getCountryHomeSelOneCho().getValue().equals("CA")) {
                        if (!m5.find()) {
                            message.setDetail(resourceBundle.getString("ZIPFORMAT"));
                            message.setSeverity(FacesMessage.SEVERITY_ERROR);
                            context.addMessage(getPostalCodeHomeIpTx().getClientId(context), message);
                            status = "failure";
                        }
                    }
                }
            }
            if ((getAddressOptionsRdBtn().getValue().equals("businesshome"))) {
                if (getAddressPreferenceRdBtn().getValue() == null) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail(resourceBundle.getString("ADDR_OPTIONS_REQ"));
                    context.addMessage(getAddressPreferenceRdBtn().getClientId(context), message);
                }
            }

            if (getLicenseNumberIpTx().getValue() != null && !getLicenseNumberIpTx().getValue().equals("")
                    && !getLicenseNumberIpTx().isReadOnly()) {
                String expression = "^[A-Za-z][A-Za-z][0-9]{1,20}$";
                Pattern p1 = Pattern.compile(expression);
                Matcher m1 = p1.matcher((String) getLicenseNumberIpTx().getValue());
                if (!m1.find()) {
                    status = "failure";
                    FacesMessage message = new FacesMessage();
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    message.setDetail("Invalid License Number");
                    context.addMessage(getLicenseNumberIpTx().getClientId(context), message);
                }
            }
        } catch (MissingResourceException e) {
            sLog.debug(e.getMessage(), e);
            e.printStackTrace();
        } catch (Exception e) {
            sLog.debug(e.getMessage(), e);
            e.printStackTrace();
        }
        return status;
    }

    public String updateAddressBook() {

        sLog.info("updateAddressBook method  in AddressBookBackingBean");
        String validateReqFlds = validateReqFlds();
        System.out.println("validateReqFlds is " + validateReqFlds);
        if (validateReqFlds != null && !validateReqFlds.equals("sucess")) {
            return null;
        }

        LoadPersonData load = new LoadPersonData();
        load.loadPersonalDetails();
        load.loadAndUpdatePreferences();
        System.out.println("getAddressOptionsRdBtn().getValue() is " + getAddressOptionsRdBtn().getValue());

        JUCtrlAttrsBinding homePrefUpdt = (JUCtrlAttrsBinding) bindings.findNamedObject("PreferredFlagHomeUpDt");
        JUCtrlAttrsBinding busPrefUpdt = (JUCtrlAttrsBinding) bindings.findNamedObject("PreferredFlagBusUpDt");

        if (getAddressOptionsRdBtn().getValue() != null) {
            if (getAddressOptionsRdBtn().getValue().equals("home")) {
                loadAndUpdateHomeInfoBindings();
                deleteBusinessInfoBindings();
                homePrefUpdt.setAttribute("PreferredFlag", "Y");
            } else if (getAddressOptionsRdBtn().getValue().equals("business")) {
                loadAndUpdateBusinessInfoBindings();
                deleteHomeInfoBindings();
                busPrefUpdt.setAttribute("PreferredFlag", "Y");
            } else if (getAddressOptionsRdBtn().getValue().equals("businesshome")) {
                loadAndUpdateBusinessInfoBindings();
                loadAndUpdateHomeInfoBindings();
                if (getAddressPreferenceRdBtn().getValue() != null
                        && getAddressPreferenceRdBtn().getValue().equals("home")) {
                    homePrefUpdt.setAttribute("PreferredFlag", "Y");
                    busPrefUpdt.setAttribute("PreferredFlag", "N");
                } else {
                    busPrefUpdt.setAttribute("PreferredFlag", "Y");
                    homePrefUpdt.setAttribute("PreferredFlag", "N");
                }
            }
            // setPreferredFlag(); 
            JUCtrlAttrsBinding flLicenseUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("LicenseNumberUpDt");
            if (getLicenseNumberIpTx() != null && getLicenseNumberIpTx().getValue() != null
                    && !getLicenseNumberIpTx().getValue().toString().trim().equals("")) {
                flLicenseUpDt.setAttribute("LicenseNumber", getLicenseNumberIpTx().getValue());
            } else {
                JUCtrlAttrsBinding flLicenseGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LicenseNumberGet");
                flLicenseUpDt.setAttribute("LicenseNumber", flLicenseGet.getAttribute("LicenseNumber"));
            }

            OperationBinding opBinding = bindings.getOperationBinding("processUpDt");
            opBinding.execute();

            //Proper confirmation text to be shown     
            JUCtrlAttrsBinding validateAddressFlagBus = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("IsBusAddressValidated");
            JUCtrlAttrsBinding validateAddressFlagHome = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("IsHomeAddressValidated");
            String busAddrValidated = (String) validateAddressFlagBus.getAttribute("IsAddressValidated");
            String homeAddrValidated = (String) validateAddressFlagHome.getAttribute("IsAddressValidated");
            Map requestScope = ADFContext.getCurrent().getRequestScope();
            if ((busAddrValidated != null && busAddrValidated.equals("N"))
                    || (homeAddrValidated != null && homeAddrValidated.equals("N"))
                    || getInstitutionOptionsRdBtn().getValue().equals("newInst")) {
                // getNewInstConfirmationTxt().setVisible(true);                
                requestScope.put("CONFIRMATION", "DELAY");

            } else {
                requestScope.put("CONFIRMATION", "IMMEDIATE");
            }
        }
        return "myAccount";
    }

    public void loadAndUpdateBusinessInfoBindings() {
        /* Business Address,Phone and Fax Bindings  */
        sLog.info("loadAndUpdateBusinessInfoBindings method  in AddressBookBackingBean");
        String amDef = "org.cap.myAccount.myAccountModel.MyAccountAM";
        String config = "MyAccountAMLocal";
        ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
        try {
            JUCtrlAttrsBinding addressStatusFlagBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("AddressStatusFlagBusUpDt");
            JUCtrlAttrsBinding institutionIDBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("InstitutionIDBusUpDt");
            JUCtrlAttrsBinding institutionNameBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("InstitutionNameBusUpDt");

            JUCtrlAttrsBinding partySiteIDBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PartySiteIDBusUpDt");
            JUCtrlAttrsBinding locationIDBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("LocationIDBusUpDt");
            JUCtrlAttrsBinding address1BusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address1BusUpDt");
            JUCtrlAttrsBinding address2BusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address2BusUpDt");

            JUCtrlAttrsBinding address3BusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3BusUpDt");

            JUCtrlAttrsBinding address4BusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address4BusUpDt");

            JUCtrlAttrsBinding countryBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("CountryBusUpDt");
            JUCtrlAttrsBinding stateBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("StateBusUpDt");
            JUCtrlAttrsBinding cityBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("CityBusUpDt");
            JUCtrlAttrsBinding postalCodeBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PostalCodeBusUpDt");
            JUCtrlAttrsBinding countyBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("CountyBusUpDt");

            JUCtrlAttrsBinding validateAddressFlagBus = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("IsBusAddressValidated");

            JUCtrlAttrsBinding phoneIDBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDBusUpDt");
            JUCtrlAttrsBinding phoneCountryCodeBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PhoneCountryCodeBusUpDt");
            JUCtrlAttrsBinding phoneAreaCodeBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PhoneAreaCodeBusUpDt");
            JUCtrlAttrsBinding phoneNumBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PhoneNumberBusUpDt");
            JUCtrlAttrsBinding phoneRawNumberBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PhoneRawNumberBusUpDt");
            JUCtrlAttrsBinding phoneExtBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PhoneExtensionBusUpDt");
            JUCtrlAttrsBinding phoneStatusFlagBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PhoneStatusFlagBusUpDt");

            JUCtrlAttrsBinding faxIDBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDBusUpDt");
            JUCtrlAttrsBinding faxCountryCodeBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("FaxCountryCodeBusUpDt");
            JUCtrlAttrsBinding faxAreaCodeBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("FaxAreaCodeBusUpDt");
            JUCtrlAttrsBinding faxNumBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxNumberBusUpDt");
            JUCtrlAttrsBinding faxRawNumberBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("FaxRawNumberBusUpDt");
            JUCtrlAttrsBinding faxExtBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxExtensionBusUpDt");
            JUCtrlAttrsBinding faxStatusFlagBusUpDt = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("FaxStatusFlagBusUpDt");

            JUCtrlAttrsBinding partySiteIDBusGet = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("PartySiteIDBusGet");
            JUCtrlAttrsBinding locationIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDBusGet");

            if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {
                //  System.out.println("I am inside load browse inst");
                if (getCountryPartySelOneCho().getValue().equals("US")) {
                    String busAddrValid = validateAndStandardiseBusinessAddress();
                    if (busAddrValid != null && busAddrValid.equals("sucess"))
                        validateAddressFlagBus.setAttribute("IsAddressValidated", "Y");
                    else
                        validateAddressFlagBus.setAttribute("IsAddressValidated", "N");
                } // end of else for non US Countries
                if (partySiteIDBusGet != null && locationIDBusGet != null) {
                    partySiteIDBusUpDt.setAttribute("PartySiteID", partySiteIDBusGet.getAttribute("PartySiteID"));
                    locationIDBusUpDt.setAttribute("LocationID", locationIDBusGet.getAttribute("LocationID"));
                }

                JUCtrlAttrsBinding phoneIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDBusGet");
                JUCtrlAttrsBinding faxIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDBusGet");

                String state = "";
                // to check changes for foreign address
                institutionIDBusUpDt.setAttribute("InstitutionID", getPartyIdIpTx().getValue());
                institutionNameBusUpDt.setAttribute("InstitutionName", getPartyNameIpLOV().getValue());
                address1BusUpDt.setAttribute("Address1", getAddress1PartyIpTx().getValue());
                address2BusUpDt.setAttribute("Address2", getAddress2PartyIpTx().getValue());
                address3BusUpDt.setAttribute("Address3", getAddress3PartyIpTx().getValue());
                address4BusUpDt.setAttribute("Address4", getAddress4PartyIpTx().getValue());
                countryBusUpDt.setAttribute("Country", getCountryPartySelOneCho().getValue());
                if (getCountryPartySelOneCho().getValue().equals("US")) {
                    stateBusUpDt.setAttribute("State", getStatesUSPartySelOneCho().getValue());
                }
                if (getCountryPartySelOneCho().getValue().equals("AU")) {
                    stateBusUpDt.setAttribute("State", getStatesAUPartySelOneCho().getValue());
                    state = (String) getStatesAUPartySelOneCho().getValue();
                }
                if (getCountryPartySelOneCho().getValue().equals("CA")) {
                    stateBusUpDt.setAttribute("State", getStatesCAPartySelOneCho().getValue());
                    state = (String) getStatesCAPartySelOneCho().getValue();
                }
                if (!getCountryPartySelOneCho().getValue().equals("US")
                        && !getCountryPartySelOneCho().getValue().equals("AU")
                        && !getCountryPartySelOneCho().getValue().equals("CA")) {
                    stateBusUpDt.setAttribute("State", getStatesOthersPartyIpTx().getValue());
                    state = (String) getStatesOthersPartyIpTx().getValue();
                }
                cityBusUpDt.setAttribute("City", getCityPartyIpTx().getValue());
                postalCodeBusUpDt.setAttribute("PostalCode", getPostalCodePartyIpTx().getValue());
                countyBusUpDt.setAttribute("County", getCountyPartyIpTx().getValue());

                if (phoneIDBusGet != null) {
                    phoneIDBusUpDt.setAttribute("ID", phoneIDBusGet.getAttribute("ID"));
                }

                if (getPhonePartyIpTx().getValue() != null) {
                    //   System.out.println("Phone parsing");
                    PhoneValues phValues = phoneDetails(getCountryPartySelOneCho().getValue().toString(),
                            getPhonePartyIpTx().getValue().toString());
                    if (phValues != null) {
                        String phRawNumber = phValues.getFormattedPhoneNumber();
                        phoneRawNumberBusUpDt.setAttribute("RawNumber", phRawNumber);
                        phoneExtBusUpDt.setAttribute("Extension", getPhoneExtPartyIpTx().getValue());
                    } else {
                        phoneRawNumberBusUpDt.setAttribute("RawNumber", " " + getPhonePartyIpTx().getValue());
                        phoneExtBusUpDt.setAttribute("Extension", getPhoneExtPartyIpTx().getValue());
                    }
                }

                if (faxIDBusGet != null) {
                    faxIDBusUpDt.setAttribute("ID", faxIDBusGet.getAttribute("ID"));
                }
                if (getFaxPartyIpTx().getValue() != null) {
                    PhoneValues phValues = phoneDetails(getCountryPartySelOneCho().getValue().toString(),
                            getFaxPartyIpTx().getValue().toString());
                    if (phValues != null) {
                        String faxRawNumber = phValues.getFormattedPhoneNumber();
                        faxRawNumberBusUpDt.setAttribute("RawNumber", faxRawNumber);
                        faxExtBusUpDt.setAttribute("Extension", getFaxExtPartyIpTx().getValue());
                    } else {
                        faxRawNumberBusUpDt.setAttribute("RawNumber", " " + getFaxPartyIpTx().getValue());
                        faxExtBusUpDt.setAttribute("Extension", getFaxExtPartyIpTx().getValue());
                    }

                }
                if (faxIDBusGet != null
                        && (getFaxPartyIpTx().getValue() != null && getFaxPartyIpTx().getValue().equals(""))) {

                    faxStatusFlagBusUpDt.setAttribute("StatusFlag", "I");
                }

                if (!getCountryPartySelOneCho().getValue().equals("US")) {
                    String foreignAddr1 = "";
                    String foreignAddr2 = "";
                    String foreignAddr3 = "";
                    String foreignAddr4 = "";
                    String foreignState = "";
                    String foreignCity = "";
                    String foreignZipCode = "";

                    JUCtrlAttrsBinding institutionIDBusGet = (JUCtrlAttrsBinding) bindings
                            .findNamedObject("InstitutionIDBusGet");
                    String instIdGet = (String) institutionIDBusGet.getAttribute("InstitutionID");
                    if (!getPartyIdIpTx().getValue().equals(instIdGet)) {

                        ViewObject vo = am.findViewObject("InstitutionLovVO1");
                        ViewCriteria vc = vo.createViewCriteria();
                        ViewCriteriaRow vcr1 = vc.createViewCriteriaRow();
                        vcr1.setAttribute("PartyNumber", getPartyNumberIpTx().getValue());
                        vc.add(vcr1);
                        vo.applyViewCriteria(vc);
                        vo.executeQuery();
                        while (vo.hasNext()) {
                            Row inst = vo.next();
                            foreignAddr1 = (String) inst.getAttribute("Address1");
                            foreignAddr2 = (String) inst.getAttribute("Address2");
                            foreignAddr3 = (String) inst.getAttribute("Address3");
                            foreignAddr4 = (String) inst.getAttribute("Address4");
                            foreignCity = (String) inst.getAttribute("City");
                            foreignState = (String) inst.getAttribute("State");
                            foreignZipCode = (String) inst.getAttribute("PostalCode");
                        }
                    }
                    // The Get the partynumber is same at the time of submitting
                    if (getPartyIdIpTx().getValue().equals(instIdGet)) {

                        JUCtrlAttrsBinding address1BusGet = (JUCtrlAttrsBinding) bindings
                                .findNamedObject("Address1BusGet");
                        JUCtrlAttrsBinding address2BusGet = (JUCtrlAttrsBinding) bindings
                                .findNamedObject("Address2BusGet");
                        JUCtrlAttrsBinding address3BusGet = (JUCtrlAttrsBinding) bindings
                                .findNamedObject("Address3BusGet");
                        JUCtrlAttrsBinding address4BusGet = (JUCtrlAttrsBinding) bindings
                                .findNamedObject("Address4BusGet");
                        JUCtrlAttrsBinding stateBusGet = (JUCtrlAttrsBinding) bindings
                                .findNamedObject("StateBusGet");
                        JUCtrlAttrsBinding cityBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CityBusGet");
                        JUCtrlAttrsBinding postalCodeBusGet = (JUCtrlAttrsBinding) bindings
                                .findNamedObject("PostalCodeBusGet");

                        foreignAddr1 = (String) address1BusGet.getAttribute("Address1");
                        foreignAddr2 = (String) address2BusGet.getAttribute("Address2");
                        foreignAddr3 = (String) address3BusGet.getAttribute("Address3");
                        foreignAddr4 = (String) address4BusGet.getAttribute("Address4");
                        foreignCity = (String) cityBusGet.getAttribute("City");
                        foreignState = (String) stateBusGet.getAttribute("State");
                        foreignZipCode = (String) postalCodeBusGet.getAttribute("PostalCode");
                    }

                    if (foreignAddr2 == null) {
                        foreignAddr2 = "";
                    }
                    if (foreignAddr3 == null) {
                        foreignAddr3 = "";
                    }
                    if (foreignAddr4 == null) {
                        foreignAddr4 = "";
                    }
                    if (foreignState == null) {
                        foreignState = "";
                    }
                    if (foreignZipCode == null) {
                        foreignZipCode = "";
                    }

                    if (getAddress2PartyIpTx().getValue() == null) {
                        getAddress2PartyIpTx().setValue("");
                    }
                    if (getAddress3PartyIpTx().getValue() == null) {
                        getAddress3PartyIpTx().setValue("");
                    }
                    if (getAddress4PartyIpTx().getValue() == null) {
                        getAddress4PartyIpTx().setValue("");
                    }
                    if (getPostalCodePartyIpTx().getValue() == null) {
                        getPostalCodePartyIpTx().setValue("");
                    }
                    if (state == null) {
                        state = "";
                    }
                    if (foreignAddr1.equals(getAddress1PartyIpTx().getValue())
                            && foreignCity.equals(getCityPartyIpTx().getValue()) && foreignState.equals(state)
                            && foreignZipCode.equals(getPostalCodePartyIpTx().getValue())
                            && foreignAddr2.equals(getAddress2PartyIpTx().getValue())
                            && foreignAddr3.equals(getAddress3PartyIpTx().getValue())
                            && foreignAddr4.equals(getAddress4PartyIpTx().getValue())) {
                        validateAddressFlagBus.setAttribute("IsAddressValidated", "Y");

                    } else {
                        validateAddressFlagBus.setAttribute("IsAddressValidated", "N");

                    }
                } // end of if for non US Countries
                  //US Countries need to assign the below flag based on trillium validations

            } // end of browse inst

            else if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {

                if (getCountryBusNewInstSelOneCho().getValue().equals("US")) { // and also trillium return true validation             
                    String busnewInstAddrValid = validateAndStandardiseBusinessAddress();
                    if (busnewInstAddrValid != null && busnewInstAddrValid.equals("sucess")) {
                        validateAddressFlagBus.setAttribute("IsAddressValidated", "Y");
                    } else {
                        validateAddressFlagBus.setAttribute("IsAddressValidated", "N");
                    }
                } else {
                    validateAddressFlagBus.setAttribute("IsAddressValidated", "N");
                }
                institutionNameBusUpDt.setAttribute("InstitutionName",
                        getInstitutionNameBusNewInstIpTx().getValue());
                address1BusUpDt.setAttribute("Address1", getAddress1BusNewInstIpTx().getValue());
                address2BusUpDt.setAttribute("Address2", getAddress2BusNewInstIpTx().getValue());
                address3BusUpDt.setAttribute("Address3", getAddress3BusNewInstIpTx().getValue());
                address4BusUpDt.setAttribute("Address4", getAddress4BusNewInstIpTx().getValue());
                countryBusUpDt.setAttribute("Country", getCountryBusNewInstSelOneCho().getValue());

                if (getCountryBusNewInstSelOneCho().getValue().equals("US")) {
                    stateBusUpDt.setAttribute("State", getStatesUSNewInstSelOneCho().getValue());
                }
                if (getCountryBusNewInstSelOneCho().getValue().equals("AU")) {
                    stateBusUpDt.setAttribute("State", getStatesAUNewInstSelOneCho().getValue());
                }
                if (getCountryBusNewInstSelOneCho().getValue().equals("CA")) {
                    stateBusUpDt.setAttribute("State", getStatesCANewInstSelOneCho().getValue());
                }
                if (!getCountryBusNewInstSelOneCho().getValue().equals("US")
                        && !getCountryBusNewInstSelOneCho().getValue().equals("AU")
                        && !getCountryBusNewInstSelOneCho().getValue().equals("CA")) {
                    stateBusUpDt.setAttribute("State", getStatesOtherNewInstIpTx().getValue());
                }
                cityBusUpDt.setAttribute("City", getCityBusNewInstIpTx().getValue());
                postalCodeBusUpDt.setAttribute("PostalCode", getPostalCodeBusNewInstIpTx().getValue());
                countyBusUpDt.setAttribute("County", getCountyBusNewInstIpTx().getValue());

                if (getPhoneBusNewInstIpTx().getValue() != null) {
                    PhoneValues phValues = phoneDetails(getCountryBusNewInstSelOneCho().getValue().toString(),
                            getPhoneBusNewInstIpTx().getValue().toString());
                    if (phValues != null) {
                        String phRawNumber = phValues.getFormattedPhoneNumber();
                        phoneRawNumberBusUpDt.setAttribute("RawNumber", phRawNumber);
                        phoneExtBusUpDt.setAttribute("Extension", getPhoneExtBusNewInstIpTx().getValue());
                    } else {
                        phoneRawNumberBusUpDt.setAttribute("RawNumber", " " + getPhoneBusNewInstIpTx().getValue());
                        phoneExtBusUpDt.setAttribute("Extension", getPhoneExtBusNewInstIpTx().getValue());
                    }

                }

                if (getFaxBusNewInstIpTx().getValue() != null) {
                    PhoneValues phValues = phoneDetails(getCountryBusNewInstSelOneCho().getValue().toString(),
                            getFaxBusNewInstIpTx().getValue().toString());
                    if (phValues != null) {
                        String faxRawNumber = phValues.getFormattedPhoneNumber();
                        faxRawNumberBusUpDt.setAttribute("RawNumber", faxRawNumber);
                        faxExtBusUpDt.setAttribute("Extension", getFaxExtBusNewInstIpTx().getValue());
                    } else {
                        faxRawNumberBusUpDt.setAttribute("RawNumber", " " + getFaxBusNewInstIpTx().getValue());
                        faxExtBusUpDt.setAttribute("Extension", getFaxExtBusNewInstIpTx().getValue());
                    }

                    if (getFaxBusNewInstIpTx().getValue() == null) {
                        faxStatusFlagBusUpDt.setAttribute("StatusFlag", "I");
                    }

                }

            }

        } catch (Exception e) {
            sLog.debug(e.getMessage(), e);
            e.printStackTrace();
        } finally {
            Configuration.releaseRootApplicationModule(am, true);
        }
    }

    public void loadAndUpdateHomeInfoBindings() {
        sLog.info("loadAndUpdateBusinessInfoBindings method  in AddressBookBackingBean");
        /* Home Address,Phone and Fax Bindings  */

        String state = "";

        JUCtrlAttrsBinding partySiteIDHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PartySiteIDHomeUpDt");
        JUCtrlAttrsBinding locationIDHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDHomeUpDt");
        JUCtrlAttrsBinding address1HomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address1HomeUpDt");
        JUCtrlAttrsBinding address2HomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address2HomeUpDt");
        JUCtrlAttrsBinding address3HomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3HomeUpDt");
        JUCtrlAttrsBinding address4HomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("Address4HomeUpDt");
        JUCtrlAttrsBinding countryHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("CountryHomeUpDt");
        JUCtrlAttrsBinding stateHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("StateHomeUpDt");
        JUCtrlAttrsBinding cityHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("CityHomeUpDt");
        JUCtrlAttrsBinding postalCodeHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("PostalCodeHomeUpDt");
        JUCtrlAttrsBinding countyHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("CountyHomeUpDt");
        JUCtrlAttrsBinding phoneIDHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDHomeUpDt");
        JUCtrlAttrsBinding phoneCountryCodeHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneCountryCodeHomeUpDt");
        JUCtrlAttrsBinding phoneAreaCodeHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneAreaCodeHomeUpDt");
        JUCtrlAttrsBinding phoneNumberHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneNumberHomeUpDt");
        JUCtrlAttrsBinding phoneRawNumberHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneRawNumberHomeUpDt");
        JUCtrlAttrsBinding faxIDHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDHomeUpDt");
        JUCtrlAttrsBinding faxCountryCodeHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxCountryCodeHomeUpDt");
        JUCtrlAttrsBinding faxAreaCodeHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxAreaCodeHomeUpDt");
        JUCtrlAttrsBinding faxNumberHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxNumberHomeUpDt");
        JUCtrlAttrsBinding faxRawNumberHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxRawNumberHomeUpDt");
        JUCtrlAttrsBinding faxStatusFlagHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxStatusFlagHomeUpDt");
        JUCtrlAttrsBinding validateAddressFlagHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("IsHomeAddressValidated");

        JUCtrlAttrsBinding partySiteIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PartySiteIDHomeGet");
        JUCtrlAttrsBinding locationIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDHomeGet");
        JUCtrlAttrsBinding phoneIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDHomeGet");
        JUCtrlAttrsBinding faxIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDHomeGet");

        if (getCountryHomeSelOneCho().getValue().equals("US")) {

            String homeAddrValid = validateAndStandardiseHomeAddress();
            if (homeAddrValid != null && homeAddrValid.equals("sucess")) {
                validateAddressFlagHomeUpDt.setAttribute("IsAddressValidated", "Y");
            } else {
                validateAddressFlagHomeUpDt.setAttribute("IsAddressValidated", "N");
            }
        }
        if (partySiteIDHomeGet != null && locationIDHomeGet != null) {
            partySiteIDHomeUpDt.setAttribute("PartySiteID", partySiteIDHomeGet.getAttribute("PartySiteID"));
            locationIDHomeUpDt.setAttribute("LocationID", locationIDHomeGet.getAttribute("LocationID"));
        }

        address1HomeUpDt.setAttribute("Address1", getAddress1HomeIpTx().getValue());
        address2HomeUpDt.setAttribute("Address2", getAddress2HomeIpTx().getValue());
        address3HomeUpDt.setAttribute("Address3", getAddress3HomeIpTx().getValue());
        address4HomeUpDt.setAttribute("Address4", getAddress4HomeIpTx().getValue());
        countryHomeUpDt.setAttribute("Country", getCountryHomeSelOneCho().getValue());

        if (getCountryHomeSelOneCho().getValue().equals("US")) {
            stateHomeUpDt.setAttribute("State", getStatesUSHomeSelOneCho().getValue());
        }
        if (getCountryHomeSelOneCho().getValue().equals("AU")) {
            stateHomeUpDt.setAttribute("State", getStatesAUHomeSelOneCho().getValue());
            state = (String) getStatesAUHomeSelOneCho().getValue();
        }
        if (getCountryHomeSelOneCho().getValue().equals("CA")) {
            stateHomeUpDt.setAttribute("State", getStatesCAHomeSelOneCho().getValue());
            state = (String) getStatesCAHomeSelOneCho().getValue();
        }
        if (!getCountryHomeSelOneCho().getValue().equals("US") && !getCountryHomeSelOneCho().getValue().equals("AU")
                && !getCountryHomeSelOneCho().getValue().equals("CA")) {
            stateHomeUpDt.setAttribute("State", getStatesOtherHomeIpTx().getValue());
            state = (String) getStatesOtherHomeIpTx().getValue();
        }
        cityHomeUpDt.setAttribute("City", getCityHomeIpTx().getValue());
        postalCodeHomeUpDt.setAttribute("PostalCode", getPostalCodeHomeIpTx().getValue());
        countyHomeUpDt.setAttribute("County", getCountyHomeIpTx().getValue());

        if (phoneIDHomeGet != null) {
            phoneIDHomeUpDt.setAttribute("ID", phoneIDHomeGet.getAttribute("ID"));
        }
        if (getPhoneHomeIpTx().getValue() != null) {
            PhoneValues phValues = phoneDetails(getCountryHomeSelOneCho().getValue().toString(),
                    getPhoneHomeIpTx().getValue().toString());
            if (phValues != null) {
                String phRawNumber = phValues.getFormattedPhoneNumber();
                phoneRawNumberHomeUpDt.setAttribute("RawNumber", phRawNumber);
            } else {
                phoneRawNumberHomeUpDt.setAttribute("RawNumber", " " + getPhoneHomeIpTx().getValue());
            }
        }

        if (faxIDHomeGet != null) {
            faxIDHomeUpDt.setAttribute("ID", faxIDHomeGet.getAttribute("ID"));
        }
        if (getFaxHomeIpTx().getValue() != null) {
            PhoneValues phValues = phoneDetails(getCountryHomeSelOneCho().getValue().toString(),
                    getFaxHomeIpTx().getValue().toString());
            if (phValues != null) {
                String faxRawNumber = phValues.getFormattedPhoneNumber();
                faxRawNumberHomeUpDt.setAttribute("RawNumber", faxRawNumber);
            } else {
                faxRawNumberHomeUpDt.setAttribute("RawNumber", " " + getFaxHomeIpTx().getValue());
            }
        }

        if (faxIDHomeGet != null
                && (getFaxHomeIpTx().getValue() != null && getFaxHomeIpTx().getValue().equals(""))) {
            faxStatusFlagHomeUpDt.setAttribute("StatusFlag", "I");
        }

        // and also trillium return true validation

        if (!getCountryHomeSelOneCho().getValue().equals("US")) {
            JUCtrlAttrsBinding LocationIDHomeGet = (JUCtrlAttrsBinding) bindings
                    .findNamedObject("LocationIDHomeGet");
            Object homeLocationId = LocationIDHomeGet.getAttribute("LocationID");

            if (homeLocationId != null) {
                String foreignAddr1 = "";
                String foreignAddr2 = "";
                String foreignAddr3 = "";
                String foreignAddr4 = "";
                String foreignState = "";
                String foreignCity = "";
                String foreignZipCode = "";
                JUCtrlAttrsBinding address1HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address1HomeGet");
                JUCtrlAttrsBinding address2HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address2HomeGet");
                JUCtrlAttrsBinding address3HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address3HomeGet");
                JUCtrlAttrsBinding address4HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address4HomeGet");
                JUCtrlAttrsBinding stateHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("StateHomeGet");
                JUCtrlAttrsBinding cityHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CityHomeGet");
                JUCtrlAttrsBinding postalCodeHomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PostalCodeHomeGet");

                foreignAddr1 = (String) address1HomeGet.getAttribute("Address1");
                foreignAddr2 = (String) address2HomeGet.getAttribute("Address2");
                foreignAddr3 = (String) address3HomeGet.getAttribute("Address3");
                foreignAddr4 = (String) address4HomeGet.getAttribute("Address4");
                foreignCity = (String) cityHomeGet.getAttribute("City");
                foreignState = (String) stateHomeGet.getAttribute("State");
                foreignZipCode = (String) postalCodeHomeGet.getAttribute("PostalCode");

                if (foreignAddr2 == null) {
                    foreignAddr2 = "";
                }
                if (foreignAddr3 == null) {
                    foreignAddr3 = "";
                }
                if (foreignAddr4 == null) {
                    foreignAddr4 = "";
                }
                if (foreignState == null) {
                    foreignState = "";
                }
                if (foreignZipCode == null) {
                    foreignZipCode = "";
                }

                if (getAddress2HomeIpTx().getValue() == null) {
                    getAddress2HomeIpTx().setValue("");
                }
                if (getAddress3HomeIpTx().getValue() == null) {
                    getAddress3HomeIpTx().setValue("");
                }
                if (getAddress4HomeIpTx().getValue() == null) {
                    getAddress4HomeIpTx().setValue("");
                }
                if (getPostalCodeHomeIpTx().getValue() == null) {
                    getPostalCodeHomeIpTx().setValue("");
                }
                if (state == null) {
                    state = "";
                }

                if (foreignAddr1.equals(getAddress1HomeIpTx().getValue())
                        && foreignCity.equals(getCityHomeIpTx().getValue()) && foreignState.equals(state)
                        && foreignZipCode.equals(getPostalCodeHomeIpTx().getValue())
                        && foreignAddr2.equals(getAddress2HomeIpTx().getValue())
                        && foreignAddr3.equals(getAddress3HomeIpTx().getValue())
                        && foreignAddr4.equals(getAddress4HomeIpTx().getValue())) {
                    validateAddressFlagHomeUpDt.setAttribute("IsAddressValidated", "Y");

                } else {
                    validateAddressFlagHomeUpDt.setAttribute("IsAddressValidated", "N");

                }
            } else {
                validateAddressFlagHomeUpDt.setAttribute("IsAddressValidated", "N");

            }
        }
    }

    public void deleteBusinessInfoBindings() {
        sLog.info("deleteBusinessInfoBindings method  in AddressBookBackingBean");

        JUCtrlAttrsBinding partySiteIDBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("PartySiteIDBusUpDt");
        JUCtrlAttrsBinding locationIDBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDBusUpDt");
        JUCtrlAttrsBinding addressStatusFlagBusUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("AddressStatusFlagBusUpDt");
        JUCtrlAttrsBinding phoneIDBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDBusUpDt");
        JUCtrlAttrsBinding phoneStatusFlagBusUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneStatusFlagBusUpDt");
        JUCtrlAttrsBinding faxIDBusUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDBusUpDt");
        JUCtrlAttrsBinding faxStatusFlagBusUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxStatusFlagBusUpDt");

        JUCtrlAttrsBinding partySiteIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PartySiteIDBusGet");
        JUCtrlAttrsBinding locationIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDBusGet");
        JUCtrlAttrsBinding phoneIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDBusGet");
        JUCtrlAttrsBinding faxIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDBusGet");

        if (partySiteIDBusGet != null && partySiteIDBusGet.getAttribute("PartySiteID") != null) {

            partySiteIDBusUpDt.setAttribute("PartySiteID", partySiteIDBusGet.getAttribute("PartySiteID"));
            locationIDBusUpDt.setAttribute("LocationID", locationIDBusGet.getAttribute("LocationID"));
            addressStatusFlagBusUpDt.setAttribute("StatusFlag", "I");
            phoneIDBusUpDt.setAttribute("ID", phoneIDBusGet.getAttribute("ID"));
            phoneStatusFlagBusUpDt.setAttribute("StatusFlag", "I");
            if (faxIDBusGet != null) {
                faxIDBusUpDt.setAttribute("ID", faxIDBusGet.getAttribute("ID"));
                faxStatusFlagBusUpDt.setAttribute("StatusFlag", "I");
            }
        }

    }

    public void deleteHomeInfoBindings() {
        sLog.info("deleteHomeInfoBindings method  in AddressBookBackingBean");

        JUCtrlAttrsBinding partySiteIDHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PartySiteIDHomeUpDt");
        JUCtrlAttrsBinding locationIDHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDHomeUpDt");
        JUCtrlAttrsBinding addressStatusFlagHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("AddressStatusFlagHomeUpDt");
        JUCtrlAttrsBinding phoneIDHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDHomeUpDt");
        JUCtrlAttrsBinding phoneStatusFlagHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneStatusFlagHomeUpDt");
        JUCtrlAttrsBinding faxIDHomeUpDt = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDHomeUpDt");
        JUCtrlAttrsBinding faxStatusFlagHomeUpDt = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxStatusFlagHomeUpDt");

        JUCtrlAttrsBinding partySiteIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PartySiteIDHomeGet");
        JUCtrlAttrsBinding locationIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDHomeGet");
        JUCtrlAttrsBinding phoneIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PhoneIDHomeGet");
        JUCtrlAttrsBinding faxIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxIDHomeGet");

        if (partySiteIDHomeGet != null && partySiteIDHomeGet.getAttribute("PartySiteID") != null) {

            partySiteIDHomeUpDt.setAttribute("PartySiteID", partySiteIDHomeGet.getAttribute("PartySiteID"));
            locationIDHomeUpDt.setAttribute("LocationID", locationIDHomeGet.getAttribute("LocationID"));
            addressStatusFlagHomeUpDt.setAttribute("StatusFlag", "I");
            phoneIDHomeUpDt.setAttribute("ID", phoneIDHomeGet.getAttribute("ID"));
            phoneStatusFlagHomeUpDt.setAttribute("StatusFlag", "I");
            if (faxIDHomeGet != null) {
                faxIDHomeUpDt.setAttribute("ID", faxIDHomeGet.getAttribute("ID"));
                faxStatusFlagHomeUpDt.setAttribute("StatusFlag", "I");
            }
        }

    }

    public String validateAndStandardiseHomeAddress() {
        String validateHomeAddressStatus = null;

        String inputHomeData = "|" + getAddress1HomeIpTx().getValue() + "|" + getAddress2HomeIpTx().getValue() + "|"
                + getAddress3HomeIpTx().getValue() + "|" + getAddress4HomeIpTx().getValue() + "|"
                + getCityHomeIpTx().getValue() + "|" + getStatesUSHomeSelOneCho().getValue() + "|"
                + getPostalCodeHomeIpTx().getValue() + "|" + "";

        String[] inputData = new String[8];
        inputData[0] = (String) getAddress1HomeIpTx().getValue();
        inputData[1] = (String) getAddress2HomeIpTx().getValue();
        inputData[2] = (String) getAddress3HomeIpTx().getValue();
        inputData[3] = (String) getAddress4HomeIpTx().getValue();
        inputData[4] = (String) getCityHomeIpTx().getValue();
        inputData[5] = (String) getStatesUSHomeSelOneCho().getValue();
        inputData[6] = (String) getPostalCodeHomeIpTx().getValue();
        inputData[7] = "";
        String[] outPut = tv.cleanseData(inputData);
        String failOutLevel = outPut[8];

        if (failOutLevel != null && failOutLevel.equals("0")) {
            validateHomeAddressStatus = "sucess";
            getAddress1HomeIpTx().setValue(outPut[0]);
            getAddress2HomeIpTx().setValue(outPut[1]);
            getAddress3HomeIpTx().setValue(outPut[2]);
            getAddress4HomeIpTx().setValue(outPut[3]);
            getCityHomeIpTx().setValue(outPut[4]);
            getStatesUSHomeSelOneCho().setValue(outPut[5]);
            getPostalCodeHomeIpTx().setValue(outPut[6]);
            getCountryHomeSelOneCho().setValue("US");
            getCountyHomeIpTx().setValue(outPut[7]);
        }
        return validateHomeAddressStatus;
    }

    public String validateAndStandardiseBusinessAddress() {
        String validateBusinessAddressStatus = "failure";

        if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {
            String inputPartyData = getAddress1PartyIpTx().getValue() + "|" + getAddress2PartyIpTx().getValue()
                    + "|" + getAddress3PartyIpTx().getValue() + "|" + getAddress4PartyIpTx().getValue() + "|"
                    + getCityPartyIpTx().getValue() + "|" + getStatesUSPartySelOneCho().getValue() + "|"
                    + getPostalCodePartyIpTx().getValue();

            String[] inputData = new String[8];
            inputData[0] = (String) getAddress1PartyIpTx().getValue();
            inputData[1] = (String) getAddress2PartyIpTx().getValue();
            inputData[2] = (String) getAddress3PartyIpTx().getValue();
            inputData[3] = (String) getAddress4PartyIpTx().getValue();
            inputData[4] = (String) getCityPartyIpTx().getValue();
            inputData[5] = (String) getStatesUSPartySelOneCho().getValue();
            inputData[6] = (String) getPostalCodePartyIpTx().getValue();
            inputData[7] = "";
            String[] outPut = tv.cleanseData(inputData);
            String failOutLevel = outPut[8];

            if (failOutLevel != null && failOutLevel.equals("0")) {

                validateBusinessAddressStatus = "sucess";
                getAddress1PartyIpTx().setValue(outPut[0]);
                getAddress2PartyIpTx().setValue(outPut[1]);
                getAddress3PartyIpTx().setValue(outPut[2]);
                getAddress4PartyIpTx().setValue(outPut[3]);
                getCityPartyIpTx().setValue(outPut[4]);
                getStatesUSPartySelOneCho().setValue(outPut[5]);
                getPostalCodePartyIpTx().setValue(outPut[6]);
                getCountryPartySelOneCho().setValue("US");
                getCountyPartyIpTx().setValue(outPut[7]);

            }
        }
        if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {
            String inputNewInstData = "|" + getAddress1BusNewInstIpTx().getValue() + "|"
                    + getAddress2BusNewInstIpTx().getValue() + "|" + getAddress3BusNewInstIpTx().getValue() + ","
                    + getAddress4BusNewInstIpTx().getValue() + "|" + getCityBusNewInstIpTx().getValue() + "|"
                    + getStatesUSNewInstSelOneCho().getValue() + "|" + getPostalCodeBusNewInstIpTx().getValue()
                    + "|" + "";

            String[] inputData = new String[8];
            inputData[0] = (String) getAddress1BusNewInstIpTx().getValue();
            inputData[1] = (String) getAddress2BusNewInstIpTx().getValue();
            inputData[2] = (String) getAddress3BusNewInstIpTx().getValue();
            inputData[3] = (String) getAddress4BusNewInstIpTx().getValue();
            inputData[4] = (String) getCityBusNewInstIpTx().getValue();
            inputData[5] = (String) getStatesUSNewInstSelOneCho().getValue();
            inputData[6] = (String) getPostalCodeBusNewInstIpTx().getValue();
            inputData[7] = "";
            String[] outPut = tv.cleanseData(inputData);
            String failOutLevel = outPut[8];
            if (failOutLevel != null && failOutLevel.equals("0")) {
                validateBusinessAddressStatus = "sucess";
                getAddress1BusNewInstIpTx().setValue(outPut[0]);
                getAddress2BusNewInstIpTx().setValue(outPut[1]);
                getAddress3BusNewInstIpTx().setValue(outPut[2]);
                getAddress3BusNewInstIpTx().setValue(outPut[3]);
                getCityBusNewInstIpTx().setValue(outPut[4]);
                getStatesUSNewInstSelOneCho().setValue(outPut[5]);
                getPostalCodeBusNewInstIpTx().setValue(outPut[6]);
                getCountryBusNewInstSelOneCho().setValue("US");
                getCountyBusNewInstIpTx().setValue(outPut[7]);
            }
        }

        return validateBusinessAddressStatus;
    }

    private void showPopup(RichPopup popUp, UIComponent source) {

        FacesContext context = FacesContext.getCurrentInstance();
        String popupId = popUp.getClientId(context);
        //  System.out.println("popupId "+popupId);
        //  String alignId = source.getClientId(context);
        String alignId = "Spacer6";

        StringBuilder script = new StringBuilder();
        script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ")
                .append("if (!popup.isPopupVisible()) { ").append("var hints = {}; ")
                .append("hints    [AdfRichPopup.HINT_ALIGN_ID] = '").append(alignId).append("'; ")
                .append("hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_START_AFTER; ")
                .append("popup.show(hints);}");
        ExtendedRenderKitService erks = Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
        erks.addScript(context, script.toString());

    }

    public void floridaFlds() {
        try {

            if (!getLicenseNumberIpTx().isReadOnly()) {

                if (getAddressOptionsRdBtn().getValue().equals("business")) {

                    if (getInstitutionOptionsRdBtn().getValue().equals("browseInst")) {

                        if (getCountryPartySelOneCho() != null && getCountryPartySelOneCho().getValue() != null
                                && getCountryPartySelOneCho().getValue().equals("US")
                                && getStatesUSPartySelOneCho() != null
                                && getStatesUSPartySelOneCho().getValue() != null
                                && !getStatesUSPartySelOneCho().getValue().equals("FL")
                                && !getStatesUSPartySelOneCho().getValue().equals("")
                                && !getLicensePnlGrp().isVisible()) {

                            getFloridaLicensePnlGrp().setVisible(true);
                            getFloridaLicenseCmdImgLnk().setVisible(true);
                            getFloridaLicenseImgLbl().setVisible(false);
                            getLicensePnlGrp().setVisible(false);
                        } else if (getCountryPartySelOneCho() != null
                                && getCountryPartySelOneCho().getValue() != null
                                && getCountryPartySelOneCho().getValue().equals("US")
                                && getStatesUSPartySelOneCho().getValue() != null
                                && getStatesUSPartySelOneCho().getValue().equals("FL")) {

                            getFloridaLicensePnlGrp().setVisible(true);
                            getFloridaLicenseCmdImgLnk().setVisible(false);
                            getFloridaLicenseImgLbl().setVisible(true);
                            getLicensePnlGrp().setVisible(true);
                        } else if (getCountryPartySelOneCho().getValue() == null
                                || !getCountryPartySelOneCho().getValue().equals("US")
                                || (getCountryPartySelOneCho().getValue().equals("US")
                                        && getStatesUSPartySelOneCho().getValue() == null)
                                || (getCountryPartySelOneCho().getValue().equals("US")
                                        && getStatesUSPartySelOneCho().getValue() != null
                                        && getStatesUSPartySelOneCho().getValue().equals("")
                                        && getStatesUSPartySelOneCho().getValue().equals(""))) {

                            getFloridaLicensePnlGrp().setVisible(false);
                            getFloridaLicenseCmdImgLnk().setVisible(false);
                            getFloridaLicenseImgLbl().setVisible(false);
                            getLicensePnlGrp().setVisible(false);
                            getLicenseNumberIpTx().setValue("");
                        }
                    } else {

                        if (getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                && getStatesUSNewInstSelOneCho().getValue() != null
                                && !getStatesUSNewInstSelOneCho().getValue().equals("FL")
                                && !getStatesUSNewInstSelOneCho().getValue().equals("")
                                && !getLicensePnlGrp().isVisible()) {

                            getFloridaLicensePnlGrp().setVisible(true);
                            getFloridaLicenseCmdImgLnk().setVisible(true);
                            getFloridaLicenseImgLbl().setVisible(false);
                            getLicensePnlGrp().setVisible(false);
                        } else if (getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                && getStatesUSNewInstSelOneCho().getValue() != null
                                && getStatesUSNewInstSelOneCho().getValue().equals("FL")) {

                            getFloridaLicensePnlGrp().setVisible(true);
                            getFloridaLicenseCmdImgLnk().setVisible(false);
                            getFloridaLicenseImgLbl().setVisible(true);
                            getLicensePnlGrp().setVisible(true);
                        } else if (getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue() != null
                                && !getCountryBusNewInstSelOneCho().getValue().equals("US")
                                || (getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() == null)
                                || (getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() != null
                                        && getStatesUSNewInstSelOneCho().getValue().equals(""))) {

                            getFloridaLicensePnlGrp().setVisible(false);
                            getFloridaLicenseCmdImgLnk().setVisible(false);
                            getFloridaLicenseImgLbl().setVisible(false);
                            getLicensePnlGrp().setVisible(false);
                            getLicenseNumberIpTx().setValue("");
                        }
                    }
                } else if (getAddressOptionsRdBtn().getValue().equals("home")) {

                    if (getCountryHomeSelOneCho().getValue().equals("US")
                            && getStatesUSHomeSelOneCho().getValue() != null
                            && !getStatesUSHomeSelOneCho().getValue().equals("FL")
                            && !getStatesUSHomeSelOneCho().getValue().equals("")
                            && !getLicensePnlGrp().isVisible()) {

                        getFloridaLicensePnlGrp().setVisible(true);
                        getFloridaLicenseCmdImgLnk().setVisible(true);
                        getFloridaLicenseImgLbl().setVisible(false);
                        getLicensePnlGrp().setVisible(false);
                    } else if (getCountryHomeSelOneCho().getValue().equals("US")
                            && getStatesUSHomeSelOneCho().getValue() != null
                            && getStatesUSHomeSelOneCho().getValue().equals("FL")) {

                        getFloridaLicensePnlGrp().setVisible(true);
                        getFloridaLicenseCmdImgLnk().setVisible(false);
                        getFloridaLicenseImgLbl().setVisible(true);
                        getLicensePnlGrp().setVisible(true);
                    } else if (!getCountryHomeSelOneCho().getValue().equals("US")
                            || (getCountryHomeSelOneCho().getValue().equals("US")
                                    && getStatesUSHomeSelOneCho().getValue() == null)
                            || (getCountryHomeSelOneCho().getValue().equals("US")
                                    && getStatesUSHomeSelOneCho().getValue() != null
                                    && getStatesUSHomeSelOneCho().getValue().equals(""))) {

                        getFloridaLicensePnlGrp().setVisible(false);
                        getFloridaLicenseCmdImgLnk().setVisible(false);
                        getFloridaLicenseImgLbl().setVisible(false);
                        getLicensePnlGrp().setVisible(false);
                        getLicenseNumberIpTx().setValue("");
                    }
                } else if (getAddressOptionsRdBtn().getValue().equals("businesshome")) {
                    if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {

                        if ((!getLicensePnlGrp().isVisible() && getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                && getCountryHomeSelOneCho().getValue().equals("US")
                                && getStatesUSNewInstSelOneCho().getValue() != null
                                && !getStatesUSNewInstSelOneCho().getValue().equals("")
                                && !getStatesUSNewInstSelOneCho().getValue().equals("FL")) ||

                                (!getLicensePnlGrp().isVisible() && getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() != null
                                        && !getStatesUSHomeSelOneCho().getValue().equals("")
                                        && !getStatesUSHomeSelOneCho().getValue().equals("FL"))
                                ||

                                (!getLicensePnlGrp().isVisible() && getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && !getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() != null
                                        && !getStatesUSNewInstSelOneCho().getValue().equals("FL")
                                        && !getStatesUSNewInstSelOneCho().getValue().equals(""))
                                ||

                                ((!getLicensePnlGrp().isVisible() && getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && !getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() != null
                                        && !getStatesUSHomeSelOneCho().getValue().equals("FL")
                                        && !getStatesUSHomeSelOneCho().getValue().equals("")))) {

                            getFloridaLicensePnlGrp().setVisible(true);
                            getFloridaLicenseCmdImgLnk().setVisible(true);
                            getFloridaLicenseImgLbl().setVisible(false);
                            getLicensePnlGrp().setVisible(false);
                        }
                        //fix null pointer exception
                        else if ((getCountryBusNewInstSelOneCho() != null
                                && getCountryBusNewInstSelOneCho().getValue() != null
                                && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                && getCountryHomeSelOneCho().getValue().equals("US")
                                && getStatesUSNewInstSelOneCho() != null
                                && getStatesUSNewInstSelOneCho().getValue() != null
                                && getStatesUSNewInstSelOneCho().getValue().equals("FL")
                                && getStatesUSHomeSelOneCho().getValue() != null
                                && getStatesUSHomeSelOneCho().getValue().equals("FL")
                                || (getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && !getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() != null
                                        && getStatesUSNewInstSelOneCho().getValue().equals("FL"))
                                || (getCountryBusNewInstSelOneCho() != null
                                        && getCountryBusNewInstSelOneCho().getValue() != null
                                        && !getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() != null
                                        && getStatesUSHomeSelOneCho().getValue().equals("FL")))) {

                            getFloridaLicensePnlGrp().setVisible(true);
                            getFloridaLicenseCmdImgLnk().setVisible(false);
                            getFloridaLicenseImgLbl().setVisible(true);
                            getLicensePnlGrp().setVisible(true);
                        }

                        else if ((!getCountryBusNewInstSelOneCho().getValue().equals("US")
                                && !getCountryHomeSelOneCho().getValue().equals("US"))
                                || (getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() == null
                                        && getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() == null)
                                || (getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() != null
                                        && getStatesUSNewInstSelOneCho().getValue().equals("")
                                        && getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() != null
                                        && getStatesUSHomeSelOneCho().getValue().equals(""))
                                || (getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() == null
                                        && !getCountryBusNewInstSelOneCho().getValue().equals("US"))
                                || (getCountryHomeSelOneCho().getValue().equals("US")
                                        && getStatesUSHomeSelOneCho().getValue() != null
                                        && getStatesUSHomeSelOneCho().getValue().equals("")
                                        && !getCountryBusNewInstSelOneCho().getValue().equals("US"))
                                || (getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() == null
                                        && !getCountryHomeSelOneCho().getValue().equals("US"))
                                || (getCountryBusNewInstSelOneCho().getValue().equals("US")
                                        && getStatesUSNewInstSelOneCho().getValue() != null
                                        && getStatesUSNewInstSelOneCho().getValue().equals("")
                                        && !getCountryHomeSelOneCho().getValue().equals("US"))) {

                            getFloridaLicensePnlGrp().setVisible(false);
                            getFloridaLicenseCmdImgLnk().setVisible(false);
                            getFloridaLicenseImgLbl().setVisible(false);
                            getLicensePnlGrp().setVisible(false);
                            getLicenseNumberIpTx().setValue("");
                        }
                    }

                    else {
                        //Party disabled
                        if (getCountryPartySelOneCho().isDisabled()) {

                            if (getCountryHomeSelOneCho().getValue().equals("US")
                                    && getStatesUSHomeSelOneCho().getValue() != null
                                    && !getStatesUSHomeSelOneCho().getValue().equals("FL")
                                    && !getStatesUSHomeSelOneCho().getValue().equals("")
                                    && !getLicensePnlGrp().isVisible()) {

                                getFloridaLicensePnlGrp().setVisible(true);
                                getFloridaLicenseCmdImgLnk().setVisible(true);
                                getFloridaLicenseImgLbl().setVisible(false);
                                getLicensePnlGrp().setVisible(false);
                            } else if (getCountryHomeSelOneCho().getValue().equals("US")
                                    && getStatesUSHomeSelOneCho().getValue() != null
                                    && getStatesUSHomeSelOneCho().getValue().equals("FL")) {

                                getFloridaLicensePnlGrp().setVisible(true);
                                getFloridaLicenseCmdImgLnk().setVisible(false);
                                getFloridaLicenseImgLbl().setVisible(true);
                                getLicensePnlGrp().setVisible(true);
                            } else if (!getCountryHomeSelOneCho().getValue().equals("US")
                                    || (getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue() == null)
                                    || (getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue() != null
                                            && getStatesUSHomeSelOneCho().getValue().equals(""))) {

                                getFloridaLicensePnlGrp().setVisible(false);
                                getFloridaLicenseCmdImgLnk().setVisible(false);
                                getFloridaLicenseImgLbl().setVisible(false);
                                getLicensePnlGrp().setVisible(false);
                                getLicenseNumberIpTx().setValue("");
                            }
                        }
                        //Party not disabled
                        else {

                            if ((!getLicensePnlGrp().isVisible()
                                    && getCountryPartySelOneCho().getValue().equals("US")
                                    && getCountryHomeSelOneCho().getValue().equals("US")
                                    && getStatesUSPartySelOneCho().getValue() != null
                                    && !getStatesUSPartySelOneCho().getValue().equals("FL")
                                    && !getStatesUSPartySelOneCho().getValue().equals("")
                                    && getStatesUSHomeSelOneCho().getValue() != null
                                    && !getStatesUSHomeSelOneCho().getValue().equals("FL")
                                    && !getStatesUSHomeSelOneCho().getValue().equals(""))
                                    || (!getLicensePnlGrp().isVisible()
                                            && getCountryPartySelOneCho().getValue().equals("US")
                                            && getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSPartySelOneCho().getValue() != null
                                            && !getStatesUSPartySelOneCho().getValue().equals("FL")
                                            && !getStatesUSPartySelOneCho().getValue().equals(""))
                                    || (!getLicensePnlGrp().isVisible()
                                            && (!getCountryPartySelOneCho().getValue().equals("US")
                                                    && getCountryHomeSelOneCho().getValue().equals("US")
                                                    && getStatesUSHomeSelOneCho().getValue() != null
                                                    && !getStatesUSHomeSelOneCho().getValue().equals("FL")
                                                    && !getStatesUSHomeSelOneCho().getValue().equals("")))) {

                                getFloridaLicensePnlGrp().setVisible(true);
                                getFloridaLicenseCmdImgLnk().setVisible(true);
                                getFloridaLicenseImgLbl().setVisible(false);
                                getLicensePnlGrp().setVisible(false);
                            } else if ((getCountryPartySelOneCho().getValue().equals("US")
                                    && getCountryHomeSelOneCho().getValue().equals("US")
                                    && (getStatesUSPartySelOneCho().getValue() != null
                                            && getStatesUSPartySelOneCho().getValue().equals("FL"))
                                    || (getStatesUSHomeSelOneCho().getValue() != null
                                            && getStatesUSHomeSelOneCho().getValue().equals("FL")))
                                    || (getCountryPartySelOneCho().getValue().equals("US")
                                            && !getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSPartySelOneCho().getValue() != null
                                            && getStatesUSPartySelOneCho().getValue().equals("FL"))
                                    || (!getCountryPartySelOneCho().getValue().equals("US")
                                            && getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue().equals("FL"))) {

                                getFloridaLicensePnlGrp().setVisible(true);
                                getFloridaLicenseCmdImgLnk().setVisible(false);
                                getFloridaLicenseImgLbl().setVisible(true);
                                getLicensePnlGrp().setVisible(true);
                            } else if ((!getCountryPartySelOneCho().getValue().equals("US")
                                    && !getCountryHomeSelOneCho().getValue().equals("US"))
                                    || (getCountryPartySelOneCho().getValue().equals("US")
                                            && getStatesUSPartySelOneCho().getValue() == null
                                            && getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue() == null)
                                    || (getCountryPartySelOneCho().getValue().equals("US")
                                            && getStatesUSPartySelOneCho().getValue() != null
                                            && getStatesUSPartySelOneCho().getValue().equals("")
                                            && getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue() != null
                                            && getStatesUSHomeSelOneCho().getValue().equals(""))
                                    || (getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue() == null
                                            && !getCountryPartySelOneCho().getValue().equals("US"))
                                    || (getCountryHomeSelOneCho().getValue().equals("US")
                                            && getStatesUSHomeSelOneCho().getValue() != null
                                            && getStatesUSHomeSelOneCho().getValue().equals("")
                                            && !getCountryPartySelOneCho().getValue().equals("US"))
                                    || (getCountryPartySelOneCho().getValue().equals("US")
                                            && getStatesUSPartySelOneCho().getValue() == null
                                            && !getCountryHomeSelOneCho().getValue().equals("US"))
                                    || (getCountryPartySelOneCho().getValue().equals("US")
                                            && getStatesUSPartySelOneCho().getValue() != null
                                            && getStatesUSPartySelOneCho().getValue().equals("")
                                            && !getCountryHomeSelOneCho().getValue().equals("US"))) {

                                getFloridaLicensePnlGrp().setVisible(false);
                                getFloridaLicenseCmdImgLnk().setVisible(false);
                                getFloridaLicenseImgLbl().setVisible(false);
                                getLicensePnlGrp().setVisible(false);
                                getLicenseNumberIpTx().setValue("");
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void clearPartyInformation() {
        getPartyIdIpTx().setValue("");
        getPartyNameIpLOV().setValue(" ");
        getAddress1PartyIpTx().setValue("");
        getAddress2PartyIpTx().setValue("");
        getAddress3PartyIpTx().setValue("");
        getAddress4PartyIpTx().setValue("");
        getCountryPartySelOneCho().setValue("");
        getStatesUSPartySelOneCho().setValue("");
        getStatesAUPartySelOneCho().setValue("");
        getStatesCAPartySelOneCho().setValue("");
        getStatesOthersPartyIpTx().setValue("");
        getCityPartyIpTx().setValue("");
        getPostalCodePartyIpTx().setValue("");
        getCountyPartyIpTx().setValue("");
        getPhonePartyIpTx().setValue("");
        getPhoneExtPartyIpTx().setValue("");
        getFaxExtPartyIpTx().setValue("");
        getFaxPartyIpTx().setValue("");

    }

    public void clearNewInstitutionInformation() {
        getInstitutionNameBusNewInstIpTx().setValue("");
        getAddress1BusNewInstIpTx().setValue("");
        getAddress2BusNewInstIpTx().setValue("");
        getAddress3BusNewInstIpTx().setValue("");
        getAddress4BusNewInstIpTx().setValue("");
        getCountryBusNewInstSelOneCho().setValue("US");
        getStatesUSNewInstSelOneCho().setValue("");
        getStatesAUNewInstSelOneCho().setValue("");
        getStatesCANewInstSelOneCho().setValue("");
        getStatesOtherNewInstIpTx().setValue("");
        getCityBusNewInstIpTx().setValue("");
        getPostalCodeBusNewInstIpTx().setValue("");
        getCountyBusNewInstIpTx().setValue("");
        getPhoneBusNewInstIpTx().setValue("");
        getPhoneExtBusNewInstIpTx().setValue("");
        getFaxBusNewInstIpTx().setValue("");
        getFaxExtBusNewInstIpTx().setValue("");

    }

    public void clearHomeInformation() {
        getAddress1HomeIpTx().setValue("");
        getAddress2HomeIpTx().setValue("");
        getAddress3HomeIpTx().setValue("");
        getAddress4HomeIpTx().setValue("");
        getCountryHomeSelOneCho().setValue("US");
        getStatesUSHomeSelOneCho().setValue("");
        getStatesAUHomeSelOneCho().setValue("");
        getStatesCAHomeSelOneCho().setValue("");
        getStatesOtherHomeIpTx().setValue("");
        getCityHomeIpTx().setValue("");
        getPostalCodeHomeIpTx().setValue("");
        getCountyHomeIpTx().setValue("");
        getPhoneHomeIpTx().setValue("");
        getFaxHomeIpTx().setValue("");
    }

    public void enablePartyInfoFlds() {

        getAddress1PartyIpTx().setDisabled(false);
        getAddress2PartyIpTx().setDisabled(false);
        getAddress3PartyIpTx().setDisabled(false);
        getAddress4PartyIpTx().setDisabled(false);
        getCountryPartySelOneCho().setDisabled(false);
        getCityPartyIpTx().setDisabled(false);
        getPostalCodePartyIpTx().setDisabled(false);
        getStatesAUPartySelOneCho().setDisabled(false);
        getStatesCAPartySelOneCho().setDisabled(false);
        getStatesUSPartySelOneCho().setDisabled(false);
        getStatesOthersPartyIpTx().setDisabled(false);
        getPhonePartyIpTx().setDisabled(false);
        getPhoneExtPartyIpTx().setDisabled(false);
        getFaxPartyIpTx().setDisabled(false);
        getFaxExtPartyIpTx().setDisabled(false);

    }

    public void disablePartyInfoFlds() {

        getAddress1PartyIpTx().setDisabled(true);
        getAddress2PartyIpTx().setDisabled(true);
        getAddress3PartyIpTx().setDisabled(true);
        getAddress4PartyIpTx().setDisabled(true);
        getCountryPartySelOneCho().setDisabled(true);
        getCityPartyIpTx().setDisabled(true);
        getPostalCodePartyIpTx().setDisabled(true);
        getStatesAUPartySelOneCho().setDisabled(true);
        getStatesCAPartySelOneCho().setDisabled(true);
        getStatesUSPartySelOneCho().setDisabled(true);
        getStatesOthersPartyIpTx().setDisabled(true);
        getPhonePartyIpTx().setDisabled(true);
        getPhoneExtPartyIpTx().setDisabled(true);
        getFaxPartyIpTx().setDisabled(true);
        getFaxExtPartyIpTx().setDisabled(true);

    }

    public void partyDetailsReturnPopupListener(ReturnPopupEvent returnPopupEvent) {

        sLog.info("PartyDetailsReturnPopupListener method AddressBookBackingBean");
        BindingContext bindingContext = BindingContext.getCurrent();
        BindingContainer bindings = bindingContext.getCurrentBindingsEntry();
        try {
            DCIteratorBinding iter;
            iter = (DCIteratorBinding) bindings.get("InstitutionDisplayVO1Iterator");
            Row r = iter.getCurrentRow();
            if (r.getAttribute("PartyId") != null && r.getAttribute("PartyNumber") != null) {
                enablePartyInfoFlds();

                if (r.getAttribute("Country").equals("US")) {

                    getCountryPartySelOneCho().setValue("US");
                    getStatesUSPartySelOneCho().setValue(r.getAttribute("State"));

                }
                if (r.getAttribute("Country").equals("AU")) {

                    getCountryPartySelOneCho().setValue("AU");
                    getStatesAUPartySelOneCho().setValue(r.getAttribute("State"));

                }
                if (r.getAttribute("Country").equals("CA")) {

                    getCountryPartySelOneCho().setValue("CA");
                    getStatesCAPartySelOneCho().setValue(r.getAttribute("State"));

                }
                if (!r.getAttribute("Country").equals("US") && !r.getAttribute("Country").equals("AU")
                        && !r.getAttribute("Country").equals("CA")) {

                    getCountryPartySelOneCho().setValue(r.getAttribute("Country"));
                    getStatesOthersPartyIpTx().setValue(r.getAttribute("State"));
                }
                floridaFlds();
            }
        } catch (Exception e) {
            sLog.debug(e.getMessage(), e);
            e.printStackTrace();
        }
    }

    public void setStatesOthersPartyIpTx(RichInputText statesOthersPartyIpTx) {
        this.statesOthersPartyIpTx = statesOthersPartyIpTx;
    }

    public RichInputText getStatesOthersPartyIpTx() {
        return statesOthersPartyIpTx;
    }

    public void setHomeOutputLabel(RichOutputLabel homeOutputLabel) {
        this.homeOutputLabel = homeOutputLabel;
    }

    public RichOutputLabel getHomeOutputLabel() {
        return homeOutputLabel;
    }

    public void setBusinessOutputLabel(RichOutputLabel businessOutputLabel) {
        this.businessOutputLabel = businessOutputLabel;
    }

    public RichOutputLabel getBusinessOutputLabel() {
        return businessOutputLabel;
    }

    public void setStatesUSHomeSelOneCho(RichSelectOneChoice statesUSHomeSelOneCho) {
        this.statesUSHomeSelOneCho = statesUSHomeSelOneCho;
    }

    public RichSelectOneChoice getStatesUSHomeSelOneCho() {
        return statesUSHomeSelOneCho;
    }

    public void setBusinessAddressConfirmPopup(RichPopup businessAddressConfirmPopup) {
        this.businessAddressConfirmPopup = businessAddressConfirmPopup;
    }

    public RichPopup getBusinessAddressConfirmPopup() {
        return businessAddressConfirmPopup;
    }

    public void setHomeAddressConfirmPopup(RichPopup homeAddressConfirmPopup) {
        this.homeAddressConfirmPopup = homeAddressConfirmPopup;
    }

    public RichPopup getHomeAddressConfirmPopup() {
        return homeAddressConfirmPopup;
    }

    public void setAddressOptionsRdBtn(RichSelectOneRadio addressOptionsRdBtn) {
        this.addressOptionsRdBtn = addressOptionsRdBtn;
    }

    public RichSelectOneRadio getAddressOptionsRdBtn() {
        return addressOptionsRdBtn;
    }

    public void setCountryPartySelOneCho(RichSelectOneChoice countryPartySelOneCho) {
        this.countryPartySelOneCho = countryPartySelOneCho;
    }

    public RichSelectOneChoice getCountryPartySelOneCho() {
        return countryPartySelOneCho;
    }

    public void setStatesUSPartySelOneCho(RichSelectOneChoice statesUSPartySelOneCho) {
        this.statesUSPartySelOneCho = statesUSPartySelOneCho;
    }

    public RichSelectOneChoice getStatesUSPartySelOneCho() {
        return statesUSPartySelOneCho;
    }

    public void setStatesAUPartySelOneCho(RichSelectOneChoice statesAUPartySelOneCho) {
        this.statesAUPartySelOneCho = statesAUPartySelOneCho;
    }

    public RichSelectOneChoice getStatesAUPartySelOneCho() {
        return statesAUPartySelOneCho;
    }

    public void setStatesCAPartySelOneCho(RichSelectOneChoice statesCAPartySelOneCho) {
        this.statesCAPartySelOneCho = statesCAPartySelOneCho;
    }

    public RichSelectOneChoice getStatesCAPartySelOneCho() {
        return statesCAPartySelOneCho;
    }

    public void setCountryHomeSelOneCho(RichSelectOneChoice countryHomeSelOneCho) {
        this.countryHomeSelOneCho = countryHomeSelOneCho;
    }

    public RichSelectOneChoice getCountryHomeSelOneCho() {
        return countryHomeSelOneCho;
    }

    public void setPartyIdIpTx(RichInputText partyIdIpTx) {
        this.partyIdIpTx = partyIdIpTx;
    }

    public RichInputText getPartyIdIpTx() {
        return partyIdIpTx;
    }

    public void setPartyNameIpLOV(RichInputListOfValues partyNameIpLOV) {
        this.partyNameIpLOV = partyNameIpLOV;
    }

    public RichInputListOfValues getPartyNameIpLOV() {
        return partyNameIpLOV;
    }

    public void setAddress1PartyIpTx(RichInputText address1PartyIpTx) {
        this.address1PartyIpTx = address1PartyIpTx;
    }

    public RichInputText getAddress1PartyIpTx() {
        return address1PartyIpTx;
    }

    public void setAddress2PartyIpTx(RichInputText address2PartyIpTx) {
        this.address2PartyIpTx = address2PartyIpTx;
    }

    public RichInputText getAddress2PartyIpTx() {
        return address2PartyIpTx;
    }

    public void setAddress3PartyIpTx(RichInputText address3PartyIpTx) {
        this.address3PartyIpTx = address3PartyIpTx;
    }

    public RichInputText getAddress3PartyIpTx() {
        return address3PartyIpTx;
    }

    public void setAddress4PartyIpTx(RichInputText address4PartyIpTx) {
        this.address4PartyIpTx = address4PartyIpTx;
    }

    public RichInputText getAddress4PartyIpTx() {
        return address4PartyIpTx;
    }

    public void setCityPartyIpTx(RichInputText cityPartyIpTx) {
        this.cityPartyIpTx = cityPartyIpTx;
    }

    public RichInputText getCityPartyIpTx() {
        return cityPartyIpTx;
    }

    public void setPostalCodePartyIpTx(RichInputText postalCodePartyIpTx) {
        this.postalCodePartyIpTx = postalCodePartyIpTx;
    }

    public RichInputText getPostalCodePartyIpTx() {
        return postalCodePartyIpTx;
    }

    public void setCountyPartyIpTx(RichInputText countyPartyIpTx) {
        this.countyPartyIpTx = countyPartyIpTx;
    }

    public RichInputText getCountyPartyIpTx() {
        return countyPartyIpTx;
    }

    public void setPhonePartyIpTx(RichInputText phonePartyIpTx) {
        this.phonePartyIpTx = phonePartyIpTx;
    }

    public RichInputText getPhonePartyIpTx() {
        return phonePartyIpTx;
    }

    public void setCountryBusNewInstSelOneCho(RichSelectOneChoice countryBusNewInstSelOneCho) {
        this.countryBusNewInstSelOneCho = countryBusNewInstSelOneCho;
    }

    public RichSelectOneChoice getCountryBusNewInstSelOneCho() {
        return countryBusNewInstSelOneCho;
    }

    public void setFaxExtPartyIpTx(RichInputText faxExtPartyIpTx) {
        this.faxExtPartyIpTx = faxExtPartyIpTx;
    }

    public RichInputText getFaxExtPartyIpTx() {
        return faxExtPartyIpTx;
    }

    public void setFaxPartyIpTx(RichInputText faxPartyIpTx) {
        this.faxPartyIpTx = faxPartyIpTx;
    }

    public RichInputText getFaxPartyIpTx() {
        return faxPartyIpTx;
    }

    public void setPhoneExtPartyIpTx(RichInputText phoneExtPartyIpTx) {
        this.phoneExtPartyIpTx = phoneExtPartyIpTx;
    }

    public RichInputText getPhoneExtPartyIpTx() {
        return phoneExtPartyIpTx;
    }

    public void setStatesUSNewInstSelOneCho(RichSelectOneChoice statesUSNewInstSelOneCho) {
        this.statesUSNewInstSelOneCho = statesUSNewInstSelOneCho;
    }

    public RichSelectOneChoice getStatesUSNewInstSelOneCho() {
        return statesUSNewInstSelOneCho;
    }

    public void setInstitutionNameBusNewInstIpTx(RichInputText institutionNameBusNewInstIpTx) {
        this.institutionNameBusNewInstIpTx = institutionNameBusNewInstIpTx;
    }

    public RichInputText getInstitutionNameBusNewInstIpTx() {
        return institutionNameBusNewInstIpTx;
    }

    public void setAddress1BusNewInstIpTx(RichInputText address1BusNewInstIpTx) {
        this.address1BusNewInstIpTx = address1BusNewInstIpTx;
    }

    public RichInputText getAddress1BusNewInstIpTx() {
        return address1BusNewInstIpTx;
    }

    public void setAddress2BusNewInstIpTx(RichInputText address2BusNewInstIpTx) {
        this.address2BusNewInstIpTx = address2BusNewInstIpTx;
    }

    public RichInputText getAddress2BusNewInstIpTx() {
        return address2BusNewInstIpTx;
    }

    public void setAddress3BusNewInstIpTx(RichInputText address3BusNewInstIpTx) {
        this.address3BusNewInstIpTx = address3BusNewInstIpTx;
    }

    public RichInputText getAddress3BusNewInstIpTx() {
        return address3BusNewInstIpTx;
    }

    public void setAddress4BusNewInstIpTx(RichInputText address4BusNewInstIpTx) {
        this.address4BusNewInstIpTx = address4BusNewInstIpTx;
    }

    public RichInputText getAddress4BusNewInstIpTx() {
        return address4BusNewInstIpTx;
    }

    public void setStatesAUNewInstSelOneCho(RichSelectOneChoice statesAUNewInstSelOneCho) {
        this.statesAUNewInstSelOneCho = statesAUNewInstSelOneCho;
    }

    public RichSelectOneChoice getStatesAUNewInstSelOneCho() {
        return statesAUNewInstSelOneCho;
    }

    public void setStatesCANewInstSelOneCho(RichSelectOneChoice statesCANewInstSelOneCho) {
        this.statesCANewInstSelOneCho = statesCANewInstSelOneCho;
    }

    public RichSelectOneChoice getStatesCANewInstSelOneCho() {
        return statesCANewInstSelOneCho;
    }

    public void setStatesOtherNewInstIpTx(RichInputText statesOtherNewInstIpTx) {
        this.statesOtherNewInstIpTx = statesOtherNewInstIpTx;
    }

    public RichInputText getStatesOtherNewInstIpTx() {
        return statesOtherNewInstIpTx;
    }

    public void setCityBusNewInstIpTx(RichInputText cityBusNewInstIpTx) {
        this.cityBusNewInstIpTx = cityBusNewInstIpTx;
    }

    public RichInputText getCityBusNewInstIpTx() {
        return cityBusNewInstIpTx;
    }

    public void setPostalCodeBusNewInstIpTx(RichInputText postalCodeBusNewInstIpTx) {
        this.postalCodeBusNewInstIpTx = postalCodeBusNewInstIpTx;
    }

    public RichInputText getPostalCodeBusNewInstIpTx() {
        return postalCodeBusNewInstIpTx;
    }

    public void setCountyBusNewInstIpTx(RichInputText countyBusNewInstIpTx) {
        this.countyBusNewInstIpTx = countyBusNewInstIpTx;
    }

    public RichInputText getCountyBusNewInstIpTx() {
        return countyBusNewInstIpTx;
    }

    public void setPhoneBusNewInstIpTx(RichInputText phoneBusNewInstIpTx) {
        this.phoneBusNewInstIpTx = phoneBusNewInstIpTx;
    }

    public RichInputText getPhoneBusNewInstIpTx() {
        return phoneBusNewInstIpTx;
    }

    public void setPhoneExtBusNewInstIpTx(RichInputText phoneExtBusNewInstIpTx) {
        this.phoneExtBusNewInstIpTx = phoneExtBusNewInstIpTx;
    }

    public RichInputText getPhoneExtBusNewInstIpTx() {
        return phoneExtBusNewInstIpTx;
    }

    public void setFaxBusNewInstIpTx(RichInputText faxBusNewInstIpTx) {
        this.faxBusNewInstIpTx = faxBusNewInstIpTx;
    }

    public RichInputText getFaxBusNewInstIpTx() {
        return faxBusNewInstIpTx;
    }

    public void setFaxExtBusNewInstIpTx(RichInputText faxExtBusNewInstIpTx) {
        this.faxExtBusNewInstIpTx = faxExtBusNewInstIpTx;
    }

    public RichInputText getFaxExtBusNewInstIpTx() {
        return faxExtBusNewInstIpTx;
    }

    public void setAddress1HomeIpTx(RichInputText address1HomeIpTx) {
        this.address1HomeIpTx = address1HomeIpTx;
    }

    public RichInputText getAddress1HomeIpTx() {
        return address1HomeIpTx;
    }

    public void setAddress2HomeIpTx(RichInputText address2HomeIpTx) {
        this.address2HomeIpTx = address2HomeIpTx;
    }

    public RichInputText getAddress2HomeIpTx() {
        return address2HomeIpTx;
    }

    public void setAddress3HomeIpTx(RichInputText address3HomeIpTx) {
        this.address3HomeIpTx = address3HomeIpTx;
    }

    public RichInputText getAddress3HomeIpTx() {
        return address3HomeIpTx;
    }

    public void setAddress4HomeIpTx(RichInputText address4HomeIpTx) {
        this.address4HomeIpTx = address4HomeIpTx;
    }

    public RichInputText getAddress4HomeIpTx() {
        return address4HomeIpTx;
    }

    public void setStatesAUHomeSelOneCho(RichSelectOneChoice statesAUHomeSelOneCho) {
        this.statesAUHomeSelOneCho = statesAUHomeSelOneCho;
    }

    public RichSelectOneChoice getStatesAUHomeSelOneCho() {
        return statesAUHomeSelOneCho;
    }

    public void setStatesCAHomeSelOneCho(RichSelectOneChoice statesCAHomeSelOneCho) {
        this.statesCAHomeSelOneCho = statesCAHomeSelOneCho;
    }

    public RichSelectOneChoice getStatesCAHomeSelOneCho() {
        return statesCAHomeSelOneCho;
    }

    public void setStatesOtherHomeIpTx(RichInputText statesOtherHomeIpTx) {
        this.statesOtherHomeIpTx = statesOtherHomeIpTx;
    }

    public RichInputText getStatesOtherHomeIpTx() {
        return statesOtherHomeIpTx;
    }

    public void setCityHomeIpTx(RichInputText cityHomeIpTx) {
        this.cityHomeIpTx = cityHomeIpTx;
    }

    public RichInputText getCityHomeIpTx() {
        return cityHomeIpTx;
    }

    public void setPostalCodeHomeIpTx(RichInputText postalCodeHomeIpTx) {
        this.postalCodeHomeIpTx = postalCodeHomeIpTx;
    }

    public RichInputText getPostalCodeHomeIpTx() {
        return postalCodeHomeIpTx;
    }

    public void setCountyHomeIpTx(RichInputText countyHomeIpTx) {
        this.countyHomeIpTx = countyHomeIpTx;
    }

    public RichInputText getCountyHomeIpTx() {
        return countyHomeIpTx;
    }

    public void setPhoneHomeIpTx(RichInputText phoneHomeIpTx) {
        this.phoneHomeIpTx = phoneHomeIpTx;
    }

    public RichInputText getPhoneHomeIpTx() {
        return phoneHomeIpTx;
    }

    public void setFaxHomeIpTx(RichInputText faxHomeIpTx) {
        this.faxHomeIpTx = faxHomeIpTx;
    }

    public RichInputText getFaxHomeIpTx() {
        return faxHomeIpTx;
    }

    public void setBrowseInstAddressConfirmPopup(RichPopup browseInstAddressConfirmPopup) {
        this.browseInstAddressConfirmPopup = browseInstAddressConfirmPopup;
    }

    public RichPopup getBrowseInstAddressConfirmPopup() {
        return browseInstAddressConfirmPopup;
    }

    public void setNewInstAddressConfirmPopup(RichPopup newInstAddressConfirmPopup) {
        this.newInstAddressConfirmPopup = newInstAddressConfirmPopup;
    }

    public RichPopup getNewInstAddressConfirmPopup() {
        return newInstAddressConfirmPopup;
    }

    public void setBrowseInstCmdLnk(RichCommandLink browseInstCmdLnk) {
        this.browseInstCmdLnk = browseInstCmdLnk;
    }

    public RichCommandLink getBrowseInstCmdLnk() {
        return browseInstCmdLnk;
    }

    public void setBrowseInstOpLbl(RichOutputLabel browseInstOpLbl) {
        this.browseInstOpLbl = browseInstOpLbl;
    }

    public RichOutputLabel getBrowseInstOpLbl() {
        return browseInstOpLbl;
    }

    public void setBrowseInstPnlFrm(RichPanelFormLayout browseInstPnlFrm) {
        this.browseInstPnlFrm = browseInstPnlFrm;
    }

    public RichPanelFormLayout getBrowseInstPnlFrm() {
        return browseInstPnlFrm;
    }

    public void setNewInstCmdLnk(RichCommandLink newInstCmdLnk) {
        this.newInstCmdLnk = newInstCmdLnk;
    }

    public RichCommandLink getNewInstCmdLnk() {
        return newInstCmdLnk;
    }

    public void setNewInstOpLbl(RichOutputText newInstOpLbl) {
        this.newInstOpLbl = newInstOpLbl;
    }

    public RichOutputText getNewInstOpLbl() {
        return newInstOpLbl;
    }

    public void setNewInstPnlFrm(RichPanelFormLayout newInstPnlFrm) {
        this.newInstPnlFrm = newInstPnlFrm;
    }

    public RichPanelFormLayout getNewInstPnlFrm() {
        return newInstPnlFrm;
    }

    public void setHomeAddressPnlGrp(RichPanelGroupLayout homeAddressPnlGrp) {
        this.homeAddressPnlGrp = homeAddressPnlGrp;
    }

    public RichPanelGroupLayout getHomeAddressPnlGrp() {
        return homeAddressPnlGrp;
    }

    public void setBusinessAddressPnlGrp(RichPanelGroupLayout businessAddressPnlGrp) {
        this.businessAddressPnlGrp = businessAddressPnlGrp;
    }

    public RichPanelGroupLayout getBusinessAddressPnlGrp() {
        return businessAddressPnlGrp;
    }

    public void setInstitutionOptionsRdBtn(RichSelectOneRadio institutionOptionsRdBtn) {
        this.institutionOptionsRdBtn = institutionOptionsRdBtn;
    }

    public RichSelectOneRadio getInstitutionOptionsRdBtn() {
        return institutionOptionsRdBtn;
    }

    public void initMethod(PhaseEvent phaseEvent) {

        if (phaseEvent.getPhaseId().equals(phaseEvent.getPhaseId().RENDER_RESPONSE)) {
            JUCtrlAttrsBinding emailAddressGet = (JUCtrlAttrsBinding) bindings.findNamedObject("EmailAddressGet");
            if (emailAddressGet != null) {
                if (emailAddressGet.toString().contains("@cap.org")) {
                    buttonsPnlGrp.setVisible(false);
                }
            }
            String amDef = "org.cap.myAccount.myAccountModel.MyAccountAM";
            String config = "MyAccountAMLocal";
            ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
            try {
                JUCtrlAttrsBinding LocationIDBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("LocationIDBusGet");
                JUCtrlAttrsBinding LocationIDHomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("LocationIDHomeGet");
                JUCtrlAttrsBinding LicenseNumberGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("LicenseNumberGet");
                JUCtrlAttrsBinding HomePrefGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PreferredFlagHomeGet");
                JUCtrlAttrsBinding BusPrefGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PreferredFlagBusGet");

                Object busLocationID = LocationIDBusGet.getAttribute("LocationID");
                Object homeLocationId = LocationIDHomeGet.getAttribute("LocationID");
                Object floridaLicenseNumberGet = LicenseNumberGet.getAttribute("LicenseNumber");
                Object homePrefGet = HomePrefGet.getAttribute("PreferredFlag");
                Object busPrefGet = BusPrefGet.getAttribute("PreferredFlag");

                if (getAddressOptionsRdBtn().getValue() == null) {
                    getInstitutionOptionsRdBtn().setValue("browseInst");
                    disableBusNewInstLayoutFlds();

                    if (busLocationID != null && homeLocationId != null) {

                        getAddressOptionsRdBtn().setValue("businesshome");
                        clearPartyBindings();
                        loadBusinessAddress();
                        loadHomeAddress();
                        enableBusinessLayoutFlds();
                        enableHomeLayoutFlds();
                        enableBusBrowstInstLayoutFlds();
                        if (homePrefGet != null && homePrefGet.equals("Y")) {
                            getAddressPreferenceRdBtn().setValue("home");
                        }
                        if (busPrefGet != null && busPrefGet.equals("Y")) {
                            getAddressPreferenceRdBtn().setValue("business");
                        }
                    } else if (busLocationID != null && homeLocationId == null) {

                        getAddressOptionsRdBtn().setValue("business");
                        getAddressPreferenceRdBtn().setValue("business");
                        clearPartyBindings();
                        loadBusinessAddress();
                        enableBusinessLayoutFlds();
                        disableHomeLayoutFlds();
                        enableBusBrowstInstLayoutFlds();
                    } else if (homeLocationId != null && busLocationID == null) {

                        getAddressOptionsRdBtn().setValue("home");
                        getAddressPreferenceRdBtn().setValue("home");
                        clearPartyBindings();
                        disablePartyInfoFlds();
                        loadHomeAddress();
                        disableBusinessLayoutFlds();
                        enableHomeLayoutFlds();
                        enableBusBrowstInstLayoutFlds();
                    } else if (busLocationID == null && homeLocationId == null) {
                        getAddressOptionsRdBtn().setValue("business");
                        getAddressPreferenceRdBtn().setValue("business");
                        getInstitutionOptionsRdBtn().setValue("browseInst");
                        clearPartyBindings();
                        enableBusinessLayoutFlds();
                        enableBusBrowstInstLayoutFlds();
                        disableHomeLayoutFlds();
                        disableBusNewInstLayoutFlds();
                        disablePartyInfoFlds();
                    }

                    if (busLocationID != null) {
                        ViewObject vo = am.findViewObject("GetPersonPrimRelDetailsLovVO1");
                        JUCtrlAttrsBinding PersonIDBind = (JUCtrlAttrsBinding) bindings.findNamedObject("PersonID");
                        Object PersonID = PersonIDBind.getAttribute("PersonID");
                        vo.setNamedWhereClauseParam("partyId", PersonID);
                        vo.executeQuery();

                        if (vo.hasNext()) {
                            getDontUpdateNoteInstPnlFrm().setVisible(true);
                            getUpdateNoteInstPnlFrm().setVisible(false);
                            getPartyNameIpLOV().setDisabled(true);
                            disablePartyInfoFlds();
                            disableBusNewInstLayoutFlds();
                            getNewInstCmdLnk().setDisabled(true);
                            getBusinessAddrOptionRdBtn().setDisabled(true);
                            getHomeAddrOptionRdBtn().setDisabled(true);
                        } else {
                            getDontUpdateNoteInstPnlFrm().setVisible(false);
                            getUpdateNoteInstPnlFrm().setVisible(true);

                        }
                    }
                }
                floridaFlds();
                if (floridaLicenseNumberGet != null) {
                    getFloridaLicensePnlGrp().setVisible(true);
                    getFloridaLicenseCmdImgLnk().setVisible(false);
                    getFloridaLicenseImgLbl().setVisible(true);
                    getLicensePnlGrp().setVisible(true);
                    JUCtrlAttrsBinding flLicenseGet = (JUCtrlAttrsBinding) bindings
                            .findNamedObject("LicenseNumberGet");

                    getLicenseNumberIpTx().setValue(flLicenseGet.getAttribute("LicenseNumber"));
                    getLicenseNumberIpTx().setReadOnly(true);
                }

            } catch (Exception e) {

                sLog.debug(e.getMessage(), e);
                e.printStackTrace();
            } finally {
                Configuration.releaseRootApplicationModule(am, true);
            }
        }
    }

    public void loadHomeAddress() {

        sLog.info("In loadHomeAddress method in AddressBookBackingBean");

        JUCtrlAttrsBinding address1HomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address1HomeGet");
        JUCtrlAttrsBinding address2HomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address2HomeGet");
        JUCtrlAttrsBinding address3HomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3HomeGet");
        JUCtrlAttrsBinding address4HomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address4HomeGet");
        JUCtrlAttrsBinding countryHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CountryHomeGet");
        JUCtrlAttrsBinding stateHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("StateHomeGet");
        JUCtrlAttrsBinding cityHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CityHomeGet");
        JUCtrlAttrsBinding postalCodeHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PostalCodeHomeGet");
        JUCtrlAttrsBinding countyHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CountyHomeGet");
        JUCtrlAttrsBinding phoneRawNumberHomeGet = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneRawNumberHomeGet");
        JUCtrlAttrsBinding faxRawNumberHomeGet = (JUCtrlAttrsBinding) bindings
                .findNamedObject("FaxRawNumberHomeGet");

        getAddress1HomeIpTx().setValue(address1HomeGet.getAttribute("Address1"));
        getAddress2HomeIpTx().setValue(address2HomeGet.getAttribute("Address2"));
        getAddress3HomeIpTx().setValue(address3HomeGet.getAttribute("Address3"));
        getAddress4HomeIpTx().setValue(address4HomeGet.getAttribute("Address4"));
        if (getCountryHomeSelOneCho().getValue() != null) {
            getCountryHomeSelOneCho().setValue(countryHomeGet.getAttribute("Country"));
        } else {
            getCountryHomeSelOneCho().setValue("US");
        }
        if (getCountryHomeSelOneCho().getValue().equals("US")) {
            getStatesUSHomeSelOneCho().setValue(stateHomeGet.getAttribute("State"));
        }
        if (getCountryHomeSelOneCho().getValue().equals("AU")) {
            getStatesAUHomeSelOneCho().setValue(stateHomeGet.getAttribute("State"));
        }
        if (getCountryHomeSelOneCho().getValue().equals("CA")) {
            getStatesCAHomeSelOneCho().setValue(stateHomeGet.getAttribute("State"));
        }
        if (!getCountryHomeSelOneCho().getValue().equals("CA") && !getCountryHomeSelOneCho().getValue().equals("AU")
                && !getCountryHomeSelOneCho().getValue().equals("US")) {
            getStatesOtherHomeIpTx().setValue(stateHomeGet.getAttribute("State"));
        }

        getCityHomeIpTx().setValue(cityHomeGet.getAttribute("City"));
        getPostalCodeHomeIpTx().setValue(postalCodeHomeGet.getAttribute("PostalCode"));
        getCountyHomeIpTx().setValue(countyHomeGet.getAttribute("County"));

        if (phoneRawNumberHomeGet.getAttribute("RawNumber") != null
                && phoneRawNumberHomeGet.getAttribute("RawNumber").toString().contains("-")) {
            getPhoneHomeIpTx()
                    .setValue(phoneRawNumberHomeGet.getAttribute("RawNumber").toString().replace("-", ""));
        } else {
            getPhoneHomeIpTx().setValue(phoneRawNumberHomeGet.getAttribute("RawNumber"));
        }
        if (faxRawNumberHomeGet.getAttribute("RawNumber") != null
                && faxRawNumberHomeGet.getAttribute("RawNumber").toString().contains("-")) {
            getFaxHomeIpTx().setValue(faxRawNumberHomeGet.getAttribute("RawNumber").toString().replace("-", ""));
        } else {
            getFaxHomeIpTx().setValue(faxRawNumberHomeGet.getAttribute("RawNumber"));
        }

    }

    public void loadBusinessAddress() {

        JUCtrlAttrsBinding institutionIDBusGet = (JUCtrlAttrsBinding) bindings
                .findNamedObject("InstitutionIDBusGet");
        JUCtrlAttrsBinding institutionNameBusGet = (JUCtrlAttrsBinding) bindings
                .findNamedObject("InstitutionNameBusGet");
        JUCtrlAttrsBinding address1BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address1BusGet");
        JUCtrlAttrsBinding address2BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address2BusGet");
        JUCtrlAttrsBinding address3BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3BusGet");
        JUCtrlAttrsBinding address4BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address4BusGet");
        JUCtrlAttrsBinding countryBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CountryBusGet");
        JUCtrlAttrsBinding stateBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("StateBusGet");
        JUCtrlAttrsBinding cityBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CityBusGet");
        JUCtrlAttrsBinding postalCodeBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("PostalCodeBusGet");
        JUCtrlAttrsBinding countyBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CountyBusGet");

        JUCtrlAttrsBinding phoneRawNumberBusGet = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneRawNumberBusGet");
        JUCtrlAttrsBinding phoneExtensionBusGet = (JUCtrlAttrsBinding) bindings
                .findNamedObject("PhoneExtensionBusGet");
        JUCtrlAttrsBinding faxRawNumberBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxRawNumberBusGet");
        JUCtrlAttrsBinding faxExtensionBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("FaxExtensionBusGet");

        getPartyIdIpTx().setValue(institutionIDBusGet.getAttribute("InstitutionID"));
        getPartyNameIpLOV().setValue(institutionNameBusGet.getAttribute("InstitutionName"));
        getAddress1PartyIpTx().setValue(address1BusGet.getAttribute("Address1"));
        getAddress2PartyIpTx().setValue(address2BusGet.getAttribute("Address2"));
        getAddress3PartyIpTx().setValue(address3BusGet.getAttribute("Address3"));
        getAddress4PartyIpTx().setValue(address4BusGet.getAttribute("Address4"));
        getCountryPartySelOneCho().setValue(countryBusGet.getAttribute("Country"));
        getCityPartyIpTx().setValue(cityBusGet.getAttribute("City"));
        getPostalCodePartyIpTx().setValue(postalCodeBusGet.getAttribute("PostalCode"));
        getCountyPartyIpTx().setValue(countyBusGet.getAttribute("County"));

        if (phoneRawNumberBusGet.getAttribute("RawNumber") != null
                && phoneRawNumberBusGet.getAttribute("RawNumber").toString().contains("-")) {
            getPhonePartyIpTx()
                    .setValue(phoneRawNumberBusGet.getAttribute("RawNumber").toString().replace("-", ""));
        } else {
            getPhonePartyIpTx().setValue(phoneRawNumberBusGet.getAttribute("RawNumber"));
        }
        if (faxRawNumberBusGet.getAttribute("RawNumber") != null
                && faxRawNumberBusGet.getAttribute("RawNumber").toString().contains("-")) {
            getFaxPartyIpTx().setValue(faxRawNumberBusGet.getAttribute("RawNumber").toString().replace("-", ""));
        } else {
            getFaxPartyIpTx().setValue(faxRawNumberBusGet.getAttribute("RawNumber"));
        }
        if (getCountryPartySelOneCho().getValue().equals("US")) {
            getStatesUSPartySelOneCho().setValue(stateBusGet.getAttribute("State"));
        }
        if (getCountryPartySelOneCho().getValue().equals("AU")) {
            getStatesAUPartySelOneCho().setValue(stateBusGet.getAttribute("State"));
        }
        if (getCountryPartySelOneCho().getValue().equals("CA")) {
            getStatesCAPartySelOneCho().setValue(stateBusGet.getAttribute("State"));
        }
        if (!getCountryPartySelOneCho().getValue().equals("CA")
                && !getCountryPartySelOneCho().getValue().equals("AU")
                && !getCountryPartySelOneCho().getValue().equals("US")) {
            getStatesOthersPartyIpTx().setValue(stateBusGet.getAttribute("State"));
        }
        getPartyNameIpLOV().setAutoSubmit(true);
    }

    public void clearPartyBindings() {
        JUCtrlAttrsBinding PartyName = (JUCtrlAttrsBinding) bindings.findNamedObject("PartyName");
        JUCtrlAttrsBinding PartyId = (JUCtrlAttrsBinding) bindings.findNamedObject("PartyId");
        JUCtrlAttrsBinding Address1 = (JUCtrlAttrsBinding) bindings.findNamedObject("Address1");
        JUCtrlAttrsBinding Address2 = (JUCtrlAttrsBinding) bindings.findNamedObject("Address2");
        JUCtrlAttrsBinding Address3 = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3");
        JUCtrlAttrsBinding Address4 = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3");
        JUCtrlAttrsBinding Country = (JUCtrlAttrsBinding) bindings.findNamedObject("Country");
        JUCtrlAttrsBinding State = (JUCtrlAttrsBinding) bindings.findNamedObject("State");
        JUCtrlAttrsBinding City = (JUCtrlAttrsBinding) bindings.findNamedObject("City");
        JUCtrlAttrsBinding PostalCode = (JUCtrlAttrsBinding) bindings.findNamedObject("PostalCode");

        PartyName.setAttribute("PartyName", " ");
        PartyId.setAttribute("PartyId", " ");
        Address1.setAttribute("Address1", " ");
        Address2.setAttribute("Address2", " ");
        Address3.setAttribute("Address3", " ");
        Address3.setAttribute("Address3", " ");
        Country.setAttribute("Country", " ");
        State.setAttribute("State", " ");
        City.setAttribute("City", " ");
        PostalCode.setAttribute("PostalCode", " ");
    }

    public void enableBusBrowstInstLayoutFlds() {
        getBrowseInstPnlFrm().setVisible(true);
        getBrowseInstOpLbl().setVisible(true);
        getBrowseInstCmdLnk().setVisible(false);
    }

    public void disableBusBrowstInstLayoutFlds() {
        getBrowseInstPnlFrm().setVisible(false);
        getBrowseInstOpLbl().setVisible(false);
        getBrowseInstCmdLnk().setVisible(true);
    }

    public void enableBusNewInstLayoutFlds() {
        getNewInstCmdLnk().setVisible(false);
        getNewInstOpLbl().setVisible(true);
        getNewInstPnlFrm().setVisible(true);
    }

    public void disableBusNewInstLayoutFlds() {
        getNewInstCmdLnk().setVisible(true);
        getNewInstOpLbl().setVisible(false);
        getNewInstPnlFrm().setVisible(false);
    }

    public void enableBusinessLayoutFlds() {
        getBusinessOutputLabel().setVisible(true);
        getBusinessAddressPnlGrp().setVisible(true);
    }

    public void disableBusinessLayoutFlds() {
        getBusinessOutputLabel().setVisible(false);
        getBusinessAddressPnlGrp().setVisible(false);
    }

    public void enableHomeLayoutFlds() {
        getHomeOutputLabel().setVisible(true);
        getHomeAddressPnlGrp().setVisible(true);
    }

    public void disableHomeLayoutFlds() {
        getHomeOutputLabel().setVisible(false);
        getHomeAddressPnlGrp().setVisible(false);
    }

    public void countryPartySelOneChoValueChangeListener(ValueChangeEvent valueChangeEvent) {
        floridaFlds();
        if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("US")) {
            getStatesAUPartySelOneCho().setValue("");
            getStatesCAPartySelOneCho().setValue("");
            getStatesOthersPartyIpTx().setValue("");
        } else if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("AU")) {
            getStatesUSPartySelOneCho().setValue("");
            getStatesCAPartySelOneCho().setValue("");
            getStatesOthersPartyIpTx().setValue("");

        } else if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("CA")) {
            getStatesUSPartySelOneCho().setValue("");
            getStatesAUPartySelOneCho().setValue("");
            getStatesOthersPartyIpTx().setValue("");
        } else if (valueChangeEvent.getNewValue() != null && !valueChangeEvent.getNewValue().equals("US")
                && !valueChangeEvent.getNewValue().equals("AU") && !valueChangeEvent.getNewValue().equals("CA")) {
            getStatesUSPartySelOneCho().setValue("");
            getStatesAUPartySelOneCho().setValue("");
            getStatesCAPartySelOneCho().setValue("");

        }
    }

    public void countryHomeSelOneChoValueChangeListener(ValueChangeEvent valueChangeEvent) {

        floridaFlds();
        if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("US")) {
            getStatesAUHomeSelOneCho().setValue("");
            getStatesCAHomeSelOneCho().setValue("");
            getStatesOtherHomeIpTx().setValue("");

        } else if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("AU")) {
            getStatesUSHomeSelOneCho().setValue("");
            getStatesCAHomeSelOneCho().setValue("");
            getStatesOtherHomeIpTx().setValue("");

        } else if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("CA")) {
            getStatesUSHomeSelOneCho().setValue("");
            getStatesAUHomeSelOneCho().setValue("");
            getStatesOtherHomeIpTx().setValue("");

        } else if (valueChangeEvent.getNewValue() != null && !valueChangeEvent.getNewValue().equals("US")
                && !valueChangeEvent.getNewValue().equals("AU") && !valueChangeEvent.getNewValue().equals("CA")) {
            getStatesUSHomeSelOneCho().setValue("");
            getStatesAUHomeSelOneCho().setValue("");
            getStatesCAHomeSelOneCho().setValue("");

        }
    }

    public void countryNewInstSelOneChoValueChangeListener(ValueChangeEvent valueChangeEvent) {

        floridaFlds();
        if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("US")) {
            getStatesAUNewInstSelOneCho().setValue("");
            getStatesCANewInstSelOneCho().setValue("");
            getStatesOtherNewInstIpTx().setValue("");
        } else if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("AU")) {
            getStatesUSNewInstSelOneCho().setValue("");
            getStatesCANewInstSelOneCho().setValue("");
            getStatesOtherNewInstIpTx().setValue("");

        } else if (valueChangeEvent.getNewValue() != null && valueChangeEvent.getNewValue().equals("CA")) {
            getStatesUSNewInstSelOneCho().setValue("");
            getStatesAUNewInstSelOneCho().setValue("");
            getStatesOtherNewInstIpTx().setValue("");
        } else if (valueChangeEvent.getNewValue() != null && !valueChangeEvent.getNewValue().equals("US")
                && !valueChangeEvent.getNewValue().equals("AU") && !valueChangeEvent.getNewValue().equals("CA")) {
            getStatesUSNewInstSelOneCho().setValue("");
            getStatesAUNewInstSelOneCho().setValue("");
            getStatesCANewInstSelOneCho().setValue("");
        }
    }

    public String validatePartyPhone() {

        String status = "sucess";
        FacesContext context = FacesContext.getCurrentInstance();
        FacesMessage message = new FacesMessage();
        Pattern p1 = Pattern.compile(expr1);
        Pattern p2 = Pattern.compile(expr2);

        Matcher m1 = p1.matcher((String) getPhonePartyIpTx().getValue());
        Matcher m2 = p2.matcher((String) getPhonePartyIpTx().getValue());

        try {

            if (getCountryPartySelOneCho() != null && (getCountryPartySelOneCho().getValue().equals("US")
                    || getCountryPartySelOneCho().getValue().equals("CA"))) {

                if (!m1.find() && !m2.find()) {
                    message.setDetail(resourceBundle.getString("PHONE_FORMAT"));
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(getPhonePartyIpTx().getClientId(context), message);
                    status = "failure";
                }
            }
        } catch (MissingResourceException e) {
            sLog.debug(e.getMessage(), e);
            e.printStackTrace();
        }
        return status;
    }

    public String validatePartyFax() {

        String status = "sucess";
        FacesMessage message = new FacesMessage();
        FacesContext context = FacesContext.getCurrentInstance();
        Pattern p1 = Pattern.compile(expr1);
        Pattern p2 = Pattern.compile(expr2);

        Matcher m1 = p1.matcher((String) getFaxPartyIpTx().getValue());
        Matcher m2 = p2.matcher((String) getFaxPartyIpTx().getValue());

        try {
            if (getCountryPartySelOneCho() != null && (getCountryPartySelOneCho().getValue().equals("US")
                    || getCountryPartySelOneCho().getValue().equals("CA"))) {
                if (!m1.find() && !m2.find()) {
                    message.setDetail(resourceBundle.getString("FAX_FORMAT"));
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(getFaxPartyIpTx().getClientId(context), message);
                    status = "failure";
                }
            }

        } catch (MissingResourceException e) {
            sLog.debug(e.getMessage(), e);
            e.printStackTrace();
        }
        return status;
    }

    public String validateNewInstPhone() {

        String status = "sucess";
        FacesMessage message = new FacesMessage();
        FacesContext context = FacesContext.getCurrentInstance();

        Pattern p1 = Pattern.compile(expr1);
        Pattern p2 = Pattern.compile(expr2);

        Matcher m1 = p1.matcher((String) getPhoneBusNewInstIpTx().getValue());
        Matcher m2 = p2.matcher((String) getPhoneBusNewInstIpTx().getValue());

        try {
            if (getCountryBusNewInstSelOneCho() != null && (getCountryBusNewInstSelOneCho().getValue().equals("US")
                    || getCountryBusNewInstSelOneCho().getValue().equals("CA"))) {
                if (!m1.find() && !m2.find()) {
                    message.setDetail(resourceBundle.getString("PHONE_FORMAT"));
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(getPhoneBusNewInstIpTx().getClientId(context), message);
                    status = "failure";
                }
            }

        } catch (MissingResourceException e) {
            //sLog.debug(e.getMessage(),e);
            e.printStackTrace();
        }
        return status;
    }

    public String validateNewInstFax() {

        String status = "sucess";
        FacesMessage message = new FacesMessage();
        FacesContext context = FacesContext.getCurrentInstance();
        Pattern p1 = Pattern.compile(expr1);
        Pattern p2 = Pattern.compile(expr2);

        Matcher m1 = p1.matcher((String) getFaxBusNewInstIpTx().getValue());
        Matcher m2 = p2.matcher((String) getFaxBusNewInstIpTx().getValue());

        try {
            if (getCountryBusNewInstSelOneCho() != null && (getCountryBusNewInstSelOneCho().getValue().equals("US")
                    || getCountryBusNewInstSelOneCho().getValue().equals("CA"))) {
                if (!m1.find() && !m2.find()) {
                    message.setDetail(resourceBundle.getString("FAX_FORMAT"));
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(getFaxBusNewInstIpTx().getClientId(context), message);
                    status = "failure";
                }
            }

        } catch (MissingResourceException e) {
            //  sLog.debug(e.getMessage(),e);
            e.printStackTrace();
        }
        return status;
    }

    public String validateHomePhone() {

        String status = "sucess";
        FacesMessage message = new FacesMessage();
        FacesContext context = FacesContext.getCurrentInstance();
        Pattern p1 = Pattern.compile(expr1);
        Pattern p2 = Pattern.compile(expr2);

        Matcher m1 = p1.matcher((String) getPhoneHomeIpTx().getValue());
        Matcher m2 = p2.matcher((String) getPhoneHomeIpTx().getValue());

        try {
            if (getCountryHomeSelOneCho() != null && (getCountryHomeSelOneCho().getValue().equals("US")
                    || getCountryHomeSelOneCho().getValue().equals("CA"))) {
                if (!m1.find() && !m2.find()) {
                    message.setDetail(resourceBundle.getString("PHONE_FORMAT"));
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(getPhoneHomeIpTx().getClientId(context), message);
                    status = "failure";
                }
            }

        } catch (MissingResourceException e) {
            // sLog.debug(e.getMessage(),e);
            e.printStackTrace();
        }
        return status;
    }

    public String validateHomeFax() {

        String status = "sucess";
        FacesMessage message = new FacesMessage();
        FacesContext context = FacesContext.getCurrentInstance();
        Pattern p1 = Pattern.compile(expr1);
        Pattern p2 = Pattern.compile(expr2);

        Matcher m1 = p1.matcher((String) getFaxHomeIpTx().getValue());
        Matcher m2 = p2.matcher((String) getFaxHomeIpTx().getValue());

        try {

            if (getCountryHomeSelOneCho() != null && (getCountryHomeSelOneCho().getValue().equals("US")
                    || getCountryHomeSelOneCho().getValue().equals("CA")
                    || getCountryHomeSelOneCho().getValue().equals("PR"))) {
                if (!m1.find() && !m2.find()) {
                    message.setDetail(resourceBundle.getString("FAX_FORMAT"));
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                    context.addMessage(getFaxHomeIpTx().getClientId(context), message);
                    status = "failure";
                }
            }
        } catch (MissingResourceException e) {
            //   sLog.debug(e.getMessage(),e);
            e.printStackTrace();
        }
        return status;
    }

    public void lovLaunch(LaunchPopupEvent launchPopupEvent) {
        RichInputListOfValues inputListOfValues = (RichInputListOfValues) launchPopupEvent.getComponent();
        if (inputListOfValues != null) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            String clientId = inputListOfValues.getClientId(facesContext);
            StringBuffer scriptBuffer = new StringBuffer();
            scriptBuffer.append(
                    " var docComp = AdfPage.PAGE.findComponent(\"f1\"); var comp = AdfPage.PAGE.findComponent(\"");
            scriptBuffer.append(clientId).append("\");  ");
            scriptBuffer.append(" if (comp != null && docComp != null) { var CompId = comp.getId(); ");
            scriptBuffer.append(" AdfCustomEvent.queue(docComp,\"lovafterlaunch\",{compId:CompId},true);}");
            String script = scriptBuffer.toString();
            ExtendedRenderKitService erks = Service.getService(facesContext.getRenderKit(),
                    ExtendedRenderKitService.class);
            erks.addScript(facesContext, script);
        }
        // Add event code here...
    }

    public void lovAfterLaunch(ClientEvent clientEvent) {
        if (clientEvent.getParameters().size() > 0 && clientEvent.getParameters().get("compId") != null) {
            String compId = clientEvent.getParameters().get("compId").toString();
            RichInputListOfValues inputListOfValues = (RichInputListOfValues) JSFUtils.findComponentInRoot(compId);
            if (inputListOfValues != null) {
                Iterator<String> facetNames = inputListOfValues.getFacetNames();
                RichPopup richPopup = null;
                String facetName = null;
                UIComponent componentFacet = null;
                UIComponent componentdialog = null;
                while (facetNames.hasNext()) {
                    facetName = facetNames.next();
                    if (facetName != null) {
                        componentFacet = inputListOfValues.getFacet(facetName);
                        if (componentFacet != null && componentFacet instanceof RichPopup) {
                            richPopup = (RichPopup) componentFacet;
                            break;
                        }
                    }
                }
                if (richPopup != null) {
                    List<UIComponent> uiCompList = richPopup.getChildren();
                    if (uiCompList.size() > 0) {
                        componentdialog = uiCompList.get(0);
                        if (componentdialog != null && componentdialog instanceof RichDialog) {
                            RichDialog richDialog = (RichDialog) componentdialog;
                            if (richDialog != null) {
                                /*   richDialog.setAffirmativeTextAndAccessKey("&OK");
                                   richDialog.setCancelTextAndAccessKey("&Cancel"); */
                                AdfFacesContext.getCurrentInstance().addPartialTarget(richDialog);
                                if (richDialog.getChildCount() == 1 && richDialog.getChildren().get(0) != null
                                        && richDialog.getChildren().get(0) instanceof RichPanelGroupLayout) {
                                    RichPanelGroupLayout panelGroupLayout = (RichPanelGroupLayout) richDialog
                                            .getChildren().get(0);
                                    uiCompList = panelGroupLayout.getChildren();
                                    if (uiCompList.size() > 0 && uiCompList.get(0) != null
                                            && uiCompList.get(0) instanceof RichPanelHeader) {
                                        RichPanelHeader richPanelHeader = (RichPanelHeader) uiCompList.get(0);
                                        if (richPanelHeader.getChildCount() == 1
                                                && richPanelHeader.getChildren().get(0) != null
                                                && richPanelHeader.getChildren().get(0) instanceof RichQuery) {
                                            RichQuery richQuery = (RichQuery) richPanelHeader.getChildren().get(0);
                                            if (richQuery != null) {
                                                richQuery.setModeChangeVisible(false);
                                                richQuery.setHeaderText(
                                                        "Providing your CAP# /CLIA# will ensure that you are affiliated with the correct existing institution");
                                                AdfFacesContext.getCurrentInstance().addPartialTarget(richQuery);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // Add event code here...
    }

    public void setPartyNumberIpTx(RichInputText partyNumberIpTx) {
        this.partyNumberIpTx = partyNumberIpTx;
    }

    public RichInputText getPartyNumberIpTx() {
        return partyNumberIpTx;
    }

    public void setFloridaLicensePnlGrp(RichPanelGroupLayout floridaLicensePnlGrp) {
        this.floridaLicensePnlGrp = floridaLicensePnlGrp;
    }

    public RichPanelGroupLayout getFloridaLicensePnlGrp() {
        return floridaLicensePnlGrp;
    }

    public void floridaLicenseActionListener(ActionEvent actionEvent) {
        getLicensePnlGrp().setVisible(true);
        getFloridaLicenseCmdImgLnk().setVisible(false);
        getFloridaLicenseImgLbl().setVisible(true);
    }

    public void setLicensePnlGrp(RichPanelGroupLayout licensePnlGrp) {
        this.licensePnlGrp = licensePnlGrp;
    }

    public RichPanelGroupLayout getLicensePnlGrp() {
        return licensePnlGrp;
    }

    public void setLicenseNumberIpTx(RichInputText licenseNumberIpTx) {
        this.licenseNumberIpTx = licenseNumberIpTx;
    }

    public RichInputText getLicenseNumberIpTx() {
        return licenseNumberIpTx;
    }

    public void stateUSPartySelOneChoValueChangeListener(ValueChangeEvent valueChangeEvent) {
        floridaFlds();
    }

    public void statesUSNewInstSelOneChoValueChangeListener(ValueChangeEvent valueChangeEvent) {
        floridaFlds();
    }

    public void statesUSHomeSelOneChoValueChangeListener(ValueChangeEvent valueChangeEvent) {
        floridaFlds();
    }

    public void setFloridaLicenseImgLbl(RichImage floridaLicenseImgLbl) {
        this.floridaLicenseImgLbl = floridaLicenseImgLbl;
    }

    public RichImage getFloridaLicenseImgLbl() {
        return floridaLicenseImgLbl;
    }

    public void setFloridaLicenseCmdImgLnk(RichCommandImageLink floridaLicenseCmdImgLnk) {
        this.floridaLicenseCmdImgLnk = floridaLicenseCmdImgLnk;
    }

    public RichCommandImageLink getFloridaLicenseCmdImgLnk() {
        return floridaLicenseCmdImgLnk;
    }

    public boolean compareDataChanges() {

        if (getInstitutionOptionsRdBtn().getValue().equals("newInst")) {
            return true;
        }
        JUCtrlAttrsBinding LocationIDBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDBusGet");
        JUCtrlAttrsBinding LocationIDHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LocationIDHomeGet");
        Object busLocationID = LocationIDBusGet.getAttribute("LocationID");
        Object homeLocationId = LocationIDHomeGet.getAttribute("LocationID");
        String state = "";
        if (getAddressOptionsRdBtn().getValue().equals("business")
                || getAddressOptionsRdBtn().getValue().equals("businesshome")) {
            if (busLocationID == null && getPartyIdIpTx().getValue() != null
                    && !getPartyIdIpTx().getValue().toString().trim().equals("")) {
                return true;
            }
            if (busLocationID != null) {
                JUCtrlAttrsBinding institutionIDBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("InstitutionIDBusGet");
                JUCtrlAttrsBinding institutionNameBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("InstitutionNameBusGet");
                JUCtrlAttrsBinding address1BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address1BusGet");
                JUCtrlAttrsBinding address2BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address2BusGet");
                JUCtrlAttrsBinding address3BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address3BusGet");
                JUCtrlAttrsBinding address4BusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("Address4BusGet");
                JUCtrlAttrsBinding countryBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CountryBusGet");
                JUCtrlAttrsBinding stateBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("StateBusGet");
                JUCtrlAttrsBinding cityBusGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CityBusGet");
                JUCtrlAttrsBinding postalCodeBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PostalCodeBusGet");
                JUCtrlAttrsBinding phoneRawNumberBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PhoneRawNumberBusGet");
                JUCtrlAttrsBinding phoneExtensionBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PhoneExtensionBusGet");
                JUCtrlAttrsBinding faxRawNumberBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("FaxRawNumberBusGet");
                JUCtrlAttrsBinding faxExtensionBusGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("FaxExtensionBusGet");

                if (getCountryPartySelOneCho().getValue().equals("US")) {

                    state = (String) getStatesUSPartySelOneCho().getValue();
                }
                if (getCountryPartySelOneCho().getValue().equals("AU")) {

                    state = (String) getStatesAUPartySelOneCho().getValue();
                }
                if (getCountryPartySelOneCho().getValue().equals("CA")) {

                    state = (String) getStatesCAPartySelOneCho().getValue();
                }
                if (!getCountryPartySelOneCho().getValue().equals("US")
                        && !getCountryPartySelOneCho().getValue().equals("AU")
                        && !getCountryPartySelOneCho().getValue().equals("CA")) {

                    state = (String) getStatesOthersPartyIpTx().getValue();
                }

                if (getPartyIdIpTx().getValue() != null
                        && institutionIDBusGet.getAttribute("InstitutionID") != null) {
                    if (!getPartyIdIpTx().getValue().equals(institutionIDBusGet.getAttribute("InstitutionID")))
                        return true;
                }
                if (getPartyNameIpLOV().getValue() != null
                        && institutionNameBusGet.getAttribute("InstitutionName") != null) {
                    if (!getPartyNameIpLOV().getValue()
                            .equals(institutionNameBusGet.getAttribute("InstitutionName")))
                        return true;
                }
                if ((getAddress1PartyIpTx().getValue() != null && !getAddress1PartyIpTx().getValue().equals("")
                        && address1BusGet.getAttribute("Address1") == null)
                        || (address1BusGet.getAttribute("Address1") != null
                                && (getAddress1PartyIpTx().getValue() == null
                                        || (getAddress1PartyIpTx().getValue() != null
                                                && getAddress1PartyIpTx().getValue().equals(""))))) {
                    return true;
                }

                if ((getAddress2PartyIpTx().getValue() != null
                        && !getAddress2PartyIpTx().getValue().toString().trim().equals("")
                        && address2BusGet.getAttribute("Address2") == null)
                        || (address2BusGet.getAttribute("Address2") != null && (getAddress2PartyIpTx()
                                .getValue() == null
                                || (getAddress2PartyIpTx().getValue() != null
                                        && getAddress2PartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getAddress3PartyIpTx().getValue() != null
                        && !getAddress3PartyIpTx().getValue().toString().trim().equals("")
                        && address3BusGet.getAttribute("Address3") == null)
                        || (address3BusGet.getAttribute("Address3") != null && (getAddress3PartyIpTx()
                                .getValue() == null
                                || (getAddress3PartyIpTx().getValue() != null
                                        && getAddress3PartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getAddress4PartyIpTx().getValue() != null
                        && !getAddress4PartyIpTx().getValue().toString().trim().equals("")
                        && address4BusGet.getAttribute("Address4") == null)
                        || (address4BusGet.getAttribute("Address4") != null && (getAddress4PartyIpTx()
                                .getValue() == null
                                || (getAddress4PartyIpTx().getValue() != null
                                        && getAddress4PartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getCountryPartySelOneCho().getValue() != null
                        && !getCountryPartySelOneCho().getValue().equals("")
                        && countryBusGet.getAttribute("Country") == null)
                        || (countryBusGet.getAttribute("Country") != null
                                && (getCountryPartySelOneCho().getValue() == null
                                        || (getCountryPartySelOneCho().getValue() != null
                                                && getCountryPartySelOneCho().getValue().equals(""))))) {
                    return true;
                }

                if ((state != null && !state.equals("") && stateBusGet.getAttribute("State") == null)
                        || (stateBusGet.getAttribute("State") != null
                                && (state == null || (state != null && state.equals(""))))) {
                    return true;
                }

                if ((getCityPartyIpTx().getValue() != null
                        && !getCityPartyIpTx().getValue().toString().trim().equals("")
                        && cityBusGet.getAttribute("City") == null)
                        || (cityBusGet.getAttribute("City") != null
                                && (getCityPartyIpTx().getValue() == null || (getCityPartyIpTx().getValue() != null
                                        && getCityPartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getPostalCodePartyIpTx().getValue() != null
                        && !getPostalCodePartyIpTx().getValue().toString().trim().equals("")
                        && postalCodeBusGet.getAttribute("PostalCode") == null)
                        || (postalCodeBusGet.getAttribute("PostalCode") != null && (getPostalCodePartyIpTx()
                                .getValue() == null
                                || (getPostalCodePartyIpTx().getValue() != null
                                        && getPostalCodePartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }
                if ((getPhonePartyIpTx().getValue() != null
                        && !getPhonePartyIpTx().getValue().toString().trim().equals("")
                        && phoneRawNumberBusGet.getAttribute("RawNumber") == null)
                        || (phoneRawNumberBusGet.getAttribute("RawNumber") != null
                                && (getPhonePartyIpTx().getValue() == null
                                        || (getPhonePartyIpTx().getValue() != null
                                                && getPhonePartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }
                if ((getPhoneExtPartyIpTx().getValue() != null
                        && !getPhoneExtPartyIpTx().getValue().toString().trim().equals("")
                        && phoneExtensionBusGet.getAttribute("Extension") == null)
                        || (phoneExtensionBusGet.getAttribute("Extension") != null && (getPhoneExtPartyIpTx()
                                .getValue() == null
                                || (getPhoneExtPartyIpTx().getValue() != null
                                        && getPhoneExtPartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getFaxPartyIpTx().getValue() != null
                        && !getFaxPartyIpTx().getValue().toString().trim().equals("")
                        && faxRawNumberBusGet.getAttribute("RawNumber") == null)
                        || (faxRawNumberBusGet.getAttribute("RawNumber") != null
                                && (getFaxPartyIpTx().getValue() == null || (getFaxPartyIpTx().getValue() != null
                                        && getFaxPartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getFaxExtPartyIpTx().getValue() != null
                        && !getFaxExtPartyIpTx().getValue().toString().trim().equals("")
                        && faxExtensionBusGet.getAttribute("Extension") == null)
                        || (faxExtensionBusGet.getAttribute("Extension") != null && (getFaxExtPartyIpTx()
                                .getValue() == null
                                || (getFaxExtPartyIpTx().getValue() != null
                                        && getFaxExtPartyIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }
            }
        }
        if (getAddressOptionsRdBtn().getValue().equals("home")
                || getAddressOptionsRdBtn().getValue().equals("businesshome")) {
            if (homeLocationId == null && getAddress1HomeIpTx().getValue() != null
                    && !getAddress1HomeIpTx().getValue().toString().trim().equals("")) {
                return true;
            }
            if (homeLocationId != null) {
                JUCtrlAttrsBinding address1HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address1HomeGet");
                JUCtrlAttrsBinding address2HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address2HomeGet");
                JUCtrlAttrsBinding address3HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address3HomeGet");
                JUCtrlAttrsBinding address4HomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("Address4HomeGet");
                JUCtrlAttrsBinding countryHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CountryHomeGet");
                JUCtrlAttrsBinding stateHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("StateHomeGet");
                JUCtrlAttrsBinding cityHomeGet = (JUCtrlAttrsBinding) bindings.findNamedObject("CityHomeGet");
                JUCtrlAttrsBinding postalCodeHomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PostalCodeHomeGet");
                JUCtrlAttrsBinding phoneRawNumberHomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("PhoneRawNumberHomeGet");
                JUCtrlAttrsBinding faxRawNumberHomeGet = (JUCtrlAttrsBinding) bindings
                        .findNamedObject("FaxRawNumberHomeGet");

                if (getCountryHomeSelOneCho().getValue().equals("US")) {
                    state = (String) getStatesUSHomeSelOneCho().getValue();
                }
                if (getCountryHomeSelOneCho().getValue().equals("AU")) {
                    state = (String) getStatesAUHomeSelOneCho().getValue();
                }
                if (getCountryHomeSelOneCho().getValue().equals("CA")) {
                    state = (String) getStatesCAHomeSelOneCho().getValue();
                }
                if (!getCountryHomeSelOneCho().getValue().equals("US")
                        && !getCountryHomeSelOneCho().getValue().equals("AU")
                        && !getCountryHomeSelOneCho().getValue().equals("CA")) {
                    state = (String) getStatesOtherHomeIpTx().getValue();
                }

                if ((getAddress1HomeIpTx().getValue() != null
                        && !getAddress1HomeIpTx().getValue().toString().trim().equals("")
                        && address1HomeGet.getAttribute("Address1") == null)
                        || (address1HomeGet.getAttribute("Address1") != null && (getAddress1HomeIpTx()
                                .getValue() == null
                                || (getAddress1HomeIpTx().getValue() != null
                                        && getAddress1HomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getAddress2HomeIpTx().getValue() != null
                        && !getAddress2HomeIpTx().getValue().toString().trim().equals("")
                        && address2HomeGet.getAttribute("Address2") == null)
                        || (address2HomeGet.getAttribute("Address2") != null && (getAddress2HomeIpTx()
                                .getValue() == null
                                || (getAddress2HomeIpTx().getValue() != null
                                        && getAddress2HomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getAddress3HomeIpTx().getValue() != null
                        && !getAddress3HomeIpTx().getValue().toString().trim().equals("")
                        && address3HomeGet.getAttribute("Address3") == null)
                        || (address3HomeGet.getAttribute("Address3") != null && (getAddress3HomeIpTx()
                                .getValue() == null
                                || (getAddress3HomeIpTx().getValue() != null
                                        && getAddress3HomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getAddress4HomeIpTx().getValue() != null
                        && !getAddress4HomeIpTx().getValue().toString().trim().equals("")
                        && address4HomeGet.getAttribute("Address4") == null)
                        || (address4HomeGet.getAttribute("Address4") != null && (getAddress4HomeIpTx()
                                .getValue() == null
                                || (getAddress4HomeIpTx().getValue() != null
                                        && getAddress4HomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getCountryHomeSelOneCho().getValue() != null
                        && !getCountryHomeSelOneCho().getValue().equals("")
                        && countryHomeGet.getAttribute("Country") == null)
                        || (countryHomeGet.getAttribute("Country") != null
                                && (getCountryHomeSelOneCho().getValue() == null
                                        || (getCountryHomeSelOneCho().getValue() != null
                                                && getCountryHomeSelOneCho().getValue().equals(""))))) {
                    return true;
                }

                if ((state != null && !state.equals("") && stateHomeGet.getAttribute("State") == null)
                        || (stateHomeGet.getAttribute("State") != null
                                && (state == null || (state != null && state.equals(""))))) {
                    return true;
                }

                if ((getCityHomeIpTx().getValue() != null
                        && !getCityHomeIpTx().getValue().toString().trim().equals("")
                        && cityHomeGet.getAttribute("City") == null)
                        || (cityHomeGet.getAttribute("City") != null
                                && (getCityHomeIpTx().getValue() == null || (getCityHomeIpTx().getValue() != null
                                        && getCityHomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getPostalCodeHomeIpTx().getValue() != null
                        && !getPostalCodeHomeIpTx().getValue().toString().trim().equals("")
                        && postalCodeHomeGet.getAttribute("PostalCode") == null)
                        || (postalCodeHomeGet.getAttribute("PostalCode") != null && (getPostalCodeHomeIpTx()
                                .getValue() == null
                                || (getPostalCodeHomeIpTx().getValue() != null
                                        && getPostalCodeHomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }
                if ((getPhoneHomeIpTx().getValue() != null
                        && !getPhoneHomeIpTx().getValue().toString().trim().equals("")
                        && phoneRawNumberHomeGet.getAttribute("RawNumber") == null)
                        || (phoneRawNumberHomeGet.getAttribute("RawNumber") != null
                                && (getPhoneHomeIpTx().getValue() == null || (getPhoneHomeIpTx().getValue() != null
                                        && getPhoneHomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }

                if ((getFaxHomeIpTx().getValue() != null
                        && !getFaxHomeIpTx().getValue().toString().trim().equals("")
                        && faxRawNumberHomeGet.getAttribute("RawNumber") == null)
                        || (faxRawNumberHomeGet.getAttribute("RawNumber") != null
                                && (getFaxHomeIpTx().getValue() == null || (getFaxHomeIpTx().getValue() != null
                                        && getFaxHomeIpTx().getValue().toString().trim().equals(""))))) {
                    return true;
                }
            }

            JUCtrlAttrsBinding flLicenseGet = (JUCtrlAttrsBinding) bindings.findNamedObject("LicenseNumberGet");
            if ((getLicenseNumberIpTx().getValue() != null
                    && !getLicenseNumberIpTx().getValue().toString().trim().equals("")
                    && flLicenseGet.getAttribute("LicenseNumber") == null)
                    || (flLicenseGet.getAttribute("LicenseNumber") != null
                            && (getLicenseNumberIpTx().getValue() == null
                                    || (getLicenseNumberIpTx().getValue() != null
                                            && getLicenseNumberIpTx().getValue().toString().trim().equals(""))))) {
                return true;
            }
        }
        return false;
    }

    public void cancelChangesActionListener(ActionEvent actionEvent) {

        boolean dataChanged = compareDataChanges();

        if (dataChanged) {
            showPopup(this.getCancelChangesConfirmPopup(), actionEvent.getComponent());
        } else {
            NavigationHandler navigationHandler = FacesContext.getCurrentInstance().getApplication()
                    .getNavigationHandler();
            navigationHandler.handleNavigation(FacesContext.getCurrentInstance(), null, "myAccount");
        }

    }

    public void setCancelChangesConfirmPopup(RichPopup cancelChangesConfirmPopup) {
        this.cancelChangesConfirmPopup = cancelChangesConfirmPopup;
    }

    public RichPopup getCancelChangesConfirmPopup() {
        return cancelChangesConfirmPopup;
    }

    public void cancelChangesConfirmDialogListener(DialogEvent dialogEvent) {
        if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {

            NavigationHandler navigationHandler = FacesContext.getCurrentInstance().getApplication()
                    .getNavigationHandler();
            navigationHandler.handleNavigation(FacesContext.getCurrentInstance(), null, "myAccount");

        }
    }

    public void setUpdateNoteInstPnlFrm(RichPanelFormLayout updateNoteInstPnlFrm) {
        this.updateNoteInstPnlFrm = updateNoteInstPnlFrm;
    }

    public RichPanelFormLayout getUpdateNoteInstPnlFrm() {
        return updateNoteInstPnlFrm;
    }

    public void setDontUpdateNoteInstPnlFrm(RichPanelFormLayout dontUpdateNoteInstPnlFrm) {
        this.dontUpdateNoteInstPnlFrm = dontUpdateNoteInstPnlFrm;
    }

    public RichPanelFormLayout getDontUpdateNoteInstPnlFrm() {
        return dontUpdateNoteInstPnlFrm;
    }

    public void setBusinessAddrOptionRdBtn(RichSelectItem businessAddrOptionRdBtn) {
        this.businessAddrOptionRdBtn = businessAddrOptionRdBtn;
    }

    public RichSelectItem getBusinessAddrOptionRdBtn() {
        return businessAddrOptionRdBtn;
    }

    public void setHomeAddrOptionRdBtn(RichSelectItem homeAddrOptionRdBtn) {
        this.homeAddrOptionRdBtn = homeAddrOptionRdBtn;
    }

    public RichSelectItem getHomeAddrOptionRdBtn() {
        return homeAddrOptionRdBtn;
    }

    public void setBothAddrOptionRdBtn(RichSelectItem bothAddrOptionRdBtn) {
        this.bothAddrOptionRdBtn = bothAddrOptionRdBtn;
    }

    public RichSelectItem getBothAddrOptionRdBtn() {
        return bothAddrOptionRdBtn;
    }

    public PhoneValues phoneDetails(String country, String number) {
        System.out.println("Inside phoneDetails");
        DCBindingContainer bindings = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
        JUCtrlAttrsBinding phoneNumberInPut = (JUCtrlAttrsBinding) bindings.findNamedObject("phoneNumber");
        JUCtrlAttrsBinding countryInPut = (JUCtrlAttrsBinding) bindings.findNamedObject("country");
        JUCtrlAttrsBinding returnValue = (JUCtrlAttrsBinding) bindings.findNamedObject("return");
        phoneNumberInPut.setAttribute("getPhoneDetails_phoneNumber", number);
        countryInPut.setAttribute("getPhoneDetails_country", country);
        OperationBinding opBindingPhoneAPI = bindings.getOperationBinding("getPhoneDetails");
        opBindingPhoneAPI.execute();
        PhoneValues values = new PhoneValues();
        values = (PhoneValues) returnValue.getAttribute("getPhoneDetails_return");
        System.out.println("Inside phoneDetails values " + values);
        if (values != null) {
            System.out.println("areacode is " + values.getPhoneAreaCode());
            System.out.println("number is " + values.getPhoneNumber());
            System.out.println("countryCode is " + values.getPhoneCountryCode());
            System.out.println("formattedNumber is " + values.getFormattedPhoneNumber());
        }
        return values;
    }

    public void setButtonsPnlGrp(RichPanelGroupLayout buttonsPnlGrp) {
        this.buttonsPnlGrp = buttonsPnlGrp;
    }

    public RichPanelGroupLayout getButtonsPnlGrp() {
        return buttonsPnlGrp;
    }

    public void setAddressPreferenceRdBtn(RichSelectOneRadio addressPreferenceRdBtn) {
        this.addressPreferenceRdBtn = addressPreferenceRdBtn;
    }

    public RichSelectOneRadio getAddressPreferenceRdBtn() {
        return addressPreferenceRdBtn;
    }
}