⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 componentradiofield.java

📁 OBPM是一个开源
💻 JAVA
字号:
//Source file:
//C:\\Java\\workspace\\SmartWeb3\\src\\com\\cyberway\\dynaform\\form\\ejb\\SelectField.java

package cn.myapps.core.dynaform.component.ejb;

import java.util.Iterator;

import cn.myapps.core.dynaform.PermissionType;
import cn.myapps.core.dynaform.document.ejb.Document;
import cn.myapps.core.dynaform.document.ejb.Item;
import cn.myapps.core.dynaform.form.ejb.Option;
import cn.myapps.core.dynaform.form.ejb.Options;
import cn.myapps.core.dynaform.form.ejb.RadioField;
import cn.myapps.core.macro.runner.JavaScriptRunner;
import cn.myapps.util.HtmlEncoder;
import cn.myapps.util.StringList;
import cn.myapps.util.StringUtil;

public class ComponentRadioField extends RadioField {

	/**
	 * 
	 */
	private static final long serialVersionUID = 148660715924009621L;

	public String runOptionsScript(JavaScriptRunner runner, Document doc,
			int displayType) throws Exception {
		Object result = null;
		StringBuffer html = new StringBuffer();
		if (displayType == PermissionType.HIDDEN) {
			return "(hidden)";
		} else {
			if (getOptionsScript() != null
					&& getOptionsScript().trim().length() > 0) {
				result = runner.run(StringUtil.dencodeHTML(getOptionsScript()));

				Options options = null;
				if (result != null && result instanceof String) {

					String[] strlst = ((String) result).split(";");
					;
					options = new Options();
					for (int i = 0; i < strlst.length; i++) {
						options.add(strlst[i], strlst[i]);
					}
				} else if (result instanceof Options) {
					options = (Options) result;
				}
				if (options != null) {
					Object value = null;
					StringList valueList = null;
					Item item = doc.findItem(this.getName());

					if (item != null)
						value = item.getValue();
					if (value != null)
						valueList = new StringList((String) value, ';');

					if (doc != null) {
						Object defvalue = "";
						boolean isreadonly = false;

						Iterator iter = options.getOptions().iterator();
						while (iter.hasNext()) {
							Option element = (Option) iter.next();

							if ((this.getTextType() != null && this
									.getTextType().equalsIgnoreCase("READONLY"))
									|| (displayType == PermissionType.DISABLED)) {
								isreadonly = true;
							}

							html.append("<input type='radio' value=");
							html.append("\"");
							html.append(HtmlEncoder.encode(element.getValue()));
							html.append("\"");
							html.append(" name='");
							if (isreadonly) {
								html.append(this.getName() + "$forshow");
							} else {
								html.append(this.getName());
							}

							html.append("'");

							if (isRefreshOnChanged()) {
								html.append(" onclick='cp_refresh(this.name)'");
							}

							if (isreadonly) {
								html.append(" disabled ");
							}

							if (valueList != null && element.getValue() != null) {
								if (valueList.indexOf(element.getValue()) >= 0) {
									defvalue = element.getValue();
									html.append(" checked ");
								}
							} else {
								if (element.isDef()) {
									defvalue = element.getValue();
									html.append(" checked ");
								}
							}
							html.append(toOtherpropsHtml());
							html.append(" class='" + cssClass + "'");
							html.append("><font size=2>");
							html.append(element.getOption());
							html.append("</font></input>");

							if (this.getLayout() != null
									&& this.getLayout().equalsIgnoreCase(
											"vertical")) {
								html.append("<br>");
							}
						}
						if (isreadonly) {
							html
									.append("<input type='hidden' name='"
											+ getName() + "' value='"
											+ defvalue + "'>");
						}
					}
				}
			}
		}
		return html.toString();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -