From f62c6ed6946b0aa37e059155192a4c8d623f5838 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Wed, 26 Oct 2022 16:17:36 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20custom=20tag=20library=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=20=20=20=20=20=20=20/=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/tag/code/CodeRadioBoxTag.java | 76 +++++++++++ .../support/tag/code/CodeSelectBoxTag.java | 96 +++++++++++++ .../support/util/constants/MessageKey.java | 2 + .../WEB-INF/jsp/fims/biz/ec/ec0100Form.jsp | 6 +- .../WEB-INF/jsp/fims/biz/ec/ec0100Popup.jsp | 9 +- .../WEB-INF/jsp/fims/biz/rt/Rt0200_detail.jsp | 6 +- .../WEB-INF/jsp/fims/biz/rt/Rt0200_main.jsp | 6 +- .../WEB-INF/jsp/fims/biz/rt/Rt0200_main2.jsp | 6 +- .../WEB-INF/jsp/fims/biz/rt/Rt0200_main3.jsp | 6 +- .../WEB-INF/jsp/fims/biz/rt/rt0200Sel.jsp | 12 +- .../biz/mng/menu/mngMenuCreateMgtForm.jsp | 6 +- .../framework/biz/mng/menu/mngMenuMgtForm.jsp | 6 +- .../biz/mng/menu/mngProgramMgtForm.jsp | 6 +- .../biz/mng/menu/mngProgramMgtPopup.jsp | 9 +- .../webapp/WEB-INF/jsp/framework/taglibs.jsp | 13 ++ src/main/webapp/WEB-INF/tlds/code.tld | 127 ++++++++++++++++++ 16 files changed, 331 insertions(+), 61 deletions(-) create mode 100644 src/main/java/kr/xit/framework/support/tag/code/CodeRadioBoxTag.java create mode 100644 src/main/java/kr/xit/framework/support/tag/code/CodeSelectBoxTag.java create mode 100644 src/main/webapp/WEB-INF/jsp/framework/taglibs.jsp create mode 100644 src/main/webapp/WEB-INF/tlds/code.tld diff --git a/src/main/java/kr/xit/framework/support/tag/code/CodeRadioBoxTag.java b/src/main/java/kr/xit/framework/support/tag/code/CodeRadioBoxTag.java new file mode 100644 index 00000000..91b11c53 --- /dev/null +++ b/src/main/java/kr/xit/framework/support/tag/code/CodeRadioBoxTag.java @@ -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 paramMap = new HashMap(); + // 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> list = CacheCodeUtils.getComboCodes(codeId); + + int index = 0; + for (Map map : list) { + + sb.append("").append("\n"); + + sb.append("").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 ""; + } + +} diff --git a/src/main/java/kr/xit/framework/support/tag/code/CodeSelectBoxTag.java b/src/main/java/kr/xit/framework/support/tag/code/CodeSelectBoxTag.java new file mode 100644 index 00000000..d84b7456 --- /dev/null +++ b/src/main/java/kr/xit/framework/support/tag/code/CodeSelectBoxTag.java @@ -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(""); + + if(this.isEmptySelect){ + //out.print(""); + sb.append("").append("\n"); + } + + // Map paramMap = new HashMap(); + // 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> list = CacheCodeUtils.getComboCodes(codeId); + + for (Map map : list) { + //out.print(""); + sb.append("").append("\n"); + } + //out.print(""); + sb.append(""); + 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 ""; + } +} diff --git a/src/main/java/kr/xit/framework/support/util/constants/MessageKey.java b/src/main/java/kr/xit/framework/support/util/constants/MessageKey.java index 0c3eade9..a86cb90c 100644 --- a/src/main/java/kr/xit/framework/support/util/constants/MessageKey.java +++ b/src/main/java/kr/xit/framework/support/util/constants/MessageKey.java @@ -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"; } diff --git a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ec0100Form.jsp b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ec0100Form.jsp index 0ea8c19e..92170958 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ec0100Form.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ec0100Form.jsp @@ -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" %>