/* * Set the state */ function loadLocation(continent) { document.getElementById("continentId").value = continent; getCountry(continent); } String.prototype.trim = function() { return this.replace(/^\s*/, "").replace(/\s*$/, ""); } /* * Set the state */ function loadCountry(country) { var country_id = country.split('%')[0]; var country_name = country.split('%')[1]; document.getElementById("countryId").value = country_id.trim(); } function doInsert() { var countryId = document.getElementById('countryId').value; document.getElementById('countryIdRecovered').value = countryId; var deviceId = document.getElementById('deviceId').value; document.getElementById('deviceIdRecovered').value = deviceId; var fieldsNames = new Array(1); var fieldsContents = new Array(1); var blank = " "; document.forms[0].action='homeInternationalRoaming_insert.do'; fieldsNames[0] = "countryId"; if ( !verifyNullAndEmptyString( document.getElementById("countryId").value )) { fieldsContents[0] = document.getElementById("countryId").value; } else { fieldsContents[0] = blank; } HomeInternationalRoamingValidatorDWR.validSave(fieldsNames, fieldsContents, evaluateResult); } /* * Method to evaluate result */ function evaluateResult(msg) { if (msg != null) { // parameters: message code and message for jsp field id, null if not require parameters // setErrorMessageDWR(msg); null; } else { // set the text document.forms[0].submit(); } } function verifyReload(id){ if(id == "-1"){ document.getElementById("continentId").value=""; HomeInternationalRoamingDWR.reloadCountries(createListCountry); } } function getCountry(name){ var countryIdRecovered = document.getElementById('countryIdRecovered').value; var continent = document.getElementById("continentId").value; if(countryIdRecovered == '' ){ DWREngine.setAsync(false); HomeInternationalRoamingDWR.getCountryByContinentByName(name,createListCountry); DWREngine.setAsync(true); } else { if ( continent != null && continent != '' ) { DWREngine.setAsync(false); HomeInternationalRoamingDWR.getCountryByContinentByName(name,createListCountryRecovered); DWREngine.setAsync(true); } document.getElementById('countryIdRecovered').value = ''; } } function createListCountryRecovered(data){ DWRUtil.removeAllOptions('countryId'); DWRUtil.addOptions('countryId', data); document.getElementById('countryId').value = document.getElementById('countryIdRecovered').value; } function createListCountry(data){ DWRUtil.removeAllOptions('countryId'); DWRUtil.addOptions('countryId', data); loadContryData(); } function getDevice(vendorId){ // var deviceId = document.getElementById('deviceId').value; if(vendorId!=''){ DWREngine.setAsync(false); // HomeInternationalRoamingDWR.getDeviceByVendorTechnology(id,technologyId,createListDevice); HomeInternationalRoamingDWR.getDeviceByVendor(vendorId, createListDevice); DWREngine.setAsync(true); // document.getElementById('deviceId').value = deviceId; } } function createListDevice(data){ DWRUtil.removeAllOptions('deviceId'); DWRUtil.addOptions('deviceId', data); } /* * This function verify if a string fieldValue is null or is empty. * * @author diego.martins */ function verifyNullAndEmptyString( fieldValue ) { if ( fieldValue == null ) { return true; } if ( fieldValue == "" ) { return true; } return false; } function autoSelectContinent(){ var countryId = document.getElementById("countryId").value; var continentId = document.getElementById("continentId").value; if(countryId!= '' && countryId!= '0' && countryId!= '-1'){ HomeInternationalRoamingDWR.getContinentByCountryId(countryId,selectContinent); } } function selectContinent(data){ document.getElementById('continentId').value = data; } function loadContryData() { var continent = document.getElementById("continentId").value; var vendor = document.getElementById("vendorId").value; // var technology = document.getElementById("technologyId").value; var countryIdRecovered = document.getElementById('countryIdRecovered').value; if(countryIdRecovered != ''){ getCountry(continent); document.getElementById('countryId').value = countryIdRecovered; } if(vendor!=''){ var deviceIdRecovered = document.getElementById('deviceIdRecovered').value; getDevice(vendor); if(deviceIdRecovered != ''){ document.getElementById('deviceId').value = deviceIdRecovered; } } }