f:attribute,af:clientAttribute可以在监听时取到相对应binding的值。
如用for Each 循环 或表时,取当前行的字段的值
在bean取用 f:attribute
在用会用actionlistener的组件下加
f:attribute
<af:commandLink partialSubmit="true"
clientComponent="true"
id="cl2"
text="·#{bindings.EcpExInfoAnnounceVO1.children[stat.index].InfoAnnounceTitle}"
inlineStyle="color:rgb(99,99,99); font-size:12.0px;"
actionListener="#{HomePageBean.gotoinfo}">
<f:attribute name="InfoAnnounceId"
value="#{bindings.EcpExInfoAnnounceVO1.children[stat.index].InfoAnnounceId}"/>
</af:commandLink>
bean代码
public void gotoinfo(ActionEvent actionEvent) {
Map attr = actionEvent.getComponent().getAttributes();
String InfoAnnounceId = attr.get("InfoAnnounceId").toString();
System.out.println(InfoAnnounceId);
}
在js取用 af:clientAttribute
<af:commandLink id="cl4" partialSubmit="true">
<af:image clientComponent="true" id="image5"
source="#{bindings.ProfileValue.inputValue}#{bindings.result.children[stat.index].ShortPicUrl}"
inlineStyle="width:150px;height:135px;"
imageMapType="server">
<af:clientAttribute value="#{bindings.ProfileValue.inputValue}#{bindings.result.children[stat.index].DetailPicUrl}"
name="url"/>
<af:clientAttribute name="ProductName"
value="产品名称:#{bindings.result.children[stat.index].ProductName}"/>
<af:clientAttribute value="产品详情:#{bindings.result.children[stat.index].Description}"
name="Description"/>
<af:clientListener method="showDetail"
type="click"/>
<af:showPopupBehavior triggerType="click"
align="endAfter"
popupId="::ProductDeatilPopup"/>
</af:image>
</af:commandLink>
js代码
function showDetail(e) {
var im = e.getSource();
var name = im.getProperty("ProductName");
var popup = AdfPage.PAGE.findComponent("ProductDeatilPopup");
var productname = popup.findComponent("ProductDeatilNameOt");
var image = popup.findComponent("ProductDeatilImage");
if (image) {
image.setSource(im.getProperty("url"));
}
if (productname) {
productname.setValue(im.getProperty("ProductName"));
}
var desc = popup.findComponent("ProductDeatilOt");
if (desc) {
desc.setValue(im.getProperty("Description"));
}
}