1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.taglib;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 import javax.servlet.jsp.JspException;
26 import javax.servlet.jsp.tagext.BodyContent;
27 import javax.servlet.jsp.tagext.BodyTag;
28
29 public abstract class TobagoBodyTag extends TobagoTag implements BodyTag {
30
31 private static final Logger LOG = LoggerFactory.getLogger(TobagoBodyTag.class);
32
33 private BodyContent bodyContent;
34
35 public int doAfterBody() throws JspException {
36 return getDoAfterBodyValue();
37 }
38
39 public void doInitBody() throws JspException {
40 }
41
42 protected String getBodyContentStr() {
43 String content = bodyContent.getString();
44 bodyContent.clearBody();
45 return content;
46 }
47
48 protected boolean isBodyContentEmpty() {
49 if (bodyContent != null) {
50 String content = bodyContent.getString();
51 String tmp = content.replace('\n', ' ');
52 if (tmp.trim().length() > 0) {
53 return false;
54 }
55 }
56 return true;
57 }
58
59 protected int getDoStartValue() throws JspException {
60 return BodyTag.EVAL_BODY_BUFFERED;
61 }
62
63 protected int getDoAfterBodyValue() throws JspException {
64 return BodyTag.SKIP_BODY;
65 }
66
67 public void release() {
68 super.release();
69 bodyContent = null;
70 }
71
72 public void setBodyContent(BodyContent bodyContent) {
73 this.bodyContent = bodyContent;
74 }
75 }
76