generatestrutsform.java
来自「Java Pattern Oriented Framework (Jt) 是为了」· Java 代码 · 共 129 行
JAVA
129 行
package Jt.wizard.struts;
import java.util.Collection;
import java.util.LinkedList;
import Jt.JtContext;
import Jt.JtMessage;
import Jt.JtObject;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;
/**
* Creates a form for the Struts framework.
*/
public class GenerateStrutsForm extends JtObject {
private static final long serialVersionUID = 1L;
/*
* Update the list of errors (objErrors) that
* should be displayed by the View component (JSP).
*/
private void handleUIError (String error) {
Collection col;
if (error == null)
return;
col = (Collection) this.getObjErrors();
if (col == null) {
col = new LinkedList ();
setObjErrors (col);
}
col.add(error);
}
public Object generateView (DynaActionForm form) {
String className;
String pack;
String formName;
FormGenerator formGenerator = new FormGenerator ();
Boolean dynaActionForm;
Object jtReply;
if (form == null) {
return (null);
}
//pack = (String) form.get ("pack");
//if (pack == null || pack.equals ("")) {
//handleUIError ("Please enter a package name.");
//return (null);
//}
//if (pack != null && !pack.equals (""))
// formGenerator.setPack(pack);
className = (String) form.get ("className");
if (className == null || className.equals ("")) {
handleUIError ("Please enter a class name.");
//return (null);
}
formGenerator.setClassName(className);
formName = (String) form.get ("formName");
if (formName == null || formName.equals ("")) {
handleUIError ("Please enter a form name.");
//return (null);
}
formGenerator.setFormName(formName);
if (getObjErrors() != null) {
return (null);
}
dynaActionForm = (Boolean) form.get ("dynaActionForm");
if (dynaActionForm != null) {
handleTrace ("dynaActionForm:" + dynaActionForm.booleanValue());
formGenerator.setDynaActionForm(dynaActionForm.booleanValue());
}
jtReply = formGenerator.processMessage(new JtMessage (JtObject.JtACTIVATE));
// Propagate the exception
if (formGenerator.getObjException() != null)
this.setObjException(formGenerator.getObjException());
return (jtReply);
}
/**
* Process object messages.
* <ul>
* <li> JtACTIVATE
* </ul>
* @param message message
*/
public Object processMessage (Object message) {
//Object data;
JtContext context;
ActionForm form = null;
JtMessage e = (JtMessage) message;
if (e == null || (e.getMsgId() == null))
return (null);
context = (JtContext) e.getMsgContext();
if (context != null)
form = (ActionForm) context.getActionForm();
if (e.getMsgId().equals(JtObject.JtACTIVATE)) {
// pass the form information
//data = e.getMsgData ();
return ( generateView ((DynaActionForm) form));
}
return (super.processMessage(message));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?