01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.tags.tree;
20:
21: import org.apache.beehive.netui.util.internal.InternalStringBuilder;
22:
23: import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
24: import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
25: import org.apache.beehive.netui.util.logging.Logger;
26:
27: import javax.servlet.http.HttpServletRequest;
28: import javax.servlet.jsp.JspException;
29:
30: /**
31: * Derived class to help handle issues specific to rendering the nodes
32: * of a tree for an XmlHttpRequest via the {@link TreeCRI}.
33: */
34: public class ServletTreeRenderSupport extends TreeRenderSupport {
35: private static final Logger logger = Logger
36: .getInstance(ServletTreeRenderSupport.class);
37: AbstractRenderAppender _writer;
38: InternalStringBuilder _sb;
39:
40: ServletTreeRenderSupport(AbstractRenderAppender writer,
41: InternalStringBuilder sb) {
42: _writer = writer;
43: _sb = sb;
44: }
45:
46: protected void renderBeforeNode(AbstractRenderAppender writer,
47: TreeElement node) {
48: writer.append("<![CDATA[");
49: }
50:
51: protected void renderAfterNode(AbstractRenderAppender writer,
52: TreeElement node) {
53: writer.append("]]>");
54: TreeCRI.writeElement(_writer, "treeDiv", writer.toString()
55: .trim());
56: _sb.setLength(0);
57: }
58:
59: /**
60: * Errors during rendering will call through this method. During the XmlHttpRequest, these
61: * will just be logged and we will go on.
62: * @param message
63: * @param e
64: * @throws JspException
65: */
66: protected void registerTagError(String message, Throwable e)
67: throws JspException {
68: System.err.println("Error in rendering tree:" + message);
69: logger.error(message, e);
70: }
71:
72: protected String renderTagId(HttpServletRequest request,
73: String tagId, AbstractHtmlState state) {
74: // @todo: this needs to be implemented
75: return null;
76: }
77: }
|