KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > webui > taglib > html > FormTag


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.webui.taglib.html;
17
18 import org.jmanage.webui.util.RequestParams;
19 import org.jmanage.util.StringUtils;
20
21 import javax.servlet.jsp.JspException JavaDoc;
22 import javax.servlet.jsp.JspWriter JavaDoc;
23 import javax.servlet.ServletRequest JavaDoc;
24 import java.io.IOException JavaDoc;
25
26 /**
27  *
28  * date: Jun 20, 2004
29  * @author Rakesh Kalra
30  */

31 public class FormTag extends org.apache.struts.taglib.html.FormTag {
32
33     private static final String JavaDoc HIDDEN_FIELD_APP_ID_BEGIN =
34             "<input type=\"hidden\" name=\"" + RequestParams.APPLICATION_ID + "\" value=\"" ;
35     private static final String JavaDoc HIDDEN_FIELD_OBJECT_NAME_BEGIN =
36             "<input type=\"hidden\" name=\"" + RequestParams.OBJECT_NAME + "\" value=\"" ;
37     private static final String JavaDoc HIDDEN_FIELD_END =
38             "\"/>";
39
40     /**
41      * Render the beginning of this form.
42      *
43      * @exception JspException if a JSP exception has occurred
44      */

45     public int doStartTag() throws JspException JavaDoc {
46         int result = super.doStartTag();
47         addHiddenFields();
48         return result;
49     }
50
51     private void addHiddenFields()
52         throws JspException JavaDoc{
53         try {
54             final ServletRequest JavaDoc request = pageContext.getRequest();
55             final JspWriter JavaDoc writer = pageContext.getOut();
56             String JavaDoc applicationId =
57                     request.getParameter(RequestParams.APPLICATION_ID);
58             if(applicationId != null){
59                 writer.println();
60                 writer.print(HIDDEN_FIELD_APP_ID_BEGIN);
61                 writer.print(applicationId);
62                 writer.println(HIDDEN_FIELD_END);
63             }
64             String JavaDoc objectName =
65                     request.getParameter(RequestParams.OBJECT_NAME);
66             if(objectName != null){
67                 writer.print(HIDDEN_FIELD_OBJECT_NAME_BEGIN);
68                 writer.print(StringUtils.htmlEscape(objectName));
69                 writer.println(HIDDEN_FIELD_END);
70             }
71
72         } catch (IOException JavaDoc e) {
73             throw new JspException JavaDoc(e);
74         }
75     }
76 }
77
Popular Tags