Need help in using checkbox to delete a row in datatable
swathis Nov 21, 2008 6:50 AMHello Every one.... I have created two entities named CityList and AreaList, I have written 2 xhtml files.In cityList.xhtml all the city list in the database will be populated in the data table and when u click on the city name it goes to areaList.xhtml, where area list is populated in datatable.I want to delete a particular row by using h:selectManyCheckbox in areaList.xhtml , but am not able to delete the selected row in the data table, I am not able to find out the problem , why it is no getting deleted. Can any body tell me what is the problem.....
here is my xhtml files and entities
AreaList.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" template="../layout/mainTemplate.xhtml"> <ui:define name="innerbody"> <ui:include src="/stylesheet/defaultStyles.css"/> <a4j:keepAlive beanName="cityList"></a4j:keepAlive> <a4j:keepAlive beanName="cityListHome"></a4j:keepAlive> <a4j:form id="areaListForm" ajaxSubmit="true" enctype="multipart/form-data" style="padding-top: 5%;width:100%; padding-left: 5%;vertical-align: top;"> <h:messages globalOnly="true" styleClass="message" style="border: 1px solid #FFCC00; padding: 5px; margin-top: 5px; margin-bottom: 5px; background-color: #F0F8FF; font-size: 12px;" /> <rich:panel headerClass="headerFont"> <f:facet name="header"> Area List </f:facet> <ui:include src="/stylesheet/defaultStyles.css" /> <h:panelGrid columns="2" cellspacing="1" width="100%" cellpadding="0" columnClasses="formColumn1"> <h:column> <s:decorate for="name" template="/layout/newEdit.xhtml"> <ui:define name="label"> <h:outputLabel value="City Name" styleClass="formFont" for="name"></h:outputLabel> </ui:define> <rich:inplaceInput defaultLabel="#{cityListHome.cityNameConversation}" value="#{cityListHome.cityNameConversation}" showControls="true" id="name" style=" width : 175px;" styleClass="formFont2"> <a4j:support event="onviewactivated" action="#{cityListHome.update}"/> </rich:inplaceInput> </s:decorate> </h:column> </h:panelGrid> <h:form id="myForm" style="width:100%;" enctype="multipart/form-data"> <h:outputText value="Areas Not Found."rendered="#{empty areaDetails.resultList}" /> <rich:datascroller for="areaDetails" rendered="#{not empty areaDetails.resultList}"></rich:datascroller> <rich:dataTable style="width:100%;" id="areaDetails" value="#{areaDetails.resultList}" var="areaList" rendered="#{not empty areaDetails.resultList}" rowClasses="#{tableLnF.getRowSettings(skinBean.skin)}" headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}" rows="10" columnClasses="formFont2"> <f:facet name="header"> <rich:columnGroup> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Select"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Area code"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}" > <h:outputText value="Area Name"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Area Population"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Street Name"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Tower No. Starting Range"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Tower No. Ending Range"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Pincode"/> </rich:column> </rich:columnGroup> </f:facet> <rich:column align="left" colspan="1"> <h:selectManyCheckbox value="#{areaListHome.id}" id="checkbox" required="true"> <f:selectItem itemValue="#{areaList.areaCode}"/> </h:selectManyCheckbox> </rich:column> <rich:column align="center" filterBy="#{areaList.areaCode}" filterEvent="onkeyup" width="30px"> #{areaList.areaCode} <h:outputText value="." style="font-size:30px;color:WHITE;"></h:outputText> </rich:column> <rich:column align="center" filterBy="#{areaList.areaName}" filterEvent="onkeyup" width="30px"> <rich:inplaceInput defaultLabel="#{areaList.areaName}" value="#{areaList.areaName}" showControls="true" id="value"> <a4j:support event="onviewactivated" action="#{areaListHome.update}"/> </rich:inplaceInput> </rich:column> <rich:column align="center"> #{areaList.areaPopulation} </rich:column> <rich:column align="center"> #{areaList.streetName} </rich:column> <rich:column align="center"> #{areaList.towerNoStartingRange} </rich:column> <rich:column align="center"> #{areaList.towerNoEndingRange} </rich:column> <rich:column align="center"> #{areaList.pincode} </rich:column> </rich:dataTable> <h:panelGrid columns="3"> <div class="actionButtons"> <s:button id="donee" value="Add New Area" rendered="#{!areaListHome.managed}" view="/admin/newArea.xhtml" styleClass="defaultButton" style="#{formLnF.getButtonSettings(skinBean.skin)}"/> <h:commandButton id="delete" value="Delete" rendered="#{cityListHome.managed}" action="#{cityListHome.remove}" styleClass="defaultButton" style="#{formLnF.getButtonSettings(skinBean.skin)}" onclick="if (!confirm('Are you sure you want to DELETE this role?')) return false;"> </h:commandButton> <s:button propagation="end" id="done" value="Cancel" view="/admin/cityList.xhtml" styleClass="defaultButton" style="#{formLnF.getButtonSettings(skinBean.skin)}"/> </div> </h:panelGrid> </h:form> </rich:panel> </a4j:form> </ui:define> </ui:composition>
CityList.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" template="../layout/mainTemplate.xhtml"> <ui:define name="innerbody"> <ui:include src="/stylesheet/defaultStyles.css"/> <a4j:keepAlive beanName="stateList"></a4j:keepAlive> <a4j:keepAlive beanName="stateListHome"></a4j:keepAlive> <a4j:form id="cityListForm" ajaxSubmit="true" enctype="multipart/form-data" style="padding-top: 5%;width:100%; padding-left: 5%;vertical-align: top;"> <h:messages globalOnly="true" styleClass="message" style="border: 1px solid #FFCC00; padding: 5px; margin-top: 5px; margin-bottom: 5px; background-color: #F0F8FF; font-size: 12px;" /> <rich:panel headerClass="headerFont"> <f:facet name="header"> City List </f:facet> <ui:include src="/stylesheet/defaultStyles.css" /> <h:panelGrid columns="2" cellspacing="1" width="100%" cellpadding="0" columnClasses="formColumn1"> <s:decorate for="name" template="/layout/newEdit.xhtml"> <ui:define name="label"> <h:outputLabel value="State Name" styleClass="formFont" for="name"></h:outputLabel> </ui:define> <rich:inplaceInput value="#{stateListHome.stateNameConversation}" showControls="true" id="name" style=" width : 175px;" styleClass="formFont2"> <a4j:support event="onviewactivated" action="#{stateListHome.update}"/> </rich:inplaceInput> </s:decorate> </h:panelGrid> <h:form id="myForm" style="width:100%;" enctype="multipart/form-data"> <h:outputText value="Cities Not Found." rendered="#{empty cityDetails.resultList}" /> <rich:datascroller for="cityDetails" rendered="#{not empty cityDetails.resultList}"></rich:datascroller> <rich:dataTable style="width:100%;" id="cityDetails" value="#{cityDetails.resultList}" var="cityList" rendered="#{not empty cityDetails.resultList}" rowClasses="#{tableLnF.getRowSettings(skinBean.skin)}" headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}" rows="10" columnClasses="formFont2"> <f:facet name="header"> <rich:columnGroup> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Select"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="City Id"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}" > <h:outputText value="City Name"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="City Population"/> </rich:column> <rich:column headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"> <h:outputText value="Status"/> </rich:column> </rich:columnGroup> </f:facet> <rich:column align="left" colspan="1"> <h:selectManyCheckbox value="#{cityListHome.areaName}"> <f:selectItem itemValue="#{cityList.cityName}"/> </h:selectManyCheckbox> </rich:column> <rich:column align="center" filterBy="#{cityList.cityId}" filterEvent="onkeyup" width="30px"> #{cityList.cityId} </rich:column> <rich:column align="center" filterBy="#{cityList.cityName}" filterEvent="onkeyup" width="30px"> <s:link id="cityName" value="#{cityList.cityName}" action="#{viewCityList.viewAreaList}"> <f:param name="citysId" value="#{cityList.cityId}" /> <f:param name="cityName" value="#{cityList.cityName}" /> </s:link> <h:outputText value="." style="font-size:30px;color:WHITE;"></h:outputText> </rich:column> <rich:column align="center"> #{cityList.cityPopulation} </rich:column> <rich:column align="center"> #{cityList.status} </rich:column> </rich:dataTable> <div class="actionButtons"> <s:button id="donee" value="Add New City" view="/admin/newCity.xhtml" styleClass="defaultButton" style="#{formLnF.getButtonSettings(skinBean.skin)}"/> <s:button propagation="end" id="done" value="Cancel" view="/admin/stateList.xhtml" styleClass="defaultButton" style="#{formLnF.getButtonSettings(skinBean.skin)}"/> </div> </h:form> </rich:panel> </a4j:form> </ui:define> </ui:composition>