jsp中下拉列表框的一种实现思路
2007-04-28 16:41
411 查看
SelBoxManager.java
import java.util.ArrayList;
import java.util.List;
import javax.servlet.jsp.PageContext;
import org.apache.struts.util.LabelValueBean;
public class SelBoxManager {
public static void prepareSelBoxCommon(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBox(page, typeCode, pos);
page.setAttribute(key, mList);
}
public static void prepareSelBoxCommonNoSel(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBox(page, typeCode, pos);
addNoSelection(mList);
page.setAttribute(key, mList);
}
public static void prepareSelBoxCommonWithCode(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBoxWithCode(page, typeCode, pos);
page.setAttribute(key, mList);
}
public static void prepareSelBoxCommonNoSelWithCode(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBoxWithCode(page, typeCode, pos);
addNoSelection(mList);
page.setAttribute(key, mList);
}
private static void addNoSelection(List mList) {
LabelValueBean pData = new LabelValueBean("", "--");
mList.add(0, pData);
}
private static List prepareSelBox(PageContext page, String typeCode, int pos) {
List mList = (List) page.getAttribute(typeCode);
if (mList == null) {
// TODO 未実装
// SELECT .....
page.setAttribute(typeCode, mList);
}
return mList;
}
private static List prepareSelBoxWithCode(PageContext page, String typeCode, int pos) {
List mList = prepareSelBox(page, typeCode, pos);
// 表示内容[区分値 区分]
List newList = new ArrayList();
for (int i = 0; i < mList.size(); i++) {
LabelValueBean pData = (LabelValueBean) mList.get(i);
String label = pData.getLabel();
label = label + " " + pData.getValue();
newList.add(new LabelValueBean(pData.getValue(), label));
}
return newList;
}
}
jsp中通过
<%SelBoxManager.prepareSelBoxCommonNosel(pageContext, "0638", 1, "SAMPLE_LIST"); %>
<logic:notEmpty name="SAMPLE_LIST">
<html:select property="">
<html:options collection="SAMPLE_LIST" property="value" labelValue="label"/>
</html:select>
import java.util.ArrayList;
import java.util.List;
import javax.servlet.jsp.PageContext;
import org.apache.struts.util.LabelValueBean;
public class SelBoxManager {
public static void prepareSelBoxCommon(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBox(page, typeCode, pos);
page.setAttribute(key, mList);
}
public static void prepareSelBoxCommonNoSel(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBox(page, typeCode, pos);
addNoSelection(mList);
page.setAttribute(key, mList);
}
public static void prepareSelBoxCommonWithCode(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBoxWithCode(page, typeCode, pos);
page.setAttribute(key, mList);
}
public static void prepareSelBoxCommonNoSelWithCode(PageContext page, String typeCode, int pos, String key) {
List mList = prepareSelBoxWithCode(page, typeCode, pos);
addNoSelection(mList);
page.setAttribute(key, mList);
}
private static void addNoSelection(List mList) {
LabelValueBean pData = new LabelValueBean("", "--");
mList.add(0, pData);
}
private static List prepareSelBox(PageContext page, String typeCode, int pos) {
List mList = (List) page.getAttribute(typeCode);
if (mList == null) {
// TODO 未実装
// SELECT .....
page.setAttribute(typeCode, mList);
}
return mList;
}
private static List prepareSelBoxWithCode(PageContext page, String typeCode, int pos) {
List mList = prepareSelBox(page, typeCode, pos);
// 表示内容[区分値 区分]
List newList = new ArrayList();
for (int i = 0; i < mList.size(); i++) {
LabelValueBean pData = (LabelValueBean) mList.get(i);
String label = pData.getLabel();
label = label + " " + pData.getValue();
newList.add(new LabelValueBean(pData.getValue(), label));
}
return newList;
}
}
jsp中通过
<%SelBoxManager.prepareSelBoxCommonNosel(pageContext, "0638", 1, "SAMPLE_LIST"); %>
<logic:notEmpty name="SAMPLE_LIST">
<html:select property="">
<html:options collection="SAMPLE_LIST" property="value" labelValue="label"/>
</html:select>
相关文章推荐
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- 换一种思路--使用behavior实现recyclerView的下拉加载更多
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- SpringMVC同时支持多视图(JSP,Velocity,Freemarker等)的一种思路实现
- N级级联下拉列表 的实现思路
- Cocos2d-x 自定义实现下拉列表框(两种实现方法)
- Android: 实现表情输入键盘的另外一种思路
- Android编程实现多列显示的下拉列表框Spinner功能示例
- Promise原理与实现探究的一种思路
- 现在通过json和gson来实现完成一个级联下拉列表框
- 一种精确从文本中提取URL的思路及实现
- Html5添加实现Bootstrap下拉列表框鼠标滑过时打开的插件教程
- 一个用webservice behavior实现的三级联动下拉列表框
- 纯JSP+DWR实现三级联动下拉选择菜单
- 一种新的编程思路(下):附 bbs之register.jsp
- 页面级的业务对象与展现映射封装(一种开发思路与技术实现)
- C# 实现颜色下拉列表框