java - Why UIComponentBase class doesn't expose a setAttribute() method? -
java - Why UIComponentBase class doesn't expose a setAttribute() method? -
uicomponentbase have public abstract map<string, object> getattributes()
method doesn't have setattributes() method .why designed ? assuming designers wanted create map unmodifiable why ?
my requirement clean attributes of component . how instead of calling each of setters ? can not phone call clear() on attributes map because it throws unsupportedoperationexception
because it's not "just" hashmap
or so. it's customized map next specific features mentioned in the javadoc:
the returned implementation must back upwards of standard , optional map methods, plus back upwards next additional requirements:
themap
implementation must implement java.io.serializable
interface. any effort add together null
key or value must throw nullpointerexception
. any effort add together key not string
must throw classcastexception
. if attribute name specified key matches property of uicomponent
's implementation class, next methods have special behavior: containskey
- homecoming false
. get()
- if property readable, phone call getter method , homecoming returned value (wrapping primitive values in corresponding wrapper classes); otherwise throw illegalargumentexception
. put()
- if property writeable, phone call setter method set corresponding value (unwrapping primitive values in corresponding wrapper classes). if property not writeable, or effort made set property of primitive type null
, throw illegalargumentexception
. remove
- throw illegalargumentexception
. particularly get()
special. doesn't "just" homecoming value associated map key, invokes getter method on current component, e.g. component.getfoo()
when component.getattributes().get("foo")
requested. getter methods in turn delegate statehelper
.
the setattributes()
allow overriding , breaking contract , perchance cause whole jsf component tree working fail.
java jsf
Comments
Post a Comment