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

📄 componentinputfield.java

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

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

import java.text.SimpleDateFormat;
import java.util.Date;

import cn.myapps.base.action.ParamsTable;
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.InputField;
import cn.myapps.core.macro.runner.JavaScriptRunner;
import cn.myapps.core.user.action.WebUser;
import cn.myapps.util.HtmlEncoder;

public class ComponentInputField extends InputField {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5749426513470185934L;

	public String toHtmlTxt(ParamsTable params, WebUser user,
			JavaScriptRunner runner, Document doc, int displayType) {
		StringBuffer html = new StringBuffer();
		// 添加Field
		if (displayType == PermissionType.HIDDEN) {// 节点设置对应field隐藏
			return "******";
		} else {
			if (getTextType() != null) {
				if (getTextType().equalsIgnoreCase("text")) {
					html.append("<input type='text'");
				} else if (getTextType().equalsIgnoreCase("readonly")) {
					html.append("<input type='text' readonly");
				} else if (getTextType().equalsIgnoreCase("hidden")) {
					html.append("<input type='hidden'");
				} else if (getTextType().equalsIgnoreCase("password")) {
					html.append("<input type='password'");
				} else {
					html.append("<input type='text'");
				}

				html.append(" id='" + getId() + "'");
				html.append(" name='" + getName() + "'");
				if (isRefreshOnChanged()) {
					html.append(" onchange='cp_refresh(this.name)'");
				}
				html.append(" class='" + cssClass + "'");

				if (doc != null) {
					Item item = doc.findItem(this.getName());
					if (item != null && item.getValue() != null) {
						Object value = item.getValue();
						if (value instanceof Double) {
							html.append(" value=\"" + item.getValue() + "\"");
						} else if (value instanceof Date) {
							Date d = (Date) value;
							SimpleDateFormat format = new SimpleDateFormat(
									"yyyy-MM-dd");
							html.append(" value=\"" + format.format(d) + "\"");
						} else {
							html.append(" value=\""
									+ HtmlEncoder.encode(item.getValue() + "")
									+ "\"");
						}
					}
				}
				if (displayType == PermissionType.READONLY) {// 节点设置对应field只读或关闭
					html.append(" readonly ");
				} else if (displayType == PermissionType.DISABLED) {
					html.append(" disabled ");
				}

				html.append(toOtherpropsHtml());
				html.append(">");
				if (getDialogView() != null
						&& getDialogView().trim().length() > 0) {
					if (displayType != PermissionType.DISABLED
							&& displayType != PermissionType.READONLY) {// 设置对话框按钮field关闭
						if (isPopToChoice()) {
							html
									.append("<input type='button' onclick='ViewHelper.convertValuesMapToPage("
											+ "cp_getFormid(),\""
											+ getDialogView()
											+ "\",\""
											+ getName()
											+ "\",\""
											+ user.getId()
											+ "\",cp_getValuesMap(),function(text){showViewDialog(text,\""
											+ getDialogView()
											+ "\",\""
											+ this.getName()
											+ "\")})' value='{*[...]*}' ");
						} else {
							html
									.append("<input type='button' onclick='ViewHelper.displayViewHtml("
											+ "cp_getFormid(),\""
											+ getDialogView()
											+ "\",\""
											+ getName()
											+ "\",\""
											+ user.getId()
											+ "\",cp_getValuesMap(),function(text){src2(text,\"Choice\")})' value='{*[...]*}' ");
						}
						html.append("/>");
					}
				}
				if (getFieldtype() != null) {
					if (getFieldtype().equals(Item.VALUE_TYPE_DATE)
							&& isSelectDate()
							&& displayType != PermissionType.READONLY) { // 只读或不可选择日期时不生成
						html
								.append("<input type='button' value='...' onclick='"
										+ getName()
										+ ".value=selectDate("
										+ getName() + ".value)' ");
						if (displayType == PermissionType.DISABLED) {// 设置日期field关闭
							html.append(" disabled ");
						}

						html.append("/>");
					}
				}

			}
		}
		return html.toString();
	}
}

⌨️ 快捷键说明

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