jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv JstlFmtTLV.java
Date Wed, 17 Apr 2002 20:28:38 GMT
luehe       02/04/17 13:28:38

  Modified:    standard/src/org/apache/taglibs/standard/tlv JstlFmtTLV.java
  Log:
  Leverage cross-breeding support between EL and RT libraries for
  <fmt:param> and <fmt:message>.
  
  Revision  Changes    Path
  1.16      +35 -0     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlFmtTLV.java
  
  Index: JstlFmtTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlFmtTLV.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JstlFmtTLV.java	17 Apr 2002 17:59:23 -0000	1.15
  +++ JstlFmtTLV.java	17 Apr 2002 20:28:38 -0000	1.16
  @@ -143,6 +143,8 @@
       private class Handler extends DefaultHandler {
   
   	// parser state
  +	private int depth = 0;
  +	private Stack messageDepths = new Stack();
   	private String lastElementName = null;
   	private boolean bodyNecessary = false;
   	private boolean bodyIllegal = false;
  @@ -194,6 +196,28 @@
                   && hasDanglingScope(a))
                   fail(Resources.getMessage("TLV_DANGLING_SCOPE", qn));
   
  +	    /*
  +	     * Make sure <fmt:param> is nested inside <fmt:message>. Note that
  +	     * <fmt:param> does not need to be a direct child of <fmt:message>.
  +	     * Otherwise, the following would not work:
  +	     *
  +	     *  <fmt:message key="..." bundle="...">
  +	     *   <c:forEach var="arg" items="...">
  +	     *    <fmt:param value="${arg}"/>
  +	     *   </c:forEach>
  +	     *  </fmt:message>
  +	     */
  +	    if (isFmtTag(ns, ln, MESSAGE_PARAM) && messageDepths.empty()) {
  +		fail(Resources.getMessage("PARAM_OUTSIDE_MESSAGE"));
  +	    }
  +
  +	    // now, modify state
  +
  +	    // If we're in a <message>, record relevant state
  +	    if (isFmtTag(ns, ln, MESSAGE)) {
  +		messageDepths.push(new Integer(depth));
  +	    }
  +
   	    // set up a check against illegal attribute/body combinations
   	    bodyIllegal = false;
   	    bodyNecessary = false;
  @@ -216,6 +240,9 @@
   	    // record the most recent tag (for error reporting)
   	    lastElementName = qn;
               lastElementId = a.getValue(JSP, "id");
  +
  +	    // we're a new element, so increase depth
  +	    depth++;
   	}
   
   	public void characters(char[] ch, int start, int length) {
  @@ -244,6 +271,14 @@
   		fail(Resources.getMessage("TLV_MISSING_BODY",
   		    lastElementName));
   	    bodyIllegal = false;	// reset: we've left the tag
  +
  +	    // update <message>-related state
  +	    if (isFmtTag(ns, ln, MESSAGE)) {
  +		messageDepths.pop();
  +	    }
  +
  +	    // update our depth
  +	    depth--;
   	}
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message