feat: custom tag library 추가

<code:select /> / <code:radio />
main
minuk926 2 years ago
parent a6ec32d942
commit f62c6ed694

@ -0,0 +1,76 @@
package kr.xit.framework.support.tag.code;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import org.springframework.util.StringUtils;
import kr.xit.framework.biz.cmm.CacheCodeUtils;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CodeRadioBoxTag extends TagSupport {
private static final long serialVersionUID = 519803737380451566L;
private String id = "";
private String name = "";
private String codeId = "";
private String defaultSelect = "";
private String cls = "";
private String alt = "";
private String onclick = "";
public int doStartTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
StringBuilder sb = new StringBuilder();
// Map<String, Object> paramMap = new HashMap<String, Object>();
// paramMap.put("codeId", this.codeId);
// paramMap.put("code", this.code);
// paramMap.put("etc_1", this.etc_1);
// paramMap.put("etc_2", this.etc_2);
// paramMap.put("etc_3", this.etc_3);
List<Map<String, Object>> list = CacheCodeUtils.getComboCodes(codeId);
int index = 0;
for (Map<String, Object> map : list) {
sb.append("<input id='").append(this.id+"_"+index).append("'");
sb.append(" type='radio'");
sb.append(" name='").append(this.name).append("'");
sb.append(" class='").append(this.cls).append("'");
sb.append(" onclick='").append(this.onclick).append("'");
sb.append(" value='").append(map.get("code")).append("'");
sb.append( isDefaultSelect((String) map.get("code")));
sb.append(" alt='").append(this.alt).append("'/>").append("\n");
sb.append("<label for='").append(this.id+"_"+index).append("'>");
sb.append(map.get("code_nm"));
sb.append("</label>").append("\n");
index++;
}
out.print(sb.toString());
} catch (IOException ie) {
throw new JspException(ie.toString());
}
return SKIP_BODY;
}
private String isDefaultSelect(String defaultSelectValue) {
if(StringUtils.hasText(this.defaultSelect) && this.defaultSelect.equals(defaultSelectValue))
return " checked='checked'";
return "";
}
}

@ -0,0 +1,96 @@
package kr.xit.framework.support.tag.code;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.util.StringUtils;
import kr.xit.framework.biz.cmm.CacheCodeUtils;
import kr.xit.framework.support.util.JBeanRegistry;
import kr.xit.framework.support.util.constants.MessageKey;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CodeSelectBoxTag extends TagSupport {
private static final long serialVersionUID = 519803737380451566L;
private String id = "";
private String name = "";
private String codeId = "";
private String etc_1 = "";
private String etc_2 = "";
private String etc_3 = "";
private String defaultSelect = "";
private boolean isEmptySelect = true;
private String emptyMessageKey = MessageKey.EMPTY_MSG_COMBO;
private String sortField = "";
private String cls = "";
private String alt = "";
private String onchange = "";
private boolean disabled = false;
public int doStartTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
StringBuilder sb = new StringBuilder();
sb.append("<select id='").append(this.id).append("'");
sb.append(" name='").append((this.name == null ? this.id : this.name)).append("'");
sb.append(" class='").append(this.cls).append("'");
sb.append(" onchange='").append(this.onchange).append("'");
if(this.disabled){
sb.append(" disabled ");
}
sb.append(" alt='").append(this.alt).append("'>").append("\n");
//out.print("<select id='"+this.id+"' name='"+(this.name == null ? this.id : this.name)+"' class='"+this.cls+"' onchange='"+this.onchange+"' alt='"+this.alt+"'>");
if(this.isEmptySelect){
//out.print("<option value=''>"+((MessageSourceAccessor)JBeanRegistry.getMessageSourceAccessor()).getMessage(this.emptyMessageKey, LocaleContextHolder.getLocale())+"</option>");
sb.append("<option value=''>")
.append( ((MessageSourceAccessor)JBeanRegistry.getMessageSourceAccessor()).getMessage(this.emptyMessageKey, LocaleContextHolder.getLocale()) )
.append("</option>").append("\n");
}
// Map<String, Object> paramMap = new HashMap<String, Object>();
// paramMap.put("codeId", this.codeId);
// paramMap.put("code", this.code);
// paramMap.put("etc_1", this.etc_1);
// paramMap.put("etc_2", this.etc_2);
// paramMap.put("etc_3", this.etc_3);
List<Map<String, Object>> list = CacheCodeUtils.getComboCodes(codeId);
for (Map<String, Object> map : list) {
//out.print("<option value='"+map.get("CODE")+"' "+isDefaultSelect((String) map.get("CODE"))+">"+map.get("CODE_NM")+"</option>");
sb.append("<option value='").append(map.get("code")).append("'")
.append( isDefaultSelect((String) map.get("code"))).append(">")
.append( map.get("code_nm") )
.append("</option>").append("\n");
}
//out.print("</select>");
sb.append("</select>");
out.print(sb.toString());
} catch (IOException ie) {
throw new JspException(ie.toString());
}
return SKIP_BODY;
}
private String isDefaultSelect(String defaultSelectValue) {
if(StringUtils.hasText(this.defaultSelect) && this.defaultSelect.equals(defaultSelectValue))
return " selected='selected'";
return "";
}
}

