001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.tags.html;
020:
021: import org.apache.beehive.netui.tags.AbstractClassicTag;
022: import org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer;
023: import org.apache.beehive.netui.util.Bundle;
024:
025: import javax.servlet.jsp.JspException;
026: import javax.servlet.jsp.tagext.JspTag;
027: import javax.servlet.jsp.tagext.SimpleTagSupport;
028:
029: /**
030: * Causes a value to be retrieved when a popup window closes.
031: * @jsptagref.tagdescription Causes a value to be retrieved when a popup window closes.
032: * @example <pre>
033: * <netui:anchor action="getCityZipFromNestedPageFlow" popup="true">
034: * Get a city and zip code
035: * <netui:configurePopup resizable="false" width="400" height="200">
036: * <netui:retrievePopupOutput tagIdRef="zipCodeField" dataSource="outputFormBean.zipCode" />
037: * <netui:retrievePopupOutput tagIdRef="cityField" dataSource="outputFormBean.city" />
038: * </netui:configurePopup>
039: * </netui:anchor></pre>
040: * @netui:tag name="retrievePopupOutput" description="Causes a value to be retrieved when a popup window closes."
041: */
042: public class RetrievePopupOutput extends AbstractClassicTag {
043: private String _tagIdRef = null;
044: private String _dataSource = null;
045:
046: /**
047: * Return the name of the Tag.
048: */
049: public String getTagName() {
050: return "RetrievePopupOutput";
051: }
052:
053: /**
054: * Sets the ID of the form field to populate with a popup output.
055: * @param tagIdRef the ID of the form field to populate with a popup output.
056: * @jsptagref.attributedescription The ID of the form field to populate with a popup output.
057: * @jsptagref.databindable false
058: * @jsptagref.attributesyntaxvalue <i>string_tagidRef</i>
059: * @netui:attribute required="true" rtexprvalue="true"
060: * description="The ID of the form field to populate with a popup output."
061: */
062: public void setTagIdRef(String tagIdRef) {
063: _tagIdRef = tagIdRef;
064: }
065:
066: /**
067: * Sets an expression to be evaluated and retrieved from the popup window.
068: * @param dataSource an expression to be evaluated and retrieved from the popup window.
069: * @jsptagref.attributedescription An expression to be evaluated and retrieved from the popup window.
070: * @jsptagref.databindable false
071: * @jsptagref.attributesyntaxvalue <i>string_dataSource</i>
072: * @netui:attribute required="true" rtexprvalue="true"
073: * description="An expression to be evaluated and retrieved from the popup window."
074: */
075: public void setDataSource(String dataSource) {
076: _dataSource = dataSource;
077: }
078:
079: /**
080: * @throws JspException if a JSP exception has occurred
081: */
082: public int doStartTag() throws JspException {
083: JspTag parentTag = SimpleTagSupport.findAncestorWithClass(this ,
084: ConfigurePopup.class);
085: if (parentTag == null) {
086: String msg = Bundle
087: .getString("Tags_InvalidRetrievePopupOutputParent");
088: registerTagError(msg, null);
089: reportErrors();
090: } else {
091: JspTag parentParent = SimpleTagSupport
092: .findAncestorWithClass(this , IUrlParams.class);
093: if (parentTag != null) // there will already be an error on ConfigurePopup if there is no URLParams parent.
094: {
095: IUrlParams urlParams = (IUrlParams) parentParent;
096: urlParams.addParameter(ReturnActionViewRenderer
097: .getMapItemParamName(), _dataSource
098: + ReturnActionViewRenderer.getDelim()
099: + getIdForTagId(_tagIdRef), null);
100: }
101: }
102: localRelease();
103: return SKIP_BODY;
104: }
105:
106: /**
107: * Release any acquired resources.
108: */
109: protected void localRelease() {
110: super.localRelease();
111:
112: _dataSource = null;
113: _tagIdRef = null;
114: }
115: }
|