<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.common.EAITable"%>
<%@ page import="com.eactive.eai.common.lifecycle.Lifecycle"%>
<%@ page import="com.eactive.eai.common.lifecycle.LifecycleManager"%>
<%@ page import="com.eactive.eai.common.lifecycle.LifecycleVO"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="com.eactive.eai.common.util.* "%>
<%!
	/**
	* <pre>
	* 문자열을 받아서 널이면 제로스트링을, 아니면 트림된 문자열을 리턴.
	* </pre>
	* @param	String		변환 대상
	* @return	'String'
	*/
	public static String checkNull( String str ) {

		String sResult = new String();
		if ( str == null ) {
			sResult = "";
		}
		else {
			sResult = str.trim();
		}
		return sResult;
	}
%>
<%
    
    LifecycleManager manager = ApplicationContextProvider.getContext().getBean(LifecycleManager.class);
    String           action  = request.getParameter("actionType");
 
    List             lists   = manager.getLifecycleVOList();  
    
    String[]         alls    = new String[lists.size()];
    
    for(int i=0; i< alls.length; i++){
    	alls[i] = ((LifecycleVO)lists.get(i)).getLifecycleClass();  
    }
    
    String selectedKey = request.getParameter("selectedKey");
    
    if(selectedKey == null && alls.length>=1) {
        selectedKey  = alls[0];
    }
   
    LifecycleVO vo   = null;
  
    if(selectedKey!=null) {
       for(int i=0; i < alls.length; i++){
            String lifeC = ((LifecycleVO)lists.get(i)).getLifecycleClass();
            if(selectedKey.equals(lifeC)){
                vo =   (LifecycleVO)lists.get(i);
            }
       }
    }
    
%>


<html>
    <head>
        <title>
            LifeCycle Manager
        </title>
         <script>
        function doAction() {
            document.frm.submit();
        }
        function doSearch(){
        	var searchValue = document.frm.searchTxt.value;
        	document.frm.selectedKey.value = searchValue;
        	document.frm.submit();
        }
        function enterEvent(){
        	if(window.event.keyCode==13){
        		doSearch();
        	}
        }
        </script>
    </head>
    <body>
        <p style="font-size:12pt;">
        <b>라이프사이클 관리</b> <br><br>
        </p>
        <form name="frm" action="">
        <input type="hidden" name="actionType" value="">
        <input type="hidden" name="actionSeq" value="">
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td rowspan=2 align='right' width='350' bgcolor="#ccccff">라이프사이클 클래스명 :&nbsp;&nbsp;</td>
            <td align='left'><select name="selectedKey" onchange="doAction();"style="width:98%">
            <%
                for(int i=0;i<alls.length;i++) {
            %>
                <option value="<%=alls[i]%>" <%= (alls[i].equals(selectedKey)) ? "selected" : "" %>><%=alls[i]%>
            <%           
                }
            %></select>
            </td>
            <td rowspan="2" align="center" ><input type="button" name="search" value="search" onClick="doSearch()" /></td>
        </tr>
         <tr bgcolor='white'>
            <td align='left' ><input type="edit" style="width:100%"  name="searchTxt" onkeydown="enterEvent()" value="<%=selectedKey%>" style="width:98%" /></td> 
        </tr>
        </table><br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' colspan='2' width='350' bgcolor="#003366">&nbsp; <font color="yellow"><b>내용</b> &nbsp;</font></td>
            
        </tr>


<%
    if(vo != null ){
        
%>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 라이프사이클 클래스명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="LifecycleClass" style="width:98%" value="<%=vo.getLifecycleClass()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 로딩순서 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="LOADSEQUENCE" style="width:98%" value="<%=vo.getLoadSequence()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 라이프사이클 구분코드 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%" value="<%=vo.getLifeCyclUseDstcd()%>"></td>
        </tr>
       
<%
}
%>    
        </table>
        </form>
    </body>
</html>