我的复选框组件包含@media screen { /* for screen option*/
p {
font-family: verdana, sans-serif;
font-size: 17px;
}
}
和 p {
font-family: georgia, serif;
font-size: 14px;
color: blue;
}
}
。
$engineers = [];
// process data
while ($row = mysql_fetch_assoc($res)) {
if (!isset($engineers[$row['username']])) {
$engineers[$row['username']] = [
'name' => $row['name'],
'locations' => [],
];
}
$engineers[$row['username']]['locations'][] = [
$xml->writeAttribute('fieldLoc', $row['location']);
'vistiDate' => $row['vdate'],
'retDate' => $row['rdate']);
];
}
// generate xml
foreach ($engineers as $engineer) {
// add engineer info to xml
foreach ($engineer['locations'] as $location) {
// add location to xml
}
}
我尝试在侦听器方法中获取<f:attribute>
<p:ajax listener>
值,如下所示:
<h:selectManyCheckbox ...>
<p:ajax listener="#{locationHandler.setChangedSOI}" />
<f:attribute name="Dummy" value="test" />
...
</h:selectManyCheckbox>
然而,它打印<f:attribute>
。我怎么能得到它?
答案 0 :(得分:4)
组件属性不作为HTTP请求参数传递。组件属性设置为..呃,组件属性。即它们存储在UIComponent#getAttributes()
中。你可以通过那张地图抓住它们。
现在正确的问题显然是如何在ajax监听器方法中获得所需的UIComponent
。有两种方法:
指定AjaxBehaviorEvent
参数。它为此目的提供了getComponent()
方法。
public void setChangedSOI(AjaxBehaviorEvent event) {
UIComponent component = event.getComponent();
String dummy = component.getAttributes().get("Dummy");
// ...
}
使用UIComponent#getCurrentComponent()
辅助方法。
public void setChangedSOI() {
UIComponent component = UIComponent.getCurrentComponent(FacesContext.getCurrentInstance());
String dummy = component.getAttributes().get("Dummy");
// ...
}