티스토리 뷰

Programming/Nexacro

Nexacro - 로그인 Form 만들기

파란크리스마스 2017. 11. 20. 22:04
728x90

Static 컴포넌트 추가

속성

  • text : 아이디

  • id : lblID

  • background : aqua

  • font : 14 Dotum

Code

this.lblID00_onclick = function(obj:Static,  e:nexacro.ClickEventInfo)
{
	
}

this.Button00_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var objLoginId = this.txt_userId;
    var objLoginPw = this.txt_userPwd;
    
    alert("아이디 / " + objLoginId.value);

    this.trLogin(this,"login",objLoginId.value,objLoginPw.value);
}


/**
* Login service
* @param {string} id
* @param {string} pw
* @return {string] 변형문자열
* @example
* @memberOf Ex.core
*/
this.trLogin = function(obj, sSvcId, id, pw)		
{
	var sSvcID        	= sSvcId;
	var sController   	= "loginCheck.do";
	var sInDatasets   	= "";
	var sOutDatasets  	= "Dataset00=gds_userInfo gds_menu=gds_menu gds_message=gds_message gds_gridInfo=gds_gridInfo gds_config=gds_config gds_task=gds_task";
	var sArgs = "";

	sArgs += this.setParam("V_USER_ID",id);
	sArgs += this.setParam("V_USER_PWD",pw);

	this.tran(obj, sSvcID, sController, sInDatasets, sOutDatasets, sArgs, "received");
}

this.isNull = function(value)
{
	return value === null;
}

this.isUndefined = function(value)
{
	return value === undefined;
}

/**
 * 공백으로치환 
 * @param {string} 체크할  파리미터명
 * @return {string} 공백으로 치환값
 * @example
 *    trace(Eco.isEmpty("")); (output) ""
 * @memberOf Ex.util
 */		
this.isReplaceEmpty = function(strArg)
{
	  if( this.isNull(strArg) || this.isUndefined(strArg)) return "";
	   else
	   return strArg;
},

this.setParam = function (p_name, p_value)
{			
   	return p_name + "="+this.isReplaceEmpty(p_value)+ " ";
}

this.tran = function(obj, svcID, sController, inDatasets, outDatasets, argument, callbackFunc)
{
	// Service ID Merge
	var strSvcID = {id:svcID, callbackFunc:callbackFunc, outDatasets:outDatasets};
	var strURL = "http://localhost/" + sController;
	var strInDatasets = inDatasets;
	var strOutDatasets = outDatasets;
	var strArgument = argument;
	var strCallbackFunc = callbackFunc;
	var m_output = outDatasets;


	this.transaction(strSvcID, strURL, strInDatasets, strOutDatasets, strArgument, strCallbackFunc, true, false);
}

this.received = function(id, code, message)
{
     if (code == 0) {
          this.alert(this.Dataset00.rowcount + " numbers of data have been found.");
          trace(this.Dataset00.rowcount + " numbers of data have been found.");
     } else {
          this.alert("Error["+code+"]:"+message);
          trace("Error["+code+"]:"+message);
     }
}

SERVER - Controller

	@RequestMapping("/loginCheck.do")
    public ModelAndView loginCheck(NexacroMapDTO xpDto, HttpServletRequest request) throws Exception {
		
		Log logger = LogFactory.getLog(this.getClass());	
		ModelAndView mav = new ModelAndView("nexacroMapView");

		try {
			Map <String, Object> inVar 			= xpDto.getInVariableMap();
			Map <String, DataSetMap> outDataset = xpDto.getOutDataSetMap();
			
			String sUserId = (String)inVar.get("V_USER_ID");
			String sPswd = (String)inVar.get("V_USER_PWD");
			
			if(("").equals(sUserId)){
				mav.addObject(NexacroConstant.ERROR_CODE, "-1");
				mav.addObject(NexacroConstant.ERROR_MSG, "ERROR");
				return mav;
			}
			
			if(("").equals(sPswd)){
				mav.addObject(NexacroConstant.ERROR_CODE, "-1");
				mav.addObject(NexacroConstant.ERROR_MSG, "ERROR");
				return mav;
			}
			
			User user = new User();
			user.setUser_id(sUserId);
			user.setPswd(sPswd);
			
			logger.debug("LogInOutController::loginCheck ...." + sUserId + " : " + sPswd);
			
			logInOutService.loginCheck(mav, user, request, outDataset);

			mav.addObject(NexacroConstant.OUT_VARIABLES_ATT_NAME, xpDto.getOutVariableMap());
			mav.addObject(NexacroConstant.OUT_DATASET_ATT_NAME, 	xpDto.getOutDataSetMap());
			
			mav.addObject(NexacroConstant.ERROR_CODE, "0");
			mav.addObject(NexacroConstant.ERROR_MSG, "");
		
		} catch ( Exception e ) {
			e.printStackTrace();
		}
		return mav;		
	}

SERVER - Service

	public void loginCheck(ModelAndView mav, User user, HttpServletRequest request, Map<String, DataSetMap> outDataset) throws NexaServiceException {
		this.user = logInOutDAO.loginCheck(user);
		
		System.out.println("this.user.................................." + this.user);

		if (this.user == null) {
			mav.addObject(NexacroConstant.ERROR_CODE, "-1");
			mav.addObject(NexacroConstant.ERROR_MSG, "User ID is Not Correct.");
			throw new NexaServiceException();
		} else if (this.user != null && !user.getPswd().equals(this.user.getPswd())) {
			mav.addObject(NexacroConstant.ERROR_CODE, "-1");
			mav.addObject(NexacroConstant.ERROR_MSG, "User Password is Not Correct.");
			throw new NexaServiceException();
		} else {
			//Convert Object to List
			List<Map> listUser = ObjectUtil.getObjectToList(this.user, "UPPER_CASE");
			List<Map> listMenu = logInOutDAO.loginMenu(this.user);
			//List<Map> listMessage = logInOutDAO.loginMessage();
			//loadConfig(request.getSession());
			
			request.getSession().setAttribute("User", this.user);
            
			Calendar ca = Calendar.getInstance();
			request.getSession().setAttribute("day", 	ca.get(Calendar.DAY_OF_MONTH));
			request.getSession().setAttribute("month", 	ca.get(Calendar.MONTH));
			request.getSession().setAttribute("year", 	ca.get(Calendar.YEAR));
			
			
			//[DataSet] Login User
			DataSetMap outUserDsMap = new DataSetMap();
			outUserDsMap.setRowMaps(listUser);
			outDataset.put("gds_userInfo", outUserDsMap);
			
			//[DataSet] Login User Menu
			DataSetMap outMenuDsMap = new DataSetMap();
			outMenuDsMap.setRowMaps(listMenu);
			outDataset.put("gds_menu", outMenuDsMap);
		}
	}
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함