You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/10/20 12:49:36 UTC
svn commit: r1186730 [8/22] - in /myfaces/commons/branches/jsf_20: examples/
examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/
examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/access...
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/AbstractTypedNumberConverter.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/AbstractTypedNumberConverter.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/AbstractTypedNumberConverter.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/AbstractTypedNumberConverter.java Thu Oct 20 10:49:18 2011
@@ -1,554 +1,554 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.commons.converter;
-
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Currency;
-import java.util.Locale;
-
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.ConverterException;
-
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.Converter;
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFConverter;
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
-import org.apache.myfaces.commons.util.MessageUtils;
-
-/**
- * Converter which uses either the manually set <code>destType</code> or the value binding to determine the
- * correct destination type to convert the number to
- *
- * This tag creates a number formatting converter and associates it with the nearest
- * parent UIComponent. It uses either the manually set destType or the value
- * binding to determine the correct destination type to convert the number to.
- *
- * Unless otherwise specified, all attributes accept static values or EL expressions.
- *
- *
- * @author imario@apache.org
- */
-@JSFConverter(
- name = "mcc:convertNumber",
- clazz = "org.apache.myfaces.commons.converter.TypedNumberConverter",
- tagClass = "org.apache.myfaces.commons.converter.TypedNumberConverterTag",
- tagHandler = "org.apache.myfaces.commons.converter.TypedNumberConverterTagHandler",
- serialuidtag = "-6592309048440572608L")
-public abstract class AbstractTypedNumberConverter extends ConverterBase
-{
- public static final String CONVERTER_ID = "org.apache.myfaces.custom.convertNumber.TypedNumberConverter";
-
- public AbstractTypedNumberConverter()
- {
- }
-
- public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
- {
- Object convertedValue = _getAsObject(facesContext, uiComponent, value);
- if (convertedValue == null)
- {
- return null;
- }
-
- Class destType = getDestType();
- if (destType == null)
- {
- ValueExpression valueBinding = uiComponent.getValueExpression("value");
- if (valueBinding != null)
- {
- destType = valueBinding.getType(facesContext.getELContext());
- }
- }
-
- if (destType != null)
- {
- Converter converter = ConvertUtils.lookup(destType);
- if (converter == null)
- {
- throw new UnsupportedOperationException("cant deal with " + destType);
- }
-
- // setting type to null, in fact the documentation is wrong here and this type is never used
- convertedValue = converter.convert(null, convertedValue);
- }
-
-
- return convertedValue;
- }
-
- /**
- * The java class name the value should be converted to.
- *
- * Default: automatically determined through valueBinding
- *
- */
- @JSFProperty
- public Class getDestType()
- {
- return (Class) getStateHelper().get(PropertyKeys.destType);
- }
-
- public void setDestType(Class destType)
- {
- getStateHelper().put(PropertyKeys.destType, destType);
- }
-
- /* ORIGINAL STUFF COPIED FROM javax.faces.convert.NumberConverter */
-
- // internal constants
- // private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.NumberConverter.CONVERSION";
- public static final String STRING_ID = "javax.faces.converter.STRING";
- public static final String CURRENCY_ID = "javax.faces.converter.NumberConverter.CURRENCY";
- public static final String NUMBER_ID = "javax.faces.converter.NumberConverter.NUMBER";
- public static final String PATTERN_ID = "javax.faces.converter.NumberConverter.PATTERN";
- public static final String PERCENT_ID = "javax.faces.converter.NumberConverter.PERCENT";
-
- private static final boolean JAVA_VERSION_14;
-
- static
- {
- JAVA_VERSION_14 = checkJavaVersion14();
- }
-
- private boolean _transient;
-
-
-
- // METHODS
- public Object _getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
- {
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value != null)
- {
- value = value.trim();
- if (value.length() > 0)
- {
- NumberFormat format = getNumberFormat(facesContext);
- format.setParseIntegerOnly(isIntegerOnly());
-
- DecimalFormat df = (DecimalFormat)format;
-
- // The best we can do in this case is check if there is a ValueExpression
- // with a BigDecimal as returning type , and if that so enable BigDecimal parsing
- // to prevent loss in precision, and do not break existing examples (since
- // in those cases it is expected to return Double). See MYFACES-1890 and TRINIDAD-1124
- // for details
- Class destType = getDestType();
- if (destType == null)
- {
- ValueExpression valueBinding = uiComponent.getValueExpression("value");
- if (valueBinding != null)
- {
- destType = valueBinding.getType(facesContext.getELContext());
- }
- }
- if (destType != null && BigDecimal.class.isAssignableFrom(destType))
- {
- df.setParseBigDecimal(true);
- }
-
- DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
- boolean changed = false;
- if(dfs.getGroupingSeparator() == '\u00a0')
- {
- dfs.setGroupingSeparator(' ');
- df.setDecimalFormatSymbols(dfs);
- changed = true;
- }
-
- formatCurrency(format);
-
- try
- {
- return format.parse(value);
- }
- catch (ParseException e)
- {
- if(changed)
- {
- dfs.setGroupingSeparator('\u00a0');
- df.setDecimalFormatSymbols(dfs);
- }
- try
- {
- return format.parse(value);
- }
- catch (ParseException pe)
- {
-
- if(getPattern() != null)
- throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
- PATTERN_ID,
- new Object[]{value,"$###,###",MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
- else if(getType().equals("number"))
- throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
- NUMBER_ID,
- new Object[]{value,format.format(21),MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
- else if(getType().equals("currency"))
- throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
- CURRENCY_ID,
- new Object[]{value,format.format(42.25),MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
- else if(getType().equals("percent"))
- throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
- PERCENT_ID,
- new Object[]{value,format.format(.90),MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
- }
- }
- }
- }
- return null;
- }
-
- public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
- {
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return "";
- }
- if (value instanceof String)
- {
- return (String)value;
- }
-
- NumberFormat format = getNumberFormat(facesContext);
- format.setGroupingUsed(isGroupingUsed());
- Integer maxFractionDigits = getMaxFractionDigits();
- Integer maxIntegerDigits = getMaxIntegerDigits();
- Integer minFractionDigits = getMinFractionDigits();
- Integer minIntegerDigits = getMinIntegerDigits();
- if (maxFractionDigits != null) format.setMaximumFractionDigits(maxFractionDigits);
- if (maxIntegerDigits != null) format.setMaximumIntegerDigits(maxIntegerDigits);
- if (minFractionDigits != null) format.setMinimumFractionDigits(minFractionDigits);
- if (minIntegerDigits != null) format.setMinimumIntegerDigits(minIntegerDigits);
- formatCurrency(format);
- try
- {
- return format.format(value);
- }
- catch (Exception e)
- {
- throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR, STRING_ID, new Object[]{value,MessageUtils.getLabel(facesContext, uiComponent)}, facesContext),e);
- }
- }
-
- private NumberFormat getNumberFormat(FacesContext facesContext)
- {
- Locale lokale = getLocale();
-
- if (getPattern() == null && getType() == null)
- {
- throw new ConverterException("Cannot get NumberFormat, either type or pattern needed.");
- }
-
- // pattern
- if (getPattern() != null)
- {
- return new DecimalFormat(getPattern(), new DecimalFormatSymbols(lokale));
- }
-
- // type
- if (getType().equals("number"))
- {
- return NumberFormat.getNumberInstance(lokale);
- }
- else if (getType().equals("currency"))
- {
- return NumberFormat.getCurrencyInstance(lokale);
- }
- else if (getType().equals("percent"))
- {
- return NumberFormat.getPercentInstance(lokale);
- }
- throw new ConverterException("Cannot get NumberFormat, illegal type " + getType());
- }
-
- private void formatCurrency(NumberFormat format)
- {
- if (getLocalCurrencyCode() == null && getLocalCurrencySymbol() == null)
- {
- return;
- }
-
- boolean useCurrencyCode;
- if (JAVA_VERSION_14)
- {
- useCurrencyCode = getLocalCurrencyCode() != null;
- }
- else
- {
- useCurrencyCode = getLocalCurrencySymbol() == null;
- }
-
- if (useCurrencyCode)
- {
- // set Currency
- try
- {
- format.setCurrency(Currency.getInstance(getLocalCurrencyCode()));
- }
- catch (Exception e)
- {
- throw new ConverterException("Unable to get Currency instance for currencyCode " +
- getLocalCurrencyCode());
- }
- }
- else if (format instanceof DecimalFormat)
-
- {
- DecimalFormat dFormat = (DecimalFormat)format;
- DecimalFormatSymbols symbols = dFormat.getDecimalFormatSymbols();
- symbols.setCurrencySymbol(getLocalCurrencySymbol());
- dFormat.setDecimalFormatSymbols(symbols);
- }
- }
-
- // STATE SAVE/RESTORE
-
- // GETTER & SETTER
-
- /**
- * ISO 4217 currency code
- *
- */
- @JSFProperty
- public String getCurrencyCode()
- {
- String value = (String) getStateHelper().eval(PropertyKeys.currencyCode);
- if (value != null)
- {
- return value;
- }
- return getDecimalFormatSymbols().getInternationalCurrencySymbol();
- }
-
- protected String getLocalCurrencyCode()
- {
- return (String) getStateHelper().eval(PropertyKeys.currencyCode);
- }
-
- public void setCurrencyCode(String currencyCode)
- {
- getStateHelper().put(PropertyKeys.currencyCode, currencyCode);
- }
-
- /**
- * The currency symbol used to format a currency value.
- *
- * Defaults to the currency symbol for locale.
- *
- */
- @JSFProperty
- public String getCurrencySymbol()
- {
- String value = (String) getStateHelper().eval(PropertyKeys.currencySymbol);
- if (value != null)
- {
- return value;
- }
- return getDecimalFormatSymbols().getCurrencySymbol();
- }
-
- protected String getLocalCurrencySymbol()
- {
- return (String) getStateHelper().eval(PropertyKeys.currencySymbol);
- }
-
- public void setCurrencySymbol(String currencySymbol)
- {
- getStateHelper().put(PropertyKeys.currencySymbol, currencySymbol);
- }
-
- /**
- * Specifies whether output will contain grouping separators.
- *
- * Default: true.
- *
- */
- @JSFProperty(defaultValue="true")
- public abstract boolean isGroupingUsed();
-
- /**
- * Specifies whether only the integer part of the input will be parsed.
- *
- * Default: false.
- *
- */
- @JSFProperty(defaultValue="false")
- public abstract boolean isIntegerOnly();
-
- /**
- * The name of the locale to be used, instead of the default as specified
- * in the faces configuration file.
- *
- */
- @JSFProperty(deferredValueType="java.lang.Object")
- public Locale getLocale()
- {
- Object value = getStateHelper().eval(PropertyKeys.locale);
- if (value instanceof String)
- {
- value = org.apache.myfaces.commons.util.TagUtils.getLocale(value);
- }
- if (value != null)
- {
- return (Locale) value;
- }
- FacesContext context = FacesContext.getCurrentInstance();
- return context.getViewRoot().getLocale();
- }
-
- public void setLocale(Locale locale)
- {
- getStateHelper().put(PropertyKeys.locale, locale);
- }
-
- /**
- * The maximum number of digits in the fractional portion of the number.
- *
- */
- @JSFProperty
- public abstract Integer getMaxFractionDigits();
-
- /**
- * The maximum number of digits in the integer portion of the number.
- *
- */
- @JSFProperty
- public abstract Integer getMaxIntegerDigits();
-
- /**
- * The minimum number of digits in the fractional portion of the number.
- *
- */
- @JSFProperty
- public abstract Integer getMinFractionDigits();
-
- /**
- * The minimum number of digits in the integer portion of the number.
- *
- */
- @JSFProperty
- public abstract Integer getMinIntegerDigits();
-
- /**
- * A custom Date formatting pattern, in the format used by java.text.SimpleDateFormat.
- *
- */
- @JSFProperty
- public abstract String getPattern();
-
- public boolean isTransient()
- {
- return _transient;
- }
-
- public void setTransient(boolean aTransient)
- {
- _transient = aTransient;
- }
-
- /**
- * The type of formatting/parsing to be performed.
- *
- * Values include: number, currency, and percentage. Default: number.
- *
- */
- @JSFProperty(defaultValue="number")
- public abstract String getType();
-
- private static boolean checkJavaVersion14()
- {
- String version = System.getProperty("java.version");
- if (version == null)
- {
- return false;
- }
- byte java14 = 0;
- for (int idx = version.indexOf('.'), i = 0; idx > 0 || version != null; i++)
- {
- if (idx > 0)
- {
- byte value = Byte.parseByte(version.substring(0, 1));
- version = version.substring(idx + 1, version.length());
- idx = version.indexOf('.');
- switch (i)
- {
- case 0:
- if (value == 1)
- {
- java14 = 1;
- break;
- }
- else if (value > 1)
- {
- java14 = 2;
- }
- case 1:
- if (java14 > 0 && value >= 4)
- {
- java14 = 2;
- }
- ;
- default:
- idx = 0;
- version = null;
- break;
- }
- }
- else
- {
- byte value = Byte.parseByte(version.substring(0, 1));
- if (java14 > 0 && value >= 4)
- {
- java14 = 2;
- }
- break;
- }
- }
- return java14 == 2;
- }
-
-
- private DecimalFormatSymbols getDecimalFormatSymbols()
- {
- return new DecimalFormatSymbols(getLocale());
- }
-
- enum PropertyKeys
- {
- destType,
- currencyCode,
- currencySymbol,
- locale
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.commons.converter;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Currency;
+import java.util.Locale;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
+
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFConverter;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.commons.util.MessageUtils;
+
+/**
+ * Converter which uses either the manually set <code>destType</code> or the value binding to determine the
+ * correct destination type to convert the number to
+ *
+ * This tag creates a number formatting converter and associates it with the nearest
+ * parent UIComponent. It uses either the manually set destType or the value
+ * binding to determine the correct destination type to convert the number to.
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ *
+ * @author imario@apache.org
+ */
+@JSFConverter(
+ name = "mcc:convertNumber",
+ clazz = "org.apache.myfaces.commons.converter.TypedNumberConverter",
+ tagClass = "org.apache.myfaces.commons.converter.TypedNumberConverterTag",
+ tagHandler = "org.apache.myfaces.commons.converter.TypedNumberConverterTagHandler",
+ serialuidtag = "-6592309048440572608L")
+public abstract class AbstractTypedNumberConverter extends ConverterBase
+{
+ public static final String CONVERTER_ID = "org.apache.myfaces.custom.convertNumber.TypedNumberConverter";
+
+ public AbstractTypedNumberConverter()
+ {
+ }
+
+ public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+ {
+ Object convertedValue = _getAsObject(facesContext, uiComponent, value);
+ if (convertedValue == null)
+ {
+ return null;
+ }
+
+ Class destType = getDestType();
+ if (destType == null)
+ {
+ ValueExpression valueBinding = uiComponent.getValueExpression("value");
+ if (valueBinding != null)
+ {
+ destType = valueBinding.getType(facesContext.getELContext());
+ }
+ }
+
+ if (destType != null)
+ {
+ Converter converter = ConvertUtils.lookup(destType);
+ if (converter == null)
+ {
+ throw new UnsupportedOperationException("cant deal with " + destType);
+ }
+
+ // setting type to null, in fact the documentation is wrong here and this type is never used
+ convertedValue = converter.convert(null, convertedValue);
+ }
+
+
+ return convertedValue;
+ }
+
+ /**
+ * The java class name the value should be converted to.
+ *
+ * Default: automatically determined through valueBinding
+ *
+ */
+ @JSFProperty
+ public Class getDestType()
+ {
+ return (Class) getStateHelper().get(PropertyKeys.destType);
+ }
+
+ public void setDestType(Class destType)
+ {
+ getStateHelper().put(PropertyKeys.destType, destType);
+ }
+
+ /* ORIGINAL STUFF COPIED FROM javax.faces.convert.NumberConverter */
+
+ // internal constants
+ // private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.NumberConverter.CONVERSION";
+ public static final String STRING_ID = "javax.faces.converter.STRING";
+ public static final String CURRENCY_ID = "javax.faces.converter.NumberConverter.CURRENCY";
+ public static final String NUMBER_ID = "javax.faces.converter.NumberConverter.NUMBER";
+ public static final String PATTERN_ID = "javax.faces.converter.NumberConverter.PATTERN";
+ public static final String PERCENT_ID = "javax.faces.converter.NumberConverter.PERCENT";
+
+ private static final boolean JAVA_VERSION_14;
+
+ static
+ {
+ JAVA_VERSION_14 = checkJavaVersion14();
+ }
+
+ private boolean _transient;
+
+
+
+ // METHODS
+ public Object _getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+ {
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value != null)
+ {
+ value = value.trim();
+ if (value.length() > 0)
+ {
+ NumberFormat format = getNumberFormat(facesContext);
+ format.setParseIntegerOnly(isIntegerOnly());
+
+ DecimalFormat df = (DecimalFormat)format;
+
+ // The best we can do in this case is check if there is a ValueExpression
+ // with a BigDecimal as returning type , and if that so enable BigDecimal parsing
+ // to prevent loss in precision, and do not break existing examples (since
+ // in those cases it is expected to return Double). See MYFACES-1890 and TRINIDAD-1124
+ // for details
+ Class destType = getDestType();
+ if (destType == null)
+ {
+ ValueExpression valueBinding = uiComponent.getValueExpression("value");
+ if (valueBinding != null)
+ {
+ destType = valueBinding.getType(facesContext.getELContext());
+ }
+ }
+ if (destType != null && BigDecimal.class.isAssignableFrom(destType))
+ {
+ df.setParseBigDecimal(true);
+ }
+
+ DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
+ boolean changed = false;
+ if(dfs.getGroupingSeparator() == '\u00a0')
+ {
+ dfs.setGroupingSeparator(' ');
+ df.setDecimalFormatSymbols(dfs);
+ changed = true;
+ }
+
+ formatCurrency(format);
+
+ try
+ {
+ return format.parse(value);
+ }
+ catch (ParseException e)
+ {
+ if(changed)
+ {
+ dfs.setGroupingSeparator('\u00a0');
+ df.setDecimalFormatSymbols(dfs);
+ }
+ try
+ {
+ return format.parse(value);
+ }
+ catch (ParseException pe)
+ {
+
+ if(getPattern() != null)
+ throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
+ PATTERN_ID,
+ new Object[]{value,"$###,###",MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
+ else if(getType().equals("number"))
+ throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
+ NUMBER_ID,
+ new Object[]{value,format.format(21),MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
+ else if(getType().equals("currency"))
+ throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
+ CURRENCY_ID,
+ new Object[]{value,format.format(42.25),MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
+ else if(getType().equals("percent"))
+ throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR,
+ PERCENT_ID,
+ new Object[]{value,format.format(.90),MessageUtils.getLabel(facesContext, uiComponent)},facesContext));
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+ {
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return "";
+ }
+ if (value instanceof String)
+ {
+ return (String)value;
+ }
+
+ NumberFormat format = getNumberFormat(facesContext);
+ format.setGroupingUsed(isGroupingUsed());
+ Integer maxFractionDigits = getMaxFractionDigits();
+ Integer maxIntegerDigits = getMaxIntegerDigits();
+ Integer minFractionDigits = getMinFractionDigits();
+ Integer minIntegerDigits = getMinIntegerDigits();
+ if (maxFractionDigits != null) format.setMaximumFractionDigits(maxFractionDigits);
+ if (maxIntegerDigits != null) format.setMaximumIntegerDigits(maxIntegerDigits);
+ if (minFractionDigits != null) format.setMinimumFractionDigits(minFractionDigits);
+ if (minIntegerDigits != null) format.setMinimumIntegerDigits(minIntegerDigits);
+ formatCurrency(format);
+ try
+ {
+ return format.format(value);
+ }
+ catch (Exception e)
+ {
+ throw new ConverterException(MessageUtils.getMessage(FacesMessage.FACES_MESSAGES, FacesMessage.SEVERITY_ERROR, STRING_ID, new Object[]{value,MessageUtils.getLabel(facesContext, uiComponent)}, facesContext),e);
+ }
+ }
+
+ private NumberFormat getNumberFormat(FacesContext facesContext)
+ {
+ Locale lokale = getLocale();
+
+ if (getPattern() == null && getType() == null)
+ {
+ throw new ConverterException("Cannot get NumberFormat, either type or pattern needed.");
+ }
+
+ // pattern
+ if (getPattern() != null)
+ {
+ return new DecimalFormat(getPattern(), new DecimalFormatSymbols(lokale));
+ }
+
+ // type
+ if (getType().equals("number"))
+ {
+ return NumberFormat.getNumberInstance(lokale);
+ }
+ else if (getType().equals("currency"))
+ {
+ return NumberFormat.getCurrencyInstance(lokale);
+ }
+ else if (getType().equals("percent"))
+ {
+ return NumberFormat.getPercentInstance(lokale);
+ }
+ throw new ConverterException("Cannot get NumberFormat, illegal type " + getType());
+ }
+
+ private void formatCurrency(NumberFormat format)
+ {
+ if (getLocalCurrencyCode() == null && getLocalCurrencySymbol() == null)
+ {
+ return;
+ }
+
+ boolean useCurrencyCode;
+ if (JAVA_VERSION_14)
+ {
+ useCurrencyCode = getLocalCurrencyCode() != null;
+ }
+ else
+ {
+ useCurrencyCode = getLocalCurrencySymbol() == null;
+ }
+
+ if (useCurrencyCode)
+ {
+ // set Currency
+ try
+ {
+ format.setCurrency(Currency.getInstance(getLocalCurrencyCode()));
+ }
+ catch (Exception e)
+ {
+ throw new ConverterException("Unable to get Currency instance for currencyCode " +
+ getLocalCurrencyCode());
+ }
+ }
+ else if (format instanceof DecimalFormat)
+
+ {
+ DecimalFormat dFormat = (DecimalFormat)format;
+ DecimalFormatSymbols symbols = dFormat.getDecimalFormatSymbols();
+ symbols.setCurrencySymbol(getLocalCurrencySymbol());
+ dFormat.setDecimalFormatSymbols(symbols);
+ }
+ }
+
+ // STATE SAVE/RESTORE
+
+ // GETTER & SETTER
+
+ /**
+ * ISO 4217 currency code
+ *
+ */
+ @JSFProperty
+ public String getCurrencyCode()
+ {
+ String value = (String) getStateHelper().eval(PropertyKeys.currencyCode);
+ if (value != null)
+ {
+ return value;
+ }
+ return getDecimalFormatSymbols().getInternationalCurrencySymbol();
+ }
+
+ protected String getLocalCurrencyCode()
+ {
+ return (String) getStateHelper().eval(PropertyKeys.currencyCode);
+ }
+
+ public void setCurrencyCode(String currencyCode)
+ {
+ getStateHelper().put(PropertyKeys.currencyCode, currencyCode);
+ }
+
+ /**
+ * The currency symbol used to format a currency value.
+ *
+ * Defaults to the currency symbol for locale.
+ *
+ */
+ @JSFProperty
+ public String getCurrencySymbol()
+ {
+ String value = (String) getStateHelper().eval(PropertyKeys.currencySymbol);
+ if (value != null)
+ {
+ return value;
+ }
+ return getDecimalFormatSymbols().getCurrencySymbol();
+ }
+
+ protected String getLocalCurrencySymbol()
+ {
+ return (String) getStateHelper().eval(PropertyKeys.currencySymbol);
+ }
+
+ public void setCurrencySymbol(String currencySymbol)
+ {
+ getStateHelper().put(PropertyKeys.currencySymbol, currencySymbol);
+ }
+
+ /**
+ * Specifies whether output will contain grouping separators.
+ *
+ * Default: true.
+ *
+ */
+ @JSFProperty(defaultValue="true")
+ public abstract boolean isGroupingUsed();
+
+ /**
+ * Specifies whether only the integer part of the input will be parsed.
+ *
+ * Default: false.
+ *
+ */
+ @JSFProperty(defaultValue="false")
+ public abstract boolean isIntegerOnly();
+
+ /**
+ * The name of the locale to be used, instead of the default as specified
+ * in the faces configuration file.
+ *
+ */
+ @JSFProperty(deferredValueType="java.lang.Object")
+ public Locale getLocale()
+ {
+ Object value = getStateHelper().eval(PropertyKeys.locale);
+ if (value instanceof String)
+ {
+ value = org.apache.myfaces.commons.util.TagUtils.getLocale(value);
+ }
+ if (value != null)
+ {
+ return (Locale) value;
+ }
+ FacesContext context = FacesContext.getCurrentInstance();
+ return context.getViewRoot().getLocale();
+ }
+
+ public void setLocale(Locale locale)
+ {
+ getStateHelper().put(PropertyKeys.locale, locale);
+ }
+
+ /**
+ * The maximum number of digits in the fractional portion of the number.
+ *
+ */
+ @JSFProperty
+ public abstract Integer getMaxFractionDigits();
+
+ /**
+ * The maximum number of digits in the integer portion of the number.
+ *
+ */
+ @JSFProperty
+ public abstract Integer getMaxIntegerDigits();
+
+ /**
+ * The minimum number of digits in the fractional portion of the number.
+ *
+ */
+ @JSFProperty
+ public abstract Integer getMinFractionDigits();
+
+ /**
+ * The minimum number of digits in the integer portion of the number.
+ *
+ */
+ @JSFProperty
+ public abstract Integer getMinIntegerDigits();
+
+ /**
+ * A custom Date formatting pattern, in the format used by java.text.SimpleDateFormat.
+ *
+ */
+ @JSFProperty
+ public abstract String getPattern();
+
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+
+ public void setTransient(boolean aTransient)
+ {
+ _transient = aTransient;
+ }
+
+ /**
+ * The type of formatting/parsing to be performed.
+ *
+ * Values include: number, currency, and percentage. Default: number.
+ *
+ */
+ @JSFProperty(defaultValue="number")
+ public abstract String getType();
+
+ private static boolean checkJavaVersion14()
+ {
+ String version = System.getProperty("java.version");
+ if (version == null)
+ {
+ return false;
+ }
+ byte java14 = 0;
+ for (int idx = version.indexOf('.'), i = 0; idx > 0 || version != null; i++)
+ {
+ if (idx > 0)
+ {
+ byte value = Byte.parseByte(version.substring(0, 1));
+ version = version.substring(idx + 1, version.length());
+ idx = version.indexOf('.');
+ switch (i)
+ {
+ case 0:
+ if (value == 1)
+ {
+ java14 = 1;
+ break;
+ }
+ else if (value > 1)
+ {
+ java14 = 2;
+ }
+ case 1:
+ if (java14 > 0 && value >= 4)
+ {
+ java14 = 2;
+ }
+ ;
+ default:
+ idx = 0;
+ version = null;
+ break;
+ }
+ }
+ else
+ {
+ byte value = Byte.parseByte(version.substring(0, 1));
+ if (java14 > 0 && value >= 4)
+ {
+ java14 = 2;
+ }
+ break;
+ }
+ }
+ return java14 == 2;
+ }
+
+
+ private DecimalFormatSymbols getDecimalFormatSymbols()
+ {
+ return new DecimalFormatSymbols(getLocale());
+ }
+
+ enum PropertyKeys
+ {
+ destType,
+ currencyCode,
+ currencySymbol,
+ locale
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/AbstractTypedNumberConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertDateTimeTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertDateTimeTagHandler.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertDateTimeTagHandler.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertDateTimeTagHandler.java Thu Oct 20 10:49:18 2011
@@ -1,61 +1,61 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.commons.converter;
-
-import javax.faces.view.facelets.ConverterConfig;
-import javax.faces.view.facelets.ConverterHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRuleset;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFConverter;
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-
-@JSFFaceletTag(
- name = "mcc:convertDateTime",
- bodyContent = "empty",
- converterClass="org.apache.myfaces.commons.converter.DateTimeConverter")
-public class ConvertDateTimeTagHandler extends ConverterHandler
-{
-
- public ConvertDateTimeTagHandler(ConverterConfig config)
- {
- super(config);
- }
-
- public void setAttributes(FaceletContext ctx, Object obj)
- {
- super.setAttributes(ctx, obj);
- }
-
- @Override
- protected MetaRuleset createMetaRuleset(Class type)
- {
- MetaRuleset ruleSet = super.createMetaRuleset(type);
-
- ruleSet.addRule(_DateTimeConverterRule.Instance);
-
- //Add locale rule
- ruleSet.addRule(_LocaleRule.Instance);
-
- //Add timeZone rule
- ruleSet.addRule(_TimeZoneRule.Instance);
-
- return ruleSet;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.commons.converter;
+
+import javax.faces.view.facelets.ConverterConfig;
+import javax.faces.view.facelets.ConverterHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFConverter;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+
+@JSFFaceletTag(
+ name = "mcc:convertDateTime",
+ bodyContent = "empty",
+ converterClass="org.apache.myfaces.commons.converter.DateTimeConverter")
+public class ConvertDateTimeTagHandler extends ConverterHandler
+{
+
+ public ConvertDateTimeTagHandler(ConverterConfig config)
+ {
+ super(config);
+ }
+
+ public void setAttributes(FaceletContext ctx, Object obj)
+ {
+ super.setAttributes(ctx, obj);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset ruleSet = super.createMetaRuleset(type);
+
+ ruleSet.addRule(_DateTimeConverterRule.Instance);
+
+ //Add locale rule
+ ruleSet.addRule(_LocaleRule.Instance);
+
+ //Add timeZone rule
+ ruleSet.addRule(_TimeZoneRule.Instance);
+
+ return ruleSet;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertDateTimeTagHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertEnumTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertEnumTagHandler.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertEnumTagHandler.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertEnumTagHandler.java Thu Oct 20 10:49:18 2011
@@ -1,73 +1,73 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.commons.converter;
-
-import javax.faces.view.facelets.ConverterConfig;
-import javax.faces.view.facelets.ConverterHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.TagAttribute;
-import javax.faces.view.facelets.TagAttributeException;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-
-@JSFFaceletTag(
- name = "mcc:convertEnum",
- bodyContent = "empty",
- converterClass="org.apache.myfaces.commons.converter.EnumConverter")
-public class ConvertEnumTagHandler extends ConverterHandler
-{
- private final TagAttribute targetClass;
-
- public ConvertEnumTagHandler(ConverterConfig config)
- {
- super(config);
- this.targetClass = this.getAttribute("targetClass");
- }
-
- public void setAttributes(FaceletContext ctx, Object obj)
- {
- super.setAttributes(ctx, obj);
- EnumConverter c = (EnumConverter) obj;
- if (this.targetClass != null)
- {
- if (this.targetClass.isLiteral())
- {
- try
- {
- c.setTargetClass(org.apache.myfaces.commons.util.ClassUtils.classForName(this.targetClass.getValue()));
- }
- catch (ClassNotFoundException e)
- {
- throw new TagAttributeException(this.targetClass,"Cannot find class assigned: "+this.targetClass.getValue(),e);
- }
- }
- else
- {
- c.setTargetClass((Class) this.targetClass.getObject(ctx, Class.class));
- }
- }
- }
-
- @Override
- protected MetaRuleset createMetaRuleset(Class type)
- {
- return super.createMetaRuleset(type).ignore("targetClass");
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.commons.converter;
+
+import javax.faces.view.facelets.ConverterConfig;
+import javax.faces.view.facelets.ConverterHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+
+@JSFFaceletTag(
+ name = "mcc:convertEnum",
+ bodyContent = "empty",
+ converterClass="org.apache.myfaces.commons.converter.EnumConverter")
+public class ConvertEnumTagHandler extends ConverterHandler
+{
+ private final TagAttribute targetClass;
+
+ public ConvertEnumTagHandler(ConverterConfig config)
+ {
+ super(config);
+ this.targetClass = this.getAttribute("targetClass");
+ }
+
+ public void setAttributes(FaceletContext ctx, Object obj)
+ {
+ super.setAttributes(ctx, obj);
+ EnumConverter c = (EnumConverter) obj;
+ if (this.targetClass != null)
+ {
+ if (this.targetClass.isLiteral())
+ {
+ try
+ {
+ c.setTargetClass(org.apache.myfaces.commons.util.ClassUtils.classForName(this.targetClass.getValue()));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new TagAttributeException(this.targetClass,"Cannot find class assigned: "+this.targetClass.getValue(),e);
+ }
+ }
+ else
+ {
+ c.setTargetClass((Class) this.targetClass.getObject(ctx, Class.class));
+ }
+ }
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ return super.createMetaRuleset(type).ignore("targetClass");
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConvertEnumTagHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBase.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBase.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBase.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBase.java Thu Oct 20 10:49:18 2011
@@ -1,375 +1,375 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.commons.converter;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.el.ValueExpression;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.PartialStateHolder;
-import javax.faces.component.StateHelper;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFConverter;
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
-import org.apache.myfaces.commons.util.MessageUtils;
-
-/**
- * Base converter implementation for Apache MyFaces Commons Converters.
- *
- */
-@JSFConverter(
- configExcluded = true,
- evaluateELOnExecution = true,
- tagClass = "org.apache.myfaces.commons.converter.ConverterBaseTag",
- tagHandler = "org.apache.myfaces.commons.converter.ConverterBaseTagHandler")
-public abstract class ConverterBase implements PartialStateHolder, Converter {
-
- private boolean _transient = false;
-
- private transient FacesContext _facesContext;
- private StateHelper _stateHelper = null;
- private boolean _initialStateMarked = false;
-
- /**
- * alternate conversion error summary message format string
- *
- * @return The summary message to be displayed
- */
- @JSFProperty
- public String getSummaryMessage()
- {
- return (String) getStateHelper().eval(PropertyKeys.summaryMessage);
- }
-
- /**
- *
- * @param message The summary message to be displayed.
- */
- public void setSummaryMessage(String message) {
- getStateHelper().put(PropertyKeys.summaryMessage, message);
- }
-
- /**
- * alternate conversion error detail message format string
- * (use 'message' and 'detailMessage' alternatively)
- *
- * @return The detail message.
- */
- @JSFProperty
- public String getDetailMessage() {
- return (String) getStateHelper().eval(PropertyKeys.detailMessage);
- }
-
- /**
- *
- * @param message The detail message to be displayed.
- */
- public void setDetailMessage(String message) {
- getStateHelper().put(PropertyKeys.detailMessage, message);
- }
-
-
- /**
- * @param context
- */
- public Object saveState(FacesContext context)
- {
- if (context == null)
- {
- throw new NullPointerException ("context");
- }
-
- StateHelper stateHelper = getStateHelper(false);
- if (stateHelper != null)
- {
- return stateHelper.saveState(context);
- }
- else
- {
- return null;
- }
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- getStateHelper().restoreState(context, state);
- }
-
- public boolean isTransient() {
- return _transient;
- }
-
- public void setTransient(boolean newTransientValue) {
- _transient = newTransientValue;
- }
-
- // Utility methods
-
- /**
- * @param defaultMessage The default message we would expect.
- * @param args Arguments for parsing this message.
- * @return FacesMessage
- */
- protected FacesMessage getFacesMessage(String defaultMessage, Object[] args) {
- FacesMessage msg;
-
- if (getSummaryMessage() == null && getDetailMessage() == null)
- {
- msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, defaultMessage, args);
- } else {
- Locale locale = MessageUtils.getCurrentLocale();
- String summaryText = MessageUtils.substituteParams(locale, getSummaryMessage(), args);
- String detailText = MessageUtils.substituteParams(locale, getDetailMessage(), args);
- msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, summaryText, detailText);
- }
- return msg;
- }
-
- // --------------------- borrowed from UIComponentBase ------------
-
- @SuppressWarnings("unchecked")
- public ValueExpression getValueExpression(String name)
- {
- if (name == null) throw new NullPointerException("name");
- StateHelper helper = getStateHelper(false);
- if (helper == null)
- {
- return null;
- }
- Map<String,Object> bindings = (Map<String,Object>) helper.get(PropertyKeys.bindings);
- if (bindings == null)
- {
- return null;
- }
- else
- {
- return (ValueExpression) bindings.get(name);
- }
- }
-
- public void setValueExpression(String name, ValueExpression expression)
- {
- if (name == null) throw new NullPointerException("name");
- if (expression == null) {
- getStateHelper().remove(PropertyKeys.bindings, name);
- } else {
- getStateHelper().put(PropertyKeys.bindings, name, expression);
- }
- }
-
- /**
- * Serializes objects which are "attached" to this component but which are
- * not UIComponent children of it. Examples are converter and listener
- * objects. To be precise, it returns an object which implements
- * java.io.Serializable, and which when serialized will persist the
- * state of the provided object.
- * <p>
- * If the attachedObject is a List then every object in the list is saved
- * via a call to this method, and the returned wrapper object contains
- * a List object.
- * <p>
- * If the object implements StateHolder then the object's saveState is
- * called immediately, and a wrapper is returned which contains both
- * this saved state and the original class name. However in the case
- * where the StateHolder.isTransient method returns true, null is
- * returned instead.
- * <p>
- * If the object implements java.io.Serializable then the object is simply
- * returned immediately; standard java serialization will later be used
- * to store this object.
- * <p>
- * In all other cases, a wrapper is returned which simply stores the type
- * of the provided object. When deserialized, a default instance of that
- * type will be recreated.
- */
- public static Object saveAttachedState(FacesContext context, Object attachedObject)
- {
- if (context == null)
- {
- throw new NullPointerException ("context");
- }
-
- if (attachedObject == null)
- return null;
- // StateHolder interface should take precedence over
- // List children
- if (attachedObject instanceof StateHolder)
- {
- StateHolder holder = (StateHolder) attachedObject;
- if (holder.isTransient())
- {
- return null;
- }
-
- return new _AttachedStateWrapper(attachedObject.getClass(), holder.saveState(context));
- }
- else if (attachedObject instanceof List)
- {
- List<Object> lst = new ArrayList<Object>(((List<?>) attachedObject).size());
- for (Object item : (List<?>) attachedObject)
- {
- if (item != null)
- {
- lst.add(saveAttachedState(context, item));
- }
- }
-
- return new _AttachedListStateWrapper(lst);
- }
- else if (attachedObject instanceof Serializable)
- {
- return attachedObject;
- }
- else
- {
- return new _AttachedStateWrapper(attachedObject.getClass(), null);
- }
- }
-
- @SuppressWarnings("unchecked")
- public static Object restoreAttachedState(FacesContext context, Object stateObj) throws IllegalStateException
- {
- if (context == null)
- throw new NullPointerException("context");
- if (stateObj == null)
- return null;
- if (stateObj instanceof _AttachedListStateWrapper)
- {
- List<Object> lst = ((_AttachedListStateWrapper) stateObj).getWrappedStateList();
- List<Object> restoredList = new ArrayList<Object>(lst.size());
- for (Object item : lst)
- {
- restoredList.add(restoreAttachedState(context, item));
- }
- return restoredList;
- }
- else if (stateObj instanceof _AttachedStateWrapper)
- {
- Class<?> clazz = ((_AttachedStateWrapper) stateObj).getClazz();
- Object restoredObject;
- try
- {
- restoredObject = clazz.newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName()
- + " (missing no-args constructor?)", e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException(e);
- }
- if (restoredObject instanceof StateHolder)
- {
- _AttachedStateWrapper wrapper = (_AttachedStateWrapper) stateObj;
- Object wrappedState = wrapper.getWrappedStateObject();
-
- StateHolder holder = (StateHolder) restoredObject;
- holder.restoreState(context, wrappedState);
- }
- return restoredObject;
- }
- else
- {
- return stateObj;
- }
- }
-
- protected FacesContext getFacesContext()
- {
- if (_facesContext == null)
- {
- return FacesContext.getCurrentInstance();
- }
- else
- {
- return _facesContext;
- }
- }
-
- boolean isCachedFacesContext()
- {
- return _facesContext != null;
- }
-
- void setCachedFacesContext(FacesContext facesContext)
- {
- _facesContext = facesContext;
- }
-
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
- }
-
- /**
- * returns a delta state saving enabled state helper
- * for the current component
- * @param create if true a state helper is created if not already existing
- * @return an implementation of the StateHelper interface or null if none exists and create is set to false
- */
- protected StateHelper getStateHelper(boolean create) {
- if(_stateHelper != null) {
- return _stateHelper;
- }
- if(create) {
- _stateHelper = new _DeltaStateHelper(this);
- }
- return _stateHelper;
- }
-
- public void clearInitialState()
- {
- _initialStateMarked = false;
- }
-
- public boolean initialStateMarked()
- {
- return _initialStateMarked;
- }
-
- public void markInitialState()
- {
- _initialStateMarked = true;
- }
-
- protected String getStringValue(FacesContext context, ValueExpression vb)
- {
- Object value = vb.getValue(context.getELContext());
- if (value != null)
- {
- return value.toString();
- }
- return null;
- }
-
- enum PropertyKeys
- {
- bindings,
- summaryMessage,
- detailMessage
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.commons.converter;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFConverter;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.commons.util.MessageUtils;
+
+/**
+ * Base converter implementation for Apache MyFaces Commons Converters.
+ *
+ */
+@JSFConverter(
+ configExcluded = true,
+ evaluateELOnExecution = true,
+ tagClass = "org.apache.myfaces.commons.converter.ConverterBaseTag",
+ tagHandler = "org.apache.myfaces.commons.converter.ConverterBaseTagHandler")
+public abstract class ConverterBase implements PartialStateHolder, Converter {
+
+ private boolean _transient = false;
+
+ private transient FacesContext _facesContext;
+ private StateHelper _stateHelper = null;
+ private boolean _initialStateMarked = false;
+
+ /**
+ * alternate conversion error summary message format string
+ *
+ * @return The summary message to be displayed
+ */
+ @JSFProperty
+ public String getSummaryMessage()
+ {
+ return (String) getStateHelper().eval(PropertyKeys.summaryMessage);
+ }
+
+ /**
+ *
+ * @param message The summary message to be displayed.
+ */
+ public void setSummaryMessage(String message) {
+ getStateHelper().put(PropertyKeys.summaryMessage, message);
+ }
+
+ /**
+ * alternate conversion error detail message format string
+ * (use 'message' and 'detailMessage' alternatively)
+ *
+ * @return The detail message.
+ */
+ @JSFProperty
+ public String getDetailMessage() {
+ return (String) getStateHelper().eval(PropertyKeys.detailMessage);
+ }
+
+ /**
+ *
+ * @param message The detail message to be displayed.
+ */
+ public void setDetailMessage(String message) {
+ getStateHelper().put(PropertyKeys.detailMessage, message);
+ }
+
+
+ /**
+ * @param context
+ */
+ public Object saveState(FacesContext context)
+ {
+ if (context == null)
+ {
+ throw new NullPointerException ("context");
+ }
+
+ StateHelper stateHelper = getStateHelper(false);
+ if (stateHelper != null)
+ {
+ return stateHelper.saveState(context);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ getStateHelper().restoreState(context, state);
+ }
+
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ _transient = newTransientValue;
+ }
+
+ // Utility methods
+
+ /**
+ * @param defaultMessage The default message we would expect.
+ * @param args Arguments for parsing this message.
+ * @return FacesMessage
+ */
+ protected FacesMessage getFacesMessage(String defaultMessage, Object[] args) {
+ FacesMessage msg;
+
+ if (getSummaryMessage() == null && getDetailMessage() == null)
+ {
+ msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, defaultMessage, args);
+ } else {
+ Locale locale = MessageUtils.getCurrentLocale();
+ String summaryText = MessageUtils.substituteParams(locale, getSummaryMessage(), args);
+ String detailText = MessageUtils.substituteParams(locale, getDetailMessage(), args);
+ msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, summaryText, detailText);
+ }
+ return msg;
+ }
+
+ // --------------------- borrowed from UIComponentBase ------------
+
+ @SuppressWarnings("unchecked")
+ public ValueExpression getValueExpression(String name)
+ {
+ if (name == null) throw new NullPointerException("name");
+ StateHelper helper = getStateHelper(false);
+ if (helper == null)
+ {
+ return null;
+ }
+ Map<String,Object> bindings = (Map<String,Object>) helper.get(PropertyKeys.bindings);
+ if (bindings == null)
+ {
+ return null;
+ }
+ else
+ {
+ return (ValueExpression) bindings.get(name);
+ }
+ }
+
+ public void setValueExpression(String name, ValueExpression expression)
+ {
+ if (name == null) throw new NullPointerException("name");
+ if (expression == null) {
+ getStateHelper().remove(PropertyKeys.bindings, name);
+ } else {
+ getStateHelper().put(PropertyKeys.bindings, name, expression);
+ }
+ }
+
+ /**
+ * Serializes objects which are "attached" to this component but which are
+ * not UIComponent children of it. Examples are converter and listener
+ * objects. To be precise, it returns an object which implements
+ * java.io.Serializable, and which when serialized will persist the
+ * state of the provided object.
+ * <p>
+ * If the attachedObject is a List then every object in the list is saved
+ * via a call to this method, and the returned wrapper object contains
+ * a List object.
+ * <p>
+ * If the object implements StateHolder then the object's saveState is
+ * called immediately, and a wrapper is returned which contains both
+ * this saved state and the original class name. However in the case
+ * where the StateHolder.isTransient method returns true, null is
+ * returned instead.
+ * <p>
+ * If the object implements java.io.Serializable then the object is simply
+ * returned immediately; standard java serialization will later be used
+ * to store this object.
+ * <p>
+ * In all other cases, a wrapper is returned which simply stores the type
+ * of the provided object. When deserialized, a default instance of that
+ * type will be recreated.
+ */
+ public static Object saveAttachedState(FacesContext context, Object attachedObject)
+ {
+ if (context == null)
+ {
+ throw new NullPointerException ("context");
+ }
+
+ if (attachedObject == null)
+ return null;
+ // StateHolder interface should take precedence over
+ // List children
+ if (attachedObject instanceof StateHolder)
+ {
+ StateHolder holder = (StateHolder) attachedObject;
+ if (holder.isTransient())
+ {
+ return null;
+ }
+
+ return new _AttachedStateWrapper(attachedObject.getClass(), holder.saveState(context));
+ }
+ else if (attachedObject instanceof List)
+ {
+ List<Object> lst = new ArrayList<Object>(((List<?>) attachedObject).size());
+ for (Object item : (List<?>) attachedObject)
+ {
+ if (item != null)
+ {
+ lst.add(saveAttachedState(context, item));
+ }
+ }
+
+ return new _AttachedListStateWrapper(lst);
+ }
+ else if (attachedObject instanceof Serializable)
+ {
+ return attachedObject;
+ }
+ else
+ {
+ return new _AttachedStateWrapper(attachedObject.getClass(), null);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Object restoreAttachedState(FacesContext context, Object stateObj) throws IllegalStateException
+ {
+ if (context == null)
+ throw new NullPointerException("context");
+ if (stateObj == null)
+ return null;
+ if (stateObj instanceof _AttachedListStateWrapper)
+ {
+ List<Object> lst = ((_AttachedListStateWrapper) stateObj).getWrappedStateList();
+ List<Object> restoredList = new ArrayList<Object>(lst.size());
+ for (Object item : lst)
+ {
+ restoredList.add(restoreAttachedState(context, item));
+ }
+ return restoredList;
+ }
+ else if (stateObj instanceof _AttachedStateWrapper)
+ {
+ Class<?> clazz = ((_AttachedStateWrapper) stateObj).getClazz();
+ Object restoredObject;
+ try
+ {
+ restoredObject = clazz.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName()
+ + " (missing no-args constructor?)", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ if (restoredObject instanceof StateHolder)
+ {
+ _AttachedStateWrapper wrapper = (_AttachedStateWrapper) stateObj;
+ Object wrappedState = wrapper.getWrappedStateObject();
+
+ StateHolder holder = (StateHolder) restoredObject;
+ holder.restoreState(context, wrappedState);
+ }
+ return restoredObject;
+ }
+ else
+ {
+ return stateObj;
+ }
+ }
+
+ protected FacesContext getFacesContext()
+ {
+ if (_facesContext == null)
+ {
+ return FacesContext.getCurrentInstance();
+ }
+ else
+ {
+ return _facesContext;
+ }
+ }
+
+ boolean isCachedFacesContext()
+ {
+ return _facesContext != null;
+ }
+
+ void setCachedFacesContext(FacesContext facesContext)
+ {
+ _facesContext = facesContext;
+ }
+
+ protected StateHelper getStateHelper() {
+ return getStateHelper(true);
+ }
+
+ /**
+ * returns a delta state saving enabled state helper
+ * for the current component
+ * @param create if true a state helper is created if not already existing
+ * @return an implementation of the StateHelper interface or null if none exists and create is set to false
+ */
+ protected StateHelper getStateHelper(boolean create) {
+ if(_stateHelper != null) {
+ return _stateHelper;
+ }
+ if(create) {
+ _stateHelper = new _DeltaStateHelper(this);
+ }
+ return _stateHelper;
+ }
+
+ public void clearInitialState()
+ {
+ _initialStateMarked = false;
+ }
+
+ public boolean initialStateMarked()
+ {
+ return _initialStateMarked;
+ }
+
+ public void markInitialState()
+ {
+ _initialStateMarked = true;
+ }
+
+ protected String getStringValue(FacesContext context, ValueExpression vb)
+ {
+ Object value = vb.getValue(context.getELContext());
+ if (value != null)
+ {
+ return value.toString();
+ }
+ return null;
+ }
+
+ enum PropertyKeys
+ {
+ bindings,
+ summaryMessage,
+ detailMessage
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTag.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTag.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTag.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTag.java Thu Oct 20 10:49:18 2011
@@ -1,88 +1,88 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.commons.converter;
-
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.servlet.jsp.JspException;
-
-/**
- * ConverterBaseTag provides support for ConverterBase subclasses.
- * ConverterBaseTag subclass tld entries should include the following to pick up attribute defintions.
- * &ext_converter_base_attributes;
- *
- * @author mkienenb (latest modification by $Author: lu4242 $)
- * @version $Revision: 706423 $
- */
-public abstract class ConverterBaseTag extends ConverterTag {
- private static final long serialVersionUID = 4416508071412794682L;
- private ValueExpression _detailMessage = null;
- private ValueExpression _summaryMessage = null;
-
- public void setDetailMessage(ValueExpression detailMessage)
- {
- _detailMessage = detailMessage;
- }
-
- public void setSummaryMessage(ValueExpression summaryMessage)
- {
- _summaryMessage = summaryMessage;
- }
-
- protected Converter createConverter() throws JspException
- {
- ConverterBase converter = (ConverterBase) super.createConverter();
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- if (_detailMessage != null)
- {
- if (!_detailMessage.isLiteralText())
- {
- converter.setValueExpression("detailMessage",_detailMessage);
- }
- else
- {
- converter.setDetailMessage((String)_detailMessage.getValue(facesContext.getELContext()));
- }
- }
-
- if (_summaryMessage != null)
- {
- if (!_summaryMessage.isLiteralText())
- {
- converter.setValueExpression("summaryMessage",_summaryMessage);
- }
- else
- {
- converter.setSummaryMessage((String)_summaryMessage.getValue(facesContext.getELContext()));
- }
- }
-
- return converter;
- }
-
- public void release()
- {
- super.release();
- _detailMessage = null;
- _summaryMessage = null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.commons.converter;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.servlet.jsp.JspException;
+
+/**
+ * ConverterBaseTag provides support for ConverterBase subclasses.
+ * ConverterBaseTag subclass tld entries should include the following to pick up attribute defintions.
+ * &ext_converter_base_attributes;
+ *
+ * @author mkienenb (latest modification by $Author: lu4242 $)
+ * @version $Revision: 706423 $
+ */
+public abstract class ConverterBaseTag extends ConverterTag {
+ private static final long serialVersionUID = 4416508071412794682L;
+ private ValueExpression _detailMessage = null;
+ private ValueExpression _summaryMessage = null;
+
+ public void setDetailMessage(ValueExpression detailMessage)
+ {
+ _detailMessage = detailMessage;
+ }
+
+ public void setSummaryMessage(ValueExpression summaryMessage)
+ {
+ _summaryMessage = summaryMessage;
+ }
+
+ protected Converter createConverter() throws JspException
+ {
+ ConverterBase converter = (ConverterBase) super.createConverter();
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ if (_detailMessage != null)
+ {
+ if (!_detailMessage.isLiteralText())
+ {
+ converter.setValueExpression("detailMessage",_detailMessage);
+ }
+ else
+ {
+ converter.setDetailMessage((String)_detailMessage.getValue(facesContext.getELContext()));
+ }
+ }
+
+ if (_summaryMessage != null)
+ {
+ if (!_summaryMessage.isLiteralText())
+ {
+ converter.setValueExpression("summaryMessage",_summaryMessage);
+ }
+ else
+ {
+ converter.setSummaryMessage((String)_summaryMessage.getValue(facesContext.getELContext()));
+ }
+ }
+
+ return converter;
+ }
+
+ public void release()
+ {
+ super.release();
+ _detailMessage = null;
+ _summaryMessage = null;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTagHandler.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTagHandler.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTagHandler.java Thu Oct 20 10:49:18 2011
@@ -1,46 +1,46 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.commons.converter;
-
-import javax.faces.view.facelets.ConverterConfig;
-import javax.faces.view.facelets.ConverterHandler;
-import javax.faces.view.facelets.MetaRuleset;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-
-@JSFFaceletTag
-public class ConverterBaseTagHandler extends ConverterHandler
-{
-
- public ConverterBaseTagHandler(ConverterConfig config)
- {
- super(config);
- }
-
- @Override
- protected MetaRuleset createMetaRuleset(Class type)
- {
- MetaRuleset ruleSet = super.createMetaRuleset(type);
-
- //Add rule to handle EL expressions
- ruleSet.addRule(_ConverterRule.Instance);
-
- return ruleSet;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.commons.converter;
+
+import javax.faces.view.facelets.ConverterConfig;
+import javax.faces.view.facelets.ConverterHandler;
+import javax.faces.view.facelets.MetaRuleset;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+
+@JSFFaceletTag
+public class ConverterBaseTagHandler extends ConverterHandler
+{
+
+ public ConverterBaseTagHandler(ConverterConfig config)
+ {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset ruleSet = super.createMetaRuleset(type);
+
+ //Add rule to handle EL expressions
+ ruleSet.addRule(_ConverterRule.Instance);
+
+ return ruleSet;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/ConverterBaseTagHandler.java
------------------------------------------------------------------------------
svn:eol-style = native