Strange EL problem
mwkohout Oct 29, 2007 11:52 AMI've got two places on a page where I iterate lists of object. For each object I output a button that allows them(in this case) to add a user and role to a domain object(in this case, a research study-I work for a university). While in both cases the datatable is populated, in the first instance when the aj4 buttons are clicked the backing actions are not called. I don't know why.
This is the nonworking instance. It displays the output of a user search. In summary, what it does is iterate through a list of members returned by the 'userHome' object. Then, in the 3rd column, I obtain a list of all possible roles and iterate over them, displaying the appropriate buttons tied to the appropriate methods.
<rich:dataTable id="memberSelectList" value="#{userHome.findByNameOrInternetID(memberSearchName).toArray()}" var="possibleMember" rendered="#{memberSearchName.trim().length() gt 0}" rowKey="#{possibleMember.umnDID}" rowKeyVar="umnDID"> <rich:column> <f:facet name="header">Name</f:facet> #{possibleMember.name} </rich:column> <rich:column> <f:facet name="header">User Name</f:facet> #{possibleMember.userName} </rich:column> <rich:column> <f:facet name="header">Add to List of Study Members</f:facet> <a4j:repeat value="#{studyRoleHome.getAllRoles()}" var="role" > possibleMember: #{possibleMember.class} role: ${role.class} <a4j:commandButton type="submit" value="Add as #{role.name}" reRender="memberGrid" rendered="#{!viewStudyAction.study.containsMember(possibleMember,role)}" action="#{viewStudyAction.study.addMember(possibleMember,role)}" ajaxSingle="true" /> <a4j:commandButton type="submit" value="Remove as #{role.name}" reRender="memberGrid" rendered="#{viewStudyAction.study.containsMember(possibleMember,role) and not viewStudyAction.isRoleAndUser(user, possibleMember, role, administrativeRole) }" action="#{viewStudyAction.removeMember(possibleMember,role)}" ajaxSingle="true" /> <a4j:commandButton type="submit" value="Remove as #{role.name}" reRender="memberGrid" rendered="#{viewStudyAction.isRoleAndUser(user, possibleMember, role, administrativeRole) and not viewStudyAction.confirmRemoveSelfAsAdmin}" action="#{viewStudyAction.setConfirmRemoveSelfAsAdmin(true)}" ajaxSingle="true" /> <a4j:commandButton type="submit" value="Remove Yourself as #{role.name}. This cannot be undone." reRender="bodyPanel" rendered="#{viewStudyAction.isRoleAndUser(user, possibleMember, role, administrativeRole) and viewStudyAction.confirmRemoveSelfAsAdmin}" action="#{viewStudyAction.removeMember(possibleMember,role)}" ajaxSingle="true" /> </a4j:repeat> </rich:column> </rich:dataTable>
This is the working list-it displays a list of current users. It obtains it's array/list of user and roles directly from the Study object, then iterates over them. For each returned user it also iterates over the list of roles.
<rich:dataTable id="memberList" value="#{viewStudyAction.study.getUserAndRole().toArray()}" var="userAndRole" rowKey="#{userAndRole.user.umnDID}" rowKeyVar="umnDID" > <rich:column> <f:facet name="header">Name</f:facet> #{userAndRole.user.name} </rich:column> <rich:column> <f:facet name="header">User Name</f:facet> #{userAndRole.user.userName} </rich:column> <rich:column> <f:facet name="header">Add or Remove Users from the list of Study Members</f:facet> <a4j:repeat value="#{studyRoleHome.getAllRoles()}" var="role" rendered="#{studyRoleHome.containsRole(viewStudyAction.study.userAndRole, user, administrativeRole)}" > userAndRole.user: #{userAndRole.user.class} role: #{role.class} <a4j:commandButton type="submit" value="Add as #{role.name}" reRender="memberGrid" rendered="#{!viewStudyAction.study.containsMember(userAndRole.user,role)}" action="#{viewStudyAction.study.addMember(userAndRole.user,role)}" ajaxSingle="true" /> <a4j:commandButton type="submit" value="Remove as #{role.name}" reRender="memberGrid" rendered="#{viewStudyAction.study.containsMember(userAndRole.user,role) and not viewStudyAction.isRoleAndUser(user, userAndRole.user, role, administrativeRole) }" action="#{viewStudyAction.removeMember(userAndRole.user,role)}" ajaxSingle="true" /> <a4j:commandButton type="submit" value="Remove as #{role.name}" reRender="memberGrid" rendered="#{viewStudyAction.isRoleAndUser(user, userAndRole.user, role, administrativeRole) and not viewStudyAction.confirmRemoveSelfAsAdmin}" action="#{viewStudyAction.setConfirmRemoveSelfAsAdmin(true)}" ajaxSingle="true" /> <a4j:commandButton type="submit" value="Remove Yourself as #{role.name}. This cannot be undone." reRender="bodyPanel" rendered="#{viewStudyAction.isRoleAndUser(user, userAndRole.user, role, administrativeRole) and viewStudyAction.confirmRemoveSelfAsAdmin}" action="#{viewStudyAction.removeMember(userAndRole.user,role)}" ajaxSingle="true" /> </a4j:repeat> </rich:column> </rich:dataTable>
Any opinion would be welcome. This problem has stumped me for more than a couple of days.
Mike Kohout