1 /* 2 * Project Bimbo. 3 * Copyright 2008 Frank Cornelis. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * 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 18 package net.sf.bimbo.spi; 19 20 import java.io.PrintWriter; 21 22 import javax.servlet.http.HttpServletRequest; 23 24 import net.sf.bimbo.Input; 25 26 /** 27 * Interface for renderer component. 28 * 29 * @author fcorneli 30 * 31 * @param <T> 32 * the type of the field that this component will render. 33 */ 34 public interface Renderer<T> { 35 36 /** 37 * Renders the component for input. 38 * 39 * @param fieldName 40 * @param initialValue 41 * @param inputAnnotation 42 * TODO 43 * @param writer 44 */ 45 void renderInput(String fieldName, T initialValue, Input inputAnnotation, 46 PrintWriter writer); 47 48 /** 49 * Restores the value from the HTTP request parameters. 50 * 51 * @param fieldName 52 * @param request 53 * @return 54 * @throws ConversionException 55 * in case the request parameters could not be converted 56 * correctly. 57 */ 58 T restore(String fieldName, HttpServletRequest request) 59 throws ConversionException; 60 61 /** 62 * Renders the component for output. 63 * 64 * @param fieldName 65 * @param outputValue 66 * @param writer 67 */ 68 void renderOutput(String fieldName, T outputValue, PrintWriter writer); 69 70 }