自動生成
ちょっと勉強をかねて、HTMLファイルを元にFormBeanやActionを作るのをとりあえず、作ってみたけど、、、まだまだ。。。でも、いざってときにすぐに作れるように準備はしとかないと。
とりあえず、下のsingleForm.htmlから
<html> <head> <title>try html</title> </head> <body> <form method="POST"> <table> <tr> <th>input text</th> <td><input type="text" name="inputtext" value="text!!!"/></td> </tr> <tr> <th>input password</th> <td><input type="password" name="inputpassword" value="password!!!"/></td> </tr> <tr> <th>input file</th> <td><input type="file" name="inputfile"/></td> </tr> </table> <input type="submit" name="doSubmit" value="OK"/> <input type="button" name="goButton" value="BACK"/> <input type="reset"/> </form> </body> </html>
下のようなFormBeanとActionの雛形と一応Actionのインターフェースを作るようにしてみた。
FormBeanとActionのインターフェースは毎回上書きだけど、Actionはない場合のみ作成するという方針で。
で、Mayaaファイルの雛形も作ろうと思ったんだけど、いろいろ考えれそうなのでまだ未着手。
public class SingleFormForm extends ValidatorForm { private static final long serialVersionUID = 1L; private String inputtext; private String inputpassword; private FormFile inputfile; public String getInputtext() { return this.inputtext; } public void setInputtext(String inputtext) { this.inputtext = inputtext; } public String getInputpassword() { return this.inputpassword; } public void setInputpassword(String inputpassword) { this.inputpassword = inputpassword; } public FormFile getInputfile() { return this.inputfile; } public void setInputfile(FormFile inputfile) { this.inputfile = inputfile; } public String toString() { StringBuffer buff = new StringBuffer("["); buff.append("/inputtext=").append(inputtext); buff.append("/inputpassword=").append(inputpassword); buff.append("/inputfile=").append(inputfile); buff.append("]"); return buff.toString(); } }
public interface ISingleFormAction { ActionForward initialize(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception; ActionForward doSubmit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception; ActionForward goButton(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception; }
public class SingleFormAction extends DispatchAction implements ISingleFormAction { public ActionForward initialize(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return mapping.findForward(""); } public ActionForward doSubmit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return mapping.findForward(""); } public ActionForward goButton(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return mapping.findForward(""); } }
NekoHTMLとFreeMarkerで意外と手軽に作れることがわかったけど、どのように取り込むかをもっと考えないと。
時間の空きをみてちょこちょこ作ろうっと。