📄 componentcheckboxfield.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.CheckboxField;
import cn.myapps.core.dynaform.form.ejb.Option;
import cn.myapps.core.dynaform.form.ejb.Options;
import cn.myapps.core.macro.runner.JavaScriptRunner;
import cn.myapps.util.HtmlEncoder;
import cn.myapps.util.StringList;
import cn.myapps.util.StringUtil;
public class ComponentCheckboxField extends CheckboxField {
/**
*
*/
private static final long serialVersionUID = 3826081467057579521L;
public String runOptionsScript(JavaScriptRunner runner, Document doc,
int displayType) throws Exception {
Object result = null;
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++) {
String[] optstr = strlst[i].split(":");
if (optstr.length >= 2) {
options.add(optstr[0], optstr[1]);
} else {
options.add(strlst[i], strlst[i]);
}
}
} else if (result instanceof Options) {
options = (Options) result;
}
if (options != null) {
Object value = null;
StringList valueList = null;
StringBuffer html = new StringBuffer();
Item item = doc.findItem(this.getName());
if (item != null)
value = item.getValue();
if (value != null)
valueList = new StringList((String) value, ';');
if (doc != null) {
Iterator iter = options.getOptions().iterator();
while (iter.hasNext()) {
Option element = (Option) iter.next();
html.append("<input type='checkbox' value=");
if (isRefreshOnChanged()) {
html.append(" onclick='cp_refresh(this.name)'");
}
html.append("\"");
html.append(HtmlEncoder.encode(element.getValue()));
html.append("\"");
html.append(" name='");
html.append(this.getName());
html.append("'");
if (displayType == PermissionType.READONLY) {
html.append(" disabled ");
}
if (valueList != null && element.getValue() != null) {
if (valueList.indexOf(element.getValue()) >= 0) {
html.append(" checked ");
}
} else {
if (element.isDef()) {
html.append(" checked ");
}
}
html.append(toOtherpropsHtml());
html.append(" class='" + cssClass + "'");
html.append(">");
html.append(element.getOption());
html.append("</input>");
if (this.getLayout() != null
&& this.getLayout().equalsIgnoreCase(
"vertical")) {
html.append("<br>");
}
}
return html.toString();
}
}
}
}
return "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -