I tried some ways to achieve this simple thing :
- Show a collection of POJOs in form of checkboxes
- When i click on one of the checkboxes, a method should be executed
- The method will be able to access the pojo/checkbox that was clicked
I tried to implement it this way :
<h:selectManyCheckbox id="groupUsers" layout="pageDirection" value="#{timetableBean.selectedUsers}">
<f:ajax listener="#{timetableBean.processUserEvents}" render="@this" />
&l开发者_运维知识库t;f:selectItems value="#{timetableBean.group.users}"
var="user" itemLabel="#{user.userId} - #{user.name}" itemValue="#{user}">
<f:attribute name="user" value="#{user}" />
</f:selectItems>
</h:selectManyCheckbox>
And my method is :
public void processUserEvents(AjaxBehaviorEvent e) {
User user = (User) e.getComponent().getAttributes().get("user");
...
}
The user fetched from e.getComponent().getAttributes().get("user");
is sadly null
In what way can i accomplish this ?
Thank you !
精彩评论