<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.transformer.layout.LayoutType"%>
<%@ page import="com.eactive.eai.transformer.layout.LayoutTypeManager"%>
<%@ page import="com.eactive.eai.transformer.util.TransformKeys"%>
<%@ page import="java.util.HashMap"%>

<%!
	/**
	* <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;
	} 

%>

<%
    LayoutTypeManager manager = LayoutTypeManager.getInstance();
    String []         alls    = manager.getAllLayoutTypeName();
    String            action  = request.getParameter("actionType");
    
    String selectedKey = request.getParameter("selectedKey");
    if(selectedKey == null && alls.length>=1) {
        selectedKey  = alls[0];
    }
    if ("reload".equals(action)){
    	manager.reload(selectedKey);
    }else if ("reloadAll".equals(action)){
    	manager.reload();
    }else {
    	;
    }
    LayoutType vo = null;
  
    if(selectedKey!=null) {
    	vo = manager.getLayoutType(selectedKey);
    }
    
%>


<html>
    <head>
        <title>
            Transform LayoutType Manager
        </title>
         <script>
        function doAction() {
            document.frm.submit();
        }
        function managerReload(){ 
        	document.frm.actionType.value="reload";
        	document.frm.submit();
        	
        }
        function managerReloadAll(){
        	document.frm.actionType.value="reloadAll";
        	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="">
        
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td rowspan=2 align='right' width='250' bgcolor="#ccccff">레이아웃유형명 :&nbsp;&nbsp;</td>
            <td align='left'>&nbsp;<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 width='50'><input type="button" name="reload" value="reload" onClick="managerReload()" /></td>
            <td width='70'><input type="button" name="reloadAll" value="reloadAll" onClick="managerReloadAll()" /></td>
        </tr>
        <tr bgcolor='white'>
            <td align='left' >&nbsp;<input type="edit" style="width:98%;" name="searchTxt" onkeydown="enterEvent()" value="<%=selectedKey%>" style="width:98%" /></td> 
            <td colspan=2 align="center"><input type="button" name="search" value="search" onClick="doSearch()" /></td>
        </tr>
        </table><br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' colspan='2' width='250' bgcolor="#003366">&nbsp; <font color="yellow"><b>LayoutType정보</b> &nbsp;</font></td>
            
        </tr>

<%
    if(vo != null ){
        
%>

        <tr bgcolor='white'>
            <td align='right' width='250' bgcolor="#ccccff">&nbsp; 레이아웃유형명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=vo.getName()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='250' bgcolor="#ccccff">&nbsp; 레이아웃유형설명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=vo.getDescription()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='250' bgcolor="#ccccff">&nbsp; 메시지레이아웃생성클래스 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=vo.getGenClass()%></td>
        </tr>
        
<%
} else {
%>    
        <tr bgcolor='white'>
            <td align='center' colspan="2" >&nbsp; 요청하신 LayoutType 정보가 없습니다. &nbsp;</td>
        </tr>

<%
}
%>
        </table>
   </form>
    </body>
</html>