01: /*
02: * de.jwic.renderer.velocity.ChildRenderer
03: * $Id: ChildRenderer.java,v 1.1 2006/01/16 08:31:13 lordsam Exp $
04: */
05: package de.jwic.renderer.util;
06:
07: import de.jwic.base.Control;
08: import de.jwic.base.IControlContainer;
09: import de.jwic.base.IControlRenderer;
10: import de.jwic.base.JWicRuntime;
11: import de.jwic.base.RenderContext;
12:
13: /**
14: * Used as a context object to insert a control at a specified location.
15: * @author Florian Lippisch
16: * @version $Revision: 1.1 $
17: */
18: public class ChildRenderer {
19:
20: private IControlContainer container;
21: private RenderContext context;
22:
23: public ChildRenderer(IControlContainer controlContainer,
24: RenderContext context) {
25: this .container = controlContainer;
26: this .context = context;
27: }
28:
29: /**
30: * Renders a child control.
31: * @param controlName
32: */
33: public void control(String controlName) {
34:
35: Control ctrl = container.getControl(controlName);
36: if (ctrl != null) {
37: IControlRenderer renderer = JWicRuntime.getRenderer(ctrl
38: .getRendererId());
39: renderer.renderControl(ctrl, context);
40: } else {
41: context.getWriter().write(
42: "[no control named " + controlName + "]");
43: }
44:
45: }
46:
47: }
|