Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 JSF中component.getAttributeName()和component.getAttributes().get(";name";)之间的区别是什么_Jsf 2_Components - Fatal编程技术网

Jsf 2 JSF中component.getAttributeName()和component.getAttributes().get(";name";)之间的区别是什么

Jsf 2 JSF中component.getAttributeName()和component.getAttributes().get(";name";)之间的区别是什么,jsf-2,components,Jsf 2,Components,在JSF中,两者之间有什么区别 UIComponent component; component.get *AttributeName*() and component.getAttributes().get("attibute name") ? ? 例如,如果我在getAttributes()HashMap?的调用阶段设置disabled=true属性,则在功能上没有任何区别。从技术上讲,UIComponent#getAttributes()允许开发人员在获取/设置属性时不必担心确切的组

在JSF中,两者之间有什么区别

UIComponent component;
component.get *AttributeName*()  and
component.getAttributes().get("attibute name") 
?

?


例如,如果我在
getAttributes()
HashMap?

的调用阶段设置
disabled=true
属性,则在功能上没有任何区别。从技术上讲,
UIComponent#getAttributes()
允许开发人员在获取/设置属性时不必担心确切的组件类型

使用
disabled=“true”
查看您的特定示例。
UIComponent
超类根本没有任何
isDisabled()
方法。您需要先执行
instanceof
检查,例如
HtmlInputText
,然后才能对其进行强制转换并最终调用
isDisabled()
。然后,
getAttributes()
就更容易独立于此。标准jsfapi中的许多
UIComponent
相关方法采用或返回
UIComponent
超类,而不是特定类型


在正确设计的组件中,这两个组件最终都会委托给同一个组件,即
UIComponent\getstateheloper()

,谢谢您的回答。您能否用一些词解释一下
UIComponent#getstateheloper()
用于什么?在同一视图上跨回发请求保存组件的状态。组件实例本质上是请求范围的。另见和
component.set *AttributeName*(value) 
component.getAttributes().put("attibute name", value)