01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/jsf/tags/sakai_2-4-1/widgets/src/java/org/sakaiproject/jsf/renderer/AnchorReferenceRenderer.java $
03: * $Id: AnchorReferenceRenderer.java 9278 2006-05-10 23:29:21Z ray@media.berkeley.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.jsf.renderer;
21:
22: import java.io.IOException;
23: import javax.faces.component.UIComponent;
24: import javax.faces.component.UIOutput;
25: import javax.faces.context.FacesContext;
26: import javax.faces.context.ResponseWriter;
27: import javax.faces.render.Renderer;
28:
29: import org.sakaiproject.jsf.util.RendererUtil;
30:
31: /**
32: * <p>Description: </p>
33: * <p>Render an anchor component with
34: * <code>name</code> attribute.</p>
35: * <p>Copyright: Copyright (c) 2005</p>
36: * <p>Organization: Sakai Project</p>
37: * @author Ed Smiley
38: * @version $Id: AnchorReferenceRenderer.java 9278 2006-05-10 23:29:21Z ray@media.berkeley.edu $
39: */
40:
41: public class AnchorReferenceRenderer extends Renderer {
42:
43: public boolean supportsComponentType(UIComponent component) {
44: return (component instanceof UIOutput);
45: }
46:
47: /**
48: * <p>Render a an anchor tag with name attribute.</p>
49: * @param context FacesContext for the request we are processing
50: * @param component UIComponent to be rendered
51: *
52: * @throws IOException if an input/output error occurs while rendering
53: * @throws NullPointerException if <code>context</code>
54: * or <code>component</code> is null
55: */
56: /**
57: * <p>Faces render output method to output script tag.</p>
58: * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
59: *
60: * @param context <code>FacesContext</code> for the current request
61: * @param component <code>UIComponent</code> being rendered
62: *
63: * @throws IOException if an input/output error occurs
64: */
65: public void encodeBegin(FacesContext context, UIComponent component)
66: throws IOException {
67:
68: if (!component.isRendered()) {
69: return;
70: }
71:
72: String name = (String) RendererUtil.getAttribute(context,
73: component, "name");
74:
75: ResponseWriter writer = context.getResponseWriter();
76: String contextPath = context.getExternalContext()
77: .getRequestContextPath();
78: writer.write("<a name=\"" + name + "\"/>");
79: }
80:
81: }
|