📄 form.java
字号:
* @param templatecontext
* The templatecontext to set.
*/
public void setTemplatecontext(String template) {
_fields.clear();
_textparts.clear();
_elements.clear();
this.templatecontext = template;
try {
// TemplateProcessVisitor.parseTemplate(this, template);
// TestHelp.doPrintTest(TemplateProcessVisitor.class.getName());
TemplateParser.parseTemplate(this, template);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Form form = new Form();
String temp = "aabbcc";
form.setTemplatecontext(temp);
System.out.println(form);
}
public Object clone() throws CloneNotSupportedException {
// call父类的clone方法
Form result = (Form) super.clone();
// TODO: 定制clone数据
return result;
}
/**
* @hibernate.property column="CHANGED"
*/
public boolean isChanged() {
return changed;
}
public void setChanged(boolean changed) {
this.changed = changed;
}
public boolean isEditmodal() {
return editmodal;
}
public void setEditmodal(boolean editmodal) {
this.editmodal = editmodal;
}
/**
* @hibernate.id column="ID" generator-class="assigned"
*/
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/**
* @return cn.myapps.core.deploy.module.ejb.ModuleVO
* @hibernate.many-to-one class="cn.myapps.core.deploy.module.ejb.ModuleVO"
* column="MODULE"
*/
public ModuleVO getModule() {
return module;
}
public void setModule(ModuleVO module) {
this.module = module;
}
/**
* @hibernate.property column="NAME"
*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* @hibernate.property column="TYPE"
*/
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
/**
* @hibernate.property column="TEMPLATECONTEXT" type="text"
*/
public String getTemplatecontext() {
return templatecontext;
}
/**
* @return cn.myapps.core.deploy.application.ejb.ApplicationVO
* @hibernate.many-to-one class="cn.myapps.core.deploy.application.ejb.ApplicationVO"
* column="APPLICATION"
*/
public ApplicationVO getApplication() {
return application;
}
public void setApplication(ApplicationVO application) {
this.application = application;
}
/**
* @param doc
* @return java.lang.String
* @roseuid 41E7764F00D1
*/
public String toCalctext(Document doc, ParamsTable params, WebUser user,
Collection errors) throws Exception {
JavaScriptRunner runner = JavaScriptRunner.getInstance();
runner.initBSFManager(doc, params, user, errors, user
.getApplicationid());
return toCalctext(doc, params, user, runner, errors);
}
public String toCalctext(Document doc, ParamsTable params, WebUser user,
Collection errors, BillDefiVO flowVO, boolean bRefreshScript)
throws Exception {
JavaScriptRunner runner = JavaScriptRunner.getInstance();
runner.initBSFManager(doc, params, user, errors, user
.getApplicationid());
return toCalctext(doc, params, user, runner, errors, flowVO,
bRefreshScript);
}
public String toHtml(Document doc, ParamsTable params, WebUser user,
Collection errors) throws Exception {
return toHtml(doc, params, user, errors, null, true);
}
public String toHtml(Document doc, ParamsTable params, WebUser user,
Collection errors, boolean bRefreshScript) throws Exception {
return toHtml(doc, params, user, errors, null, bRefreshScript);
}
public String toHtml(Document doc, ParamsTable params, WebUser user,
Collection errors, BillDefiVO flowVO) throws Exception {
return toHtml(doc, params, user, errors, flowVO, true);
}
public String toHtml(Document doc, ParamsTable params, WebUser user,
Collection errors, BillDefiVO flowVO, boolean bRefreshScript)
throws Exception {
StringBuffer buffer = new StringBuffer();
if (flowVO != null) {
setFieldpermlist(doc, flowVO, user);
}
String calctext = toCalctext(doc, params, user, errors, flowVO,
bRefreshScript);
// String js = compileCalctext(calctext);
JavaScriptRunner runner = JavaScriptRunner.getInstance();
runner.initBSFManager(doc, params, user, errors, user
.getApplicationid());
Collection js = compileCalctext(calctext);
for (Iterator iter = js.iterator(); iter.hasNext();) {
Object element = (Object) iter.next();
if (element instanceof String) {
buffer.append(element);
} else {
CalculatePart part = (CalculatePart) element;
Object result = runner.run(part.text);
if (result != null) {
buffer.append(result);
}
}
}
// runner.run(js);
// return runner.getHtmlText();
return buffer.toString();
}
public String toPrintHtmlTxt(Document doc, ParamsTable params,
WebUser user, Collection errors) throws Exception {
StringBuffer template = new StringBuffer();
JavaScriptRunner runner = JavaScriptRunner.getInstance();
// show error info.
if (errors != null && errors.size() > 0) {
template
.append("<table class=dybody width='100%'><tr><td align='right' width='1%' valign='top' nowrap><font color='red'><b>提示信息:</b></font></td><td align='left' width='99%'><font color='red'><b>");
Iterator iter = errors.iterator();
while (iter.hasNext()) {
ValidateMessage error = (ValidateMessage) iter.next();
template.append(error.getErrmessage());
}
template.append("</font><b></td></tr></table>");
}
// show element html tags.
Iterator iter = _elements.iterator();
while (iter.hasNext()) {
FormElement fld = (FormElement) iter.next();
if (fld != null) {
if (fld instanceof FormField) {
FormField ff = (FormField) fld;
if (isEditmodal()) {
ff.setDisplayType(PermissionType.MODIFY);
}
try {
if (!ff.runHiddenScript(runner, doc)) {
template.append("<SPAN id='" + ff.getName()
+ "_divid'>");
String content = "";
if (fld instanceof IncludeField
&& ((IncludeField) fld).isIntegratePage()) {
content = ((IncludeField) fld).toHtmlTxt(
params, user, runner);
} else {
content = fld.toPrintHtml(params, user, runner,
doc);
}
if (content != null && content.trim().length() > 0) {
template.append(content);
}
template.append("</SPAN>");
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
template.append(fld.toPrintHtml(params, user, runner, doc)); // doc为null时是page
}
}
}
return template.toString();
}
public Document recalculateDocument(Document doc, ParamsTable params,
WebUser user) throws Exception {
return recalculateDocument(doc, params, true, user);
}
public Document recalculateDocument(Document doc, ParamsTable params,
boolean calcAll, WebUser user) throws Exception {
JavaScriptRunner runner = JavaScriptRunner.getInstance();
runner.initBSFManager(doc, params, user, null, user.getApplicationid());
Iterator iter = deepSearchFields(getFields()).iterator();
FormField field = null;
try {
while (iter.hasNext()) {
field = (FormField) iter.next();
if (field != null && field.getFieldtype() != null
&& (field.isCalculateOnRefresh() || calcAll)) {
field.recalculate(runner, doc);
}
}
} catch (Exception ex) {
ex.printStackTrace();
throw new Exception("Field:" + field.getName() + "-值脚本出错 <br>"
+ ex.getMessage());
}
return doc;
}
public Collection validate(Document doc, ParamsTable params, WebUser user,
boolean isSubform) throws Exception {
Collection errs = new ArrayList();
JavaScriptRunner runner = JavaScriptRunner.getInstance();
// 测试Field输入合法性
runner.initBSFManager(doc, params, user, errs, user.getApplicationid());
Iterator iter = deepSearchFields(getFields()).iterator();
while (iter.hasNext()) {
FormField field = (FormField) iter.next();
if (field != null && field.getIssubformvalue() == isSubform) {
try {
ValidateMessage msg = field.validate(runner, doc);
if (msg != null) {
errs.add(msg);
}
} catch (Exception ex) {
ex.printStackTrace();
throw new Exception("Field:" + field.getName()
+ "-校验脚本出错! <br>" + ex.getMessage());
}
}
}
return errs;
}
public Collection validate(Document doc, ParamsTable params, WebUser user)
throws Exception {
return validate(doc, params, user, false);
}
public String compile(Document currdoc, ParamsTable params, WebUser user,
String js) {
try {
JavaScriptRunner runner = JavaScriptRunner.getInstance();
runner.initBSFManager(currdoc, params, user, null, user
.getApplicationid());
runner.run(js);
} catch (Exception ex) {
// System.out.println(ex.getMessage());
return ex.getMessage();
}
return "success";
}
/**
* @hibernate.property column="DISCRIPTION"
*/
public String getDiscription() {
return discription;
}
public void setDiscription(String discription) {
this.discription = discription;
}
/**
* @hibernate.many-to-one class="cn.myapps.core.user.ejb.UserVO"
* column="LASTMODIFIER"
*/
public UserVO getLastmodifier() {
return lastmodifier;
}
public void setLastmodifier(UserVO lastmodifier) {
this.lastmodifier = lastmodifier;
}
/**
* @hibernate.property column="LASTMODIFYTIME"
*/
public Date getLastmodifytime() {
return lastmodifytime;
}
public void setLastmodifytime(Date lastmodifytime) {
this.lastmodifytime = lastmodifytime;
}
/**
* @hibernate.property column="TITLESCRIPT"
*/
public String getTitlescript() {
return titlescript;
}
public void setTitlescript(String titlescript) {
this.titlescript = titlescript;
}
/**
* @return cn.myapps.core.style.repository.ejb.StyleRepositoryVO
* @hibernate.many-to-one class="cn.myapps.core.style.repository.ejb.StyleRepositoryVO"
* column="STYLE"
*/
public StyleRepositoryVO getStyle() {
return style;
}
public void setStyle(StyleRepositoryVO style) {
this.style = style;
}
public String getTypeName() {
for (int i = 0; i < formType.length; i++) {
if (this.type == formType[i]) {
return this.formTypeName[i];
}
}
return "";
}
/**
* @hibernate.set name="relatedViews" inverse="true" cascade="delete"
* @hibernate.collection-key column="FORM_ID"
* @hibernate.collection-one-to-many class="cn.myapps.core.dynaform.view.ejb.View"
* @return
*/
public Set getRelatedViews() {
return relatedViews;
}
public void setRelatedViews(Set relatedViews) {
this.relatedViews = relatedViews;
}
/**
* @hibernate.set name="relatedActivitys" inverse="true" cascade="delete"
* @hibernate.collection-key column="ONACTIONFORM_ID"
* @hibernate.collection-one-to-many class="cn.myapps.core.dynaform.activity.ejb.Activity"
* @return
*/
public Set getRelatedActivitys() {
return relatedActivitys;
}
public void setRelatedActivitys(Set relatedActivitys) {
this.relatedActivitys = relatedActivitys;
}
}
class CalculatePart {
String text;
CalculatePart(String t) {
text = t;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -