KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > html > RetrievePopupOutput


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.html;
19
20 import org.apache.beehive.netui.tags.AbstractClassicTag;
21 import org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer;
22 import org.apache.beehive.netui.util.Bundle;
23
24 import javax.servlet.jsp.JspException JavaDoc;
25 import javax.servlet.jsp.tagext.JspTag JavaDoc;
26 import javax.servlet.jsp.tagext.SimpleTagSupport JavaDoc;
27
28
29 /**
30  * Causes a value to be retrieved when a popup window closes.
31  * @jsptagref.tagdescription Causes a value to be retrieved when a popup window closes.
32  * @example <pre>
33  * &lt;netui:anchor action="getCityZipFromNestedPageFlow" popup="true">
34  * Get a city and zip code
35  * &lt;netui:configurePopup resizable="false" width="400" height="200">
36  * &lt;netui:retrievePopupOutput tagIdRef="zipCodeField" dataSource="outputFormBean.zipCode" /&gt;
37  * &lt;netui:retrievePopupOutput tagIdRef="cityField" dataSource="outputFormBean.city" /&gt;
38  * &lt;/netui:configurePopup>
39  * &lt;/netui:anchor></pre>
40  * @netui:tag name="retrievePopupOutput" description="Causes a value to be retrieved when a popup window closes."
41  */

42 public class RetrievePopupOutput
43         extends AbstractClassicTag
44 {
45     private String JavaDoc _tagIdRef = null;
46     private String JavaDoc _dataSource = null;
47
48     /**
49      * Return the name of the Tag.
50      */

51     public String JavaDoc getTagName()
52     {
53         return "RetrievePopupOutput";
54     }
55
56     /**
57      * Sets the ID of the form field to populate with a popup output.
58      * @param tagIdRef the ID of the form field to populate with a popup output.
59      * @jsptagref.attributedescription The ID of the form field to populate with a popup output.
60      * @jsptagref.databindable false
61      * @jsptagref.attributesyntaxvalue <i>string_tagidRef</i>
62      * @netui:attribute required="true" rtexprvalue="true"
63      * description="The ID of the form field to populate with a popup output."
64      */

65     public void setTagIdRef(String JavaDoc tagIdRef)
66     {
67         _tagIdRef = tagIdRef;
68     }
69
70     /**
71      * Sets an expression to be evaluated and retrieved from the popup window.
72      * @param dataSource an expression to be evaluated and retrieved from the popup window.
73      * @jsptagref.attributedescription An expression to be evaluated and retrieved from the popup window.
74      * @jsptagref.databindable false
75      * @jsptagref.attributesyntaxvalue <i>string_dataSource</i>
76      * @netui:attribute required="true" rtexprvalue="true"
77      * description="An expression to be evaluated and retrieved from the popup window."
78      */

79     public void setDataSource(String JavaDoc dataSource)
80     {
81         _dataSource = dataSource;
82     }
83
84     /**
85      * @throws JspException if a JSP exception has occurred
86      */

87     public int doStartTag() throws JspException JavaDoc
88     {
89         JspTag JavaDoc parentTag = SimpleTagSupport.findAncestorWithClass(this, ConfigurePopup.class);
90         if (parentTag == null) {
91             String JavaDoc msg = Bundle.getString("Tags_InvalidRetrievePopupOutputParent");
92             registerTagError(msg, null);
93             reportErrors();
94         }
95         else {
96             JspTag JavaDoc parentParent = SimpleTagSupport.findAncestorWithClass(this, IUrlParams.class);
97             if (parentTag != null) // there will already be an error on ConfigurePopup if there is no URLParams parent.
98
{
99                 IUrlParams urlParams = (IUrlParams) parentParent;
100                 urlParams.addParameter(ReturnActionViewRenderer.getMapItemParamName(),
101                         _dataSource + ReturnActionViewRenderer.getDelim() + getIdForTagId(_tagIdRef),
102                         null);
103             }
104         }
105         localRelease();
106         return SKIP_BODY;
107     }
108
109     /**
110      * Release any acquired resources.
111      */

112     protected void localRelease()
113     {
114         super.localRelease();
115
116         _dataSource = null;
117         _tagIdRef = null;
118     }
119 }
120
Popular Tags