@ -17,4 +17,6 @@ public abstract class MessageKey {
public static final String CMM_DELETE_FAIL = "fail.common.delete";
public static final String WARN_SESSION_END = "warn.session.end";//세션이 종료 되었습니다..
public static final String EMPTY_MSG_COMBO = "button.select";
}

@ -1,10 +1,6 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<style type="text/css">
h1 {font-size:12px;}
caption {visibility:hidden; font-size:0; height:0; margin:0; padding:0; line-height:0;}

@ -1,12 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<form id="frmEc0100">

@ -1,9 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<form id="frmSearch" name="frmSearch" method="get">

@ -1,9 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<form id="frmSearch" name="frmSearch" method="get">

@ -1,9 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<form id="frmSearch" name="frmSearch" method="get">

@ -1,9 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<form id="frmSearch" name="frmSearch" method="get">

@ -1,10 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<form id="frmSearch" name="frmSearch" method="get">
<input type="hidden" id="searchGubun" name="searchGubun" value="excel">
@ -22,6 +17,10 @@
<option value="1">위반일자</option>
<option value="2">등록일자</option>
</select>
<!-- tag lib sample -->
<code:select id="sch_date_opt1" name="sch_date_opt1" codeId="ENS003" defaultSelect="99" cls="selectBox" alt="selectBox tag"/>
<code:radio id="sch_date_opt2" name="sch_date_opt2" codeId="ENS003" defaultSelect="02" cls="radioBox" alt="radio tag"/>
</li>
<li>
<span class="cal-box">
@ -48,7 +47,6 @@
</li>
<input type="text" id="sch_word" name="sch_word" value="">
<button type="button" class="btnSearch" id="btnSearch" name="btnSearch">검색</button>
</ul>
</fieldset>
</div>

@ -1,8 +1,6 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<%
/* Image Path 설정 */
String imagePath_icon = "/images/egovframework/sym/mpm/icon/";

@ -1,8 +1,6 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<%
/* Image Path 설정 */
String imagePath_icon = "/images/egovframework/sym/mpm/icon";

@ -1,10 +1,6 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<style type="text/css">
h1 {font-size:12px;}
caption {visibility:hidden; font-size:0; height:0; margin:0; padding:0; line-height:0;}

@ -1,12 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp"%>
<script type="text/javascript" src="<c:url value="/framework/util/validator.do"/>"></script>
<validator:javascript formName="progrmMngVO" staticJavascript="true" xhtml="true" cdata="false"/>

@ -0,0 +1,13 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<%@ taglib prefix="code" uri="/WEB-INF/tlds/code.tld"%>

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>Common Code tag library</description>
<display-name>Common Code tag library</display-name>
<tlib-version>1.0</tlib-version>
<short-name>code</short-name>
<tag>
<description>select box JSTL</description>
<name>select</name>
<tag-class>kr.xit.framework.support.tag.code.CodeSelectBoxTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>codeId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>etc_1</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>etc_2</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>etc_3</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>defaultSelect</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>isEmptySelect</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>emptyMessageKey</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>cls</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>alt</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>onchange</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>radio</name>
<tag-class>kr.xit.framework.support.tag.code.CodeRadioBoxTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>codeId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>etc_1</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>etc_2</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>etc_3</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>defaultSelect</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>cls</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>alt</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>onclick</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
Loading…
Cancel
Save