01: /***************************************************************
02: * This file is part of the [fleXive](R) project.
03: *
04: * Copyright (c) 1999-2007
05: * UCS - unique computing solutions gmbh (http://www.ucs.at)
06: * All rights reserved
07: *
08: * The [fleXive](R) project is free software; you can redistribute
09: * it and/or modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation;
11: * either version 2 of the License, or (at your option) any
12: * later version.
13: *
14: * The GNU General Public License can be found at
15: * http://www.gnu.org/copyleft/gpl.html.
16: * A copy is found in the textfile GPL.txt and important notices to the
17: * license from the author are found in LICENSE.txt distributed with
18: * these libraries.
19: *
20: * This library is distributed in the hope that it will be useful,
21: * but WITHOUT ANY WARRANTY; without even the implied warranty of
22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: * GNU General Public License for more details.
24: *
25: * For further information about UCS - unique computing solutions gmbh,
26: * please see the company website: http://www.ucs.at
27: *
28: * For further information about [fleXive](R), please see the
29: * project website: http://www.flexive.org
30: *
31: *
32: * This copyright notice MUST APPEAR in all copies of the file!
33: ***************************************************************/package com.flexive.faces.components.input;
34:
35: import com.flexive.shared.FxLanguage;
36: import com.flexive.shared.value.FxValue;
37:
38: import javax.faces.context.ResponseWriter;
39: import java.io.IOException;
40:
41: /**
42: * Renders the given FxValue.
43: *
44: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
45: * @version $Rev: 1 $
46: */
47: abstract class RenderHelper {
48:
49: protected final FxValueInput component;
50: protected final ResponseWriter writer;
51: protected final String clientId;
52: protected final FxValue value;
53:
54: /**
55: * @param writer the current response writer
56: * @param clientId the component's client ID
57: * @param value the initial input value
58: * @param component the input component
59: */
60: protected RenderHelper(ResponseWriter writer,
61: FxValueInput component, String clientId, FxValue value) {
62: this .component = component;
63: this .writer = writer;
64: this .clientId = clientId;
65: this .value = value;
66: }
67:
68: /**
69: * Render the input fields for the given value/type.
70: *
71: * @throws java.io.IOException if an output error occured
72: */
73: protected void render() throws IOException {
74: if (value.isMultiLanguage()
75: && !component.isDisableMultiLanguage()) {
76: encodeMultiLanguageField();
77: } else {
78: encodeField(clientId + FxValueInputRenderer.INPUT, null);
79: }
80: }
81:
82: /**
83: * Render a multi-language input field for the current value.
84: *
85: * @throws IOException if the input could not be rendered
86: */
87: protected abstract void encodeMultiLanguageField()
88: throws IOException;
89:
90: /**
91: * Render a input field for the given language.
92: *
93: * @param inputId the input element ID (= form name)
94: * @param language the language for the input field, or null if the value is not multi-language.
95: * @throws IOException if the input could not be rendered
96: */
97: protected abstract void encodeField(String inputId,
98: FxLanguage language) throws IOException;
99: }
|