001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020 package org.apache.myfaces.tobago.renderkit; 021 022 import org.apache.commons.logging.Log; 023 import org.apache.commons.logging.LogFactory; 024 import org.apache.myfaces.tobago.component.ComponentUtil; 025 026 import javax.faces.component.UIComponent; 027 import javax.faces.component.UIInput; 028 import javax.faces.context.FacesContext; 029 import java.util.Map; 030 031 public class InputRendererBase extends LayoutableRendererBase { 032 033 private static final Log LOG = LogFactory.getLog(InputRendererBase.class); 034 035 public void decode(FacesContext context, UIComponent component) { 036 UIInput uiInput; 037 if (component instanceof UIInput) { 038 uiInput = (UIInput) component; 039 } else { 040 return; // no decoding required 041 } 042 043 if (ComponentUtil.isOutputOnly(component)) { 044 return; 045 } 046 047 String clientId = component.getClientId(context); 048 049 Map requestParameterMap = context.getExternalContext() 050 .getRequestParameterMap(); 051 if (requestParameterMap.containsKey(clientId)) { 052 if (LOG.isDebugEnabled()) { 053 LOG.debug("clientId = '" + clientId + "'"); 054 LOG.debug("requestParameterMap.get(clientId) = '" 055 + requestParameterMap.get(clientId) + "'"); 056 LOG.debug("requestParameterMap.get(clientId).getClass().getName() = '" 057 + requestParameterMap.get(clientId).getClass().getName() + "'"); 058 } 059 String newValue = (String) requestParameterMap.get(clientId); 060 uiInput.setSubmittedValue(newValue); 061 } 062 } 063 064 public int getLabelWidth(FacesContext facesContext, UIComponent component) { 065 return getConfiguredValue(facesContext, component, "labelWidth"); 066 } 067 068 } 069