KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > form > ConnectFormTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.form;
14
15 import javax.servlet.jsp.JspException JavaDoc;
16 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
17
18 import org.apache.log4j.Logger;
19
20 import com.tonbeller.wcf.component.Form;
21 import com.tonbeller.wcf.controller.RequestContext;
22
23 public class ConnectFormTag extends TagSupport JavaDoc {
24   String JavaDoc form1;
25   String JavaDoc form2;
26     private static Logger logger = Logger.getLogger(ConnectFormTag.class);
27
28   public void setForm1(String JavaDoc string) {
29     form1 = string;
30   }
31
32   public void setForm2(String JavaDoc string) {
33     form2 = string;
34   }
35
36   public int doStartTag() throws JspException JavaDoc {
37         logger.info("enter");
38     RequestContext context = RequestContext.instance();
39     Form f1 = (Form)context.getModelReference(form1);
40     if (f1 == null) {
41       String JavaDoc err = "could not find " + form1;
42       logger.error(err);
43       throw new JspException JavaDoc(err);
44     }
45     Form f2 = (Form)context.getModelReference(form2);
46     if (f2 == null) {
47       String JavaDoc err = "could not find " + form2;
48       logger.error(err);
49       throw new JspException JavaDoc(err);
50     }
51     f1.addFormListener(f2);
52     f2.addFormListener(f1);
53         logger.info("leave");
54     return super.doStartTag();
55   }
56
57 }
58
Popular Tags