I think it is a good idea as long as CSS style or style is also NOT in
use.  You never know what the designer had in mind and while this would
be a great feature to have most of the time it will not work all of the
time.  

Would this not be better left to working with a skin style definition?

Steve


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Matthias Wessendorf
Sent: Tuesday, August 14, 2007 3:44 AM
To: MyFaces Development
Subject: #Adv#: [Trinidad] SimpleInputTextRenderer / numeric field

Hi,

there is a private _isNumericField() method inside the renderer. Not
called atm.
Wouldn't it be nice, if we render a CSS rule (text-align: right;), when
the rendered input field is a numberic field ?

For that, we could do something like:

  private boolean _isNumericField(
    FacesBean bean
    )
  {
    ValueExpression binding = getValueExpression(bean);
    if (binding != null)
    {
      FacesContext context = FacesContext.getCurrentInstance();
      Class type = binding.getType(context.getELContext());
      return Number.class.isAssignableFrom(type) ||
(type.isPrimitive() && _NUMBER_TYPES.contains(type));
    }
    return false;
  }


Where _NUMBER_TYPES is:
  private final static Set<Class> _NUMBER_TYPES = new HashSet<Class>();

  static
  {
    _NUMBER_TYPES.add(Byte.TYPE);
    _NUMBER_TYPES.add(Short.TYPE);
    _NUMBER_TYPES.add(Integer.TYPE);
    _NUMBER_TYPES.add(Long.TYPE);
    _NUMBER_TYPES.add(Float.TYPE);
    _NUMBER_TYPES.add(Double.TYPE);
  }

by making it protected, subclasses could also use it..

What do you think ?

(yes, I used unified EL in this example..., on trunk that would be
ValueBinding for instance)

-Matthias

--
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
mail: matzew-at-apache-dot-org

This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.

Reply via email to