001: /*
002: * $Id: ELMessagesNotPresentTag.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.strutsel.taglib.logic;
022:
023: import org.apache.struts.taglib.logic.MessagesNotPresentTag;
024: import org.apache.strutsel.taglib.utils.EvalHelper;
025:
026: import javax.servlet.jsp.JspException;
027:
028: /**
029: * Evalute to <code>false</code> if an <code>ActionMessages</code> class or a
030: * class that can be converted to an <code>ActionMessages</code> class is in
031: * request scope under the specified key and there is at least one message in
032: * the class or for the property specified. <p> This class is a subclass of
033: * the class <code>org.apache.struts.taglib.logic.MessagesNotPresentTag</code>
034: * which provides most of the described functionality. This subclass allows
035: * all attribute values to be specified as expressions utilizing the
036: * JavaServer Pages Standard Library expression language.
037: *
038: * @version $Rev: 471754 $
039: */
040: public class ELMessagesNotPresentTag extends MessagesNotPresentTag {
041: /**
042: * Instance variable mapped to "name" tag attribute. (Mapping set in
043: * associated BeanInfo class.)
044: */
045: private String nameExpr;
046:
047: /**
048: * Instance variable mapped to "property" tag attribute. (Mapping set in
049: * associated BeanInfo class.)
050: */
051: private String propertyExpr;
052:
053: /**
054: * Instance variable mapped to "message" tag attribute. (Mapping set in
055: * associated BeanInfo class.)
056: */
057: private String messageExpr;
058:
059: /**
060: * Getter method for "name" tag attribute. (Mapping set in associated
061: * BeanInfo class.)
062: */
063: public String getNameExpr() {
064: return (nameExpr);
065: }
066:
067: /**
068: * Getter method for "property" tag attribute. (Mapping set in associated
069: * BeanInfo class.)
070: */
071: public String getPropertyExpr() {
072: return (propertyExpr);
073: }
074:
075: /**
076: * Getter method for "message" tag attribute. (Mapping set in associated
077: * BeanInfo class.)
078: */
079: public String getMessageExpr() {
080: return (messageExpr);
081: }
082:
083: /**
084: * Setter method for "name" tag attribute. (Mapping set in associated
085: * BeanInfo class.)
086: */
087: public void setNameExpr(String nameExpr) {
088: this .nameExpr = nameExpr;
089: }
090:
091: /**
092: * Setter method for "property" tag attribute. (Mapping set in associated
093: * BeanInfo class.)
094: */
095: public void setPropertyExpr(String propertyExpr) {
096: this .propertyExpr = propertyExpr;
097: }
098:
099: /**
100: * Setter method for "message" tag attribute. (Mapping set in associated
101: * BeanInfo class.)
102: */
103: public void setMessageExpr(String messageExpr) {
104: this .messageExpr = messageExpr;
105: }
106:
107: /**
108: * Releases state of custom tag so this instance can be reused.
109: */
110: public void release() {
111: super .release();
112: setNameExpr(null);
113: setPropertyExpr(null);
114: setMessageExpr(null);
115: }
116:
117: /**
118: * Process the start tag.
119: *
120: * @throws JspException if a JSP exception has occurred
121: */
122: public int doStartTag() throws JspException {
123: evaluateExpressions();
124:
125: return (super .doStartTag());
126: }
127:
128: /**
129: * Processes all attribute values which use the JSTL expression evaluation
130: * engine to determine their values.
131: *
132: * @throws JspException if a JSP exception has occurred
133: */
134: private void evaluateExpressions() throws JspException {
135: String string = null;
136:
137: if ((string = EvalHelper.evalString("name", getNameExpr(),
138: this , pageContext)) != null) {
139: setName(string);
140: }
141:
142: if ((string = EvalHelper.evalString("property",
143: getPropertyExpr(), this , pageContext)) != null) {
144: setProperty(string);
145: }
146:
147: if ((string = EvalHelper.evalString("message",
148: getMessageExpr(), this, pageContext)) != null) {
149: setMessage(string);
150: }
151: }
152: }
|