View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.view.facelets.tag.jsf.core;
20  
21  import javax.faces.component.UIComponent;
22  import javax.faces.view.facelets.ComponentConfig;
23  import javax.faces.view.facelets.ComponentHandler;
24  import javax.faces.view.facelets.FaceletContext;
25  import javax.faces.view.facelets.TextHandler;
26  
27  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
28  import org.apache.myfaces.view.facelets.tag.TagHandlerUtils;
29  
30  /**
31   * Handler for f:verbatim
32   * 
33   * @author Adam Winer
34   * @version $Id$
35   */
36  @JSFFaceletTag(
37          name = "f:verbatim",
38          bodyContent = "empty", 
39          tagClass="org.apache.myfaces.taglib.core.VerbatimTag")
40  public final class VerbatimHandler extends ComponentHandler
41  {
42      public VerbatimHandler(ComponentConfig config)
43      {
44          super(config);
45      }
46  
47      public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
48      {
49          StringBuffer content = new StringBuffer();
50          for (TextHandler handler : TagHandlerUtils.findNextByType(nextHandler, TextHandler.class))
51          {
52              content.append(handler.getText(ctx));
53          }
54  
55          c.getAttributes().put("value", content.toString());
56          c.getAttributes().put("escape", Boolean.FALSE);
57          c.setTransient(true);
58      }
59  
60      public void applyNextHandler(FaceletContext ctx, UIComponent c)
61      {
62      }
63  }