File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
main/java/org/apache/struts2/components
test/java/org/apache/struts2/views/jsp Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 3131 * complex expression and then simply reference that variable each time rather than the complex expression. This is
3232 * useful in both cases: when the complex expression takes time (performance improvement) or is hard to read (code
3333 * readability improvement).</p>
34- * <p>If the tag is used with body content, the evaluation of the value parameter is omitted. Instead, the String to
35- * which the body evaluates is set as value for the scoped variable.</p>
34+ * <p>If the value parameter is omitted, the String to which the body evaluates is set as value for the scoped variable.</p>
3635 *
3736 * <p>The scopes available are as follows:</p>
3837 * <ul>
@@ -94,11 +93,7 @@ public boolean end(Writer writer, String body) {
9493
9594 Object o ;
9695 if (value == null ) {
97- if (body != null && !body .equals ("" )) {
98- o = body ;
99- } else {
100- o = findValue ("top" );
101- }
96+ o = body ;
10297 } else {
10398 o = findValue (value );
10499 }
Original file line number Diff line number Diff line change @@ -121,6 +121,20 @@ public void testSetTrimBody() throws JspException, IOException {
121121 assertEquals (beginEndSpaceString , context .get ("foo" ));
122122 }
123123
124+ public void testEmptyBody () throws JspException {
125+ StrutsMockBodyContent mockBodyContent ;
126+ String variableName = "foo" ;
127+ tag .setName (variableName );
128+ tag .setValue (null );
129+ mockBodyContent = new StrutsMockBodyContent (new MockJspWriter ());
130+ String emptyBody = "" ;
131+ mockBodyContent .setString (emptyBody );
132+ tag .setBodyContent (mockBodyContent );
133+ tag .doStartTag ();
134+ tag .doEndTag ();
135+ assertEquals (emptyBody , context .get (variableName ));
136+ }
137+
124138 protected void setUp () throws Exception {
125139 super .setUp ();
126140
You can’t perform that action at this time.
0 commit comments