posted 15 years ago
Hi
Thank-you very much for your reply. I just wanted to confirm something with you please. I assume that by datamodel, you mean the list that is going to be populated in the datatable. My scenario is as follows :
User clicks on a View menu item. He/she then has a search criteria, and then clicks the search button. In my bean, I populate the data tables list, in a method called doSearch() <this populates the adminUserList>. It then reloads the same page, and because I have a rendered attribute on the datatable to check if the list is populated, it then populates it.
PS. My code is as follows
public Collection<AdminUserEntity> doSearch() {
logger.info("doSearch");
foundResults = false;
//check which of the three search criteria was entered
if((getSearchName() == null | getSearchName().trim().equals("")) && (getSearchSurname() == null | getSearchSurname().trim().equals(""))
&& (getSearchUserName() == null | getSearchUserName().trim().equals(""))) {
if(userSession.getAdminUser().getAccessLevel().getDescription().trim().equals("SuperUser")) {
adminUserList = adminUserManager.getAllAdminUsers();
} else {
adminUserList = adminUserManager.getAllAdminUsersForDomain(userSession.getAdminUser().getDomain().getDomainId());
}
}
and the xhtml page is
<rich:dataTable id="dtAdminUser"
value="#{userAdmin.adminUserList}"
var="adminUser"
onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
width="100%" rendered="#{userAdmin.adminUserList.size() > 0
}" rowkey="#{adminUser.adminUserId}">
<rich:column width="30px">
<f:facet name="header"></f:facet>
<a4j:commandButton image="/img/pencil.png" rendered="#{userAdmin.showUpdateBtn}" immediate="true" action="#{userAdmin.administerUser(adminUser.adminUserId)}"/>
<a4j:commandButton image="/img/pencil_delete.png" rendered="#{userAdmin.showDeleteBtn}" immediate="true" action="#{userAdmin.administerUser(adminUser.adminUserId)}"/>
<a4j:commandButton image="/img/magnifier.png" rendered="#{userAdmin.showViewBtn}" immediate="true" action="#{userAdmin.administerUser(adminUser.adminUserId)}"/>
</rich:column>
<rich:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{adminUser.name}" />
</rich:column>
<rich:column>
<f:facet name="header">Surname</f:facet>
<h:outputText value="#{adminUser.surname}" />
</rich:column>
<rich:column>
<f:facet name="header">adminUserName</f:facet>
<h:outputText value="#{adminUser.userName}" />
</rich:column>
</rich:dataTable>