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 "";
|
||||
}
|
||||
}
|
@ -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…
Reference in New Issue