📄 viewdialogfield.java
字号:
package cn.myapps.core.dynaform.form.ejb;
import cn.myapps.base.action.ParamsTable;
import cn.myapps.core.dynaform.PermissionType;
import cn.myapps.core.dynaform.document.ejb.Document;
import cn.myapps.core.macro.runner.JavaScriptRunner;
import cn.myapps.core.user.action.WebUser;
import cn.myapps.core.validate.repository.ejb.ValidateRepositoryProcess;
import cn.myapps.core.validate.repository.ejb.ValidateRepositoryVO;
import cn.myapps.util.ProcessFactory;
import cn.myapps.util.StringUtil;
public class ViewDialogField extends FormField {
protected String dialogView = "";
protected String validateLibs = "";
protected String mapping = "";
protected boolean mutilSelect;
protected boolean allowViewDoc;
protected String caption = "";
public boolean isAllowViewDoc() {
return allowViewDoc;
}
public void setAllowViewDoc(boolean allowViewDoc) {
this.allowViewDoc = allowViewDoc;
}
public String getMapping() {
return mapping;
}
public void setMapping(String mapping) {
this.mapping = mapping;
}
public String getDialogView() {
return dialogView;
}
public void setDialogView(String dialogView) {
this.dialogView = dialogView;
}
public String getValidateLibs() {
return validateLibs;
}
public void setValidateLibs(String validateLibs) {
this.validateLibs = validateLibs;
}
public ValidateMessage validate(JavaScriptRunner runner, Document doc)
throws Exception {
Object result = null;
String rtn = "";
ValidateMessage msg = new ValidateMessage();
if (getValidateLibs() != null && getValidateLibs().trim().length() > 0) {
String libs[] = getValidateLibs().split(";");
ValidateRepositoryProcess vp = (ValidateRepositoryProcess) ProcessFactory
.createProcess(ValidateRepositoryProcess.class);
for (int i = 0; i < libs.length; i++) {
ValidateRepositoryVO vo = (ValidateRepositoryVO) vp
.doView(libs[i]);
String cotent = "";
String functionName = getFunctionNames(vo.getContent());
if (functionName != null) {
cotent += functionName + "('" + getName() + "');";
cotent += vo.getContent();
Object obj = runner.run(cotent);
if (obj instanceof String) {
rtn += (String) obj;
}
}
}
}
if (getValidateRule() != null && getValidateRule().trim().length() > 0) {
result = runner.run(StringUtil.dencodeHTML(getValidateRule()));
System.out.print(getValidateLibs());
// Item item = doc.findItem(this.getName());
if (result instanceof String) {
String rs = (String) result;
if (rs != null && rs.trim().length() > 0) {
rtn += rs;
}
}
}
if (rtn != null && rtn.trim().length() > 0) {
msg.setFieldname(this.getName());
msg.setErrmessage(rtn);
return msg;
} else
return null;
}
public String toTemplate() {
StringBuffer template = new StringBuffer();
template.append("<span");
template.append(" className='" + this.getClass().getName() + "'");
template.append(" id='" + getId() + "'");
template.append(" name='" + getName() + "'");
template.append(" formid='" + getFormid() + "'");
template.append(" hiddenScript='" + getHiddenScript() + "'");
template.append(" hiddenPrintScript='" + getHiddenPrintScript() + "'");
template.append(" refreshOnChanged='" + isRefreshOnChanged() + "'");
template.append(" validateRule='" + getValidateRule() + "'");
template.append(" valueScript='" + getValueScript() + "'");
template.append("/>");
return template.toString();
}
public String toHtmlTxt(ParamsTable params, WebUser user,
JavaScriptRunner runner, Document doc) throws Exception {
StringBuffer html = new StringBuffer();
int displayType = getDisplayType(runner, doc);
if (getDialogView() != null && getDialogView().trim().length() > 0) {
String parameters = "param" + getName();
html.append("<script>");
html.append("var " + parameters + "= {");
html.append("allow:" + isAllowViewDoc() + ",");
html.append("mutil:" + isMutilSelect() + ",");
html.append("className:'" + this.getClass().getName() + "'");
if (displayType == PermissionType.MODIFY) {
html.append(",isEdit:" + true);
} else {
html.append(",isEdit:" + false);
}
html.append("}");
html.append("</script>");
html
.append("<input type='button' onclick='ViewHelper.convertValuesMapToPage("
+ "dy_getFormid(),\""
+ getDialogView()
+ "\",\""
+ getName()
+ "\",\""
+ user.getId()
+ "\",dy_getValuesMap(),function(text){if(showViewDialog2(text,\""
+ getDialogView()
+ "\",\""
+ getMapping()
+ "\","
+ parameters
+ ")){"
+ (isRefreshOnChanged() ? "dy_refresh(\""
+ getName() + "\")" : "") + "}");
html.append("})'");
if (getCaption() == null || getCaption().trim().length() <= 0) {
html.append("value='{*[...]*}'");
} else {
html.append("value='" + getCaption() + "'");
}
}
return html.toString();
}
public String getFunctionNames(String content) {
if (content == null || content.trim().length() == 0)
return null;
int i = content.indexOf("function");
int j = content.substring(i + 8, content.length()).indexOf("(");
String functionname = content.substring(i + 8, i + 8 + j);
if (functionname != null && functionname.trim().length() > 0)
return functionname;
else
return null;
}
public boolean isMutilSelect() {
return mutilSelect;
}
public void setMutilSelect(boolean mutilSelect) {
this.mutilSelect = mutilSelect;
}
public String toPrintHtmlTxt(ParamsTable params, WebUser user,
JavaScriptRunner runner, Document doc) throws Exception {
return "";
}
/**
* @hibernate.property
* column="caption"
*/
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -