Checkbox in datatable

Hi,
I use a data table in my jsf page.I have give a f:selectbooleanchkbox.
When i select the chk box my data table has to be updated with the checked ones.
problem here is:
I have a button at the bottom of my page named reassign.when i click on the reassign button i shud get a pop up and this pop up has to be loaded with dynamic values.since a java script for pop up & both action cannot be called at a single shot , i use a use bean tag in my pop up to call a method in backing bean to load the pop mup with dynamic values.
Doing this way(calling a bean method), will my data table be automatically updated?
Presently am using a value changed listener on click of my chk box.but doing this way cant be efficient & does not seem to be user friendly as the form is submitted each time.
Your suggestions would be appreciated.
Thanks,
padma.

I think I finally pulled it of; I added an empty arraylist and assigned the value of the checkbox to it.
I don't really know how to point to a certain element in that list, as value="#{theBean.theList[person.id]}" or value="#{theBean.theList['person.id']}" or value="#{theBean.theList[0]}" don't seem to evaluate to something meaningfull.
It's kinda ugly, and I was hoping binding the tag to a method would get me a cleaner solution, but it appears it doesn't pass the f:attribute (??)...

Similar Messages

  • Problem with checkbox and datatable

    Hi,
    I have a checkbox in one column of the data table. The checkbox is to be disabled if the status (which is another column in the table) is set to Completed. For all other rows, the checkbox is to be enabled. What happens is that, the checkbox is either enabled for all the rows or disabled for all the rows...
    This is how i have implemented it.
    public void setCheck(){
    int rows = dataTable1.getRowCount();
    OrderRunStatusBean osb = new OrderRunStatusBean();
    for (int i =0;i<rows;i++){
    dataTable1.setRowIndex(i);
    osb = (OrderRunStatusBean)dataTable1.getRowData();
    if (osb.getStatusName().equalsIgnoreCase("Completed")){
    dataTable1.setRowIndex(i);
    chkSelect.setDisabled(true);
    else
    chkSelect.setDisabled(false);
    Thanks!!!!
    -Tabitha
    PS
    I'm facing the same trouble with selecting and deselecting a checkbox as well.

    Hallo Tabitha,
    create a method called isDisabled() in your <Page>.java class containing the logic by which you want to disable the checkbox, for example:
         * Getter for property disabled.
         * @return Value of property disabled.
        public boolean isDisabled() {
            TableRowDataProvider trdp = (TableRowDataProvider)getBean("currentRow");
            String category = (String) trdp.getValue("MUSICCATEGORIES.MUSICCATEGORY");
            return category.equals("Rock");
        }This example is connected to a TableRow and returns true when the value of the database field is "Rock".
    Then bind the disabled property of the checkbox to the 'disabled' property:
    Click on the right of the disabled property in the Properties window, select the option 'Use Binding', select the 'Bind to an object' tab, select the Page1.disabled property and click on OK.
    Deploy and run the project.
    Hope this helps.
    Ciao,
    Fabio

  • Adding checkbox to DataTable

    I want to add a check box to my data table so the user can select one or more rows for an action (Delete in this case).
    Right now, I use a simple ListModel and it's using my java bean data directly.
    But, my java bean data doesn't know anything about selection, and thus does not have a "selected" property.
    Is there a way that I can create a parallel check box array or something that ties in with my list of rows so I don't have to create a new "checkbox aware" bean for my data?

    Just add a new property to the DTO, you don't need to do it in your backing bean.
    Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html#SelectMultipleRows

  • URGENT - how to get the checkbox selected data from datatable.

    Hi
    I have some dynamic data. which will be displayed as checkbox. User can select the checkboxes in jsp. after selection when I submit the page I wanted to get the list of checkbox data the user selected.
    Here is the following code. when I submit the form the method which is mapped in bean (dostuff() method) is not calling. it is simply displaying the same page. Could you please tell me where I am doing wrong.
    please give me suggestion what I should to get the checkbox data in bean.
    My Code JSP:
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <f:view>
    <h:form>
    <h:dataTable id="xxx" var="person" value="#{checkboxBean.beans}" >
    <h:column><h:selectBooleanCheckbox value="#{person.checked}"/></h:column>
    <h:column><h:outputText value="#{person.id}"/></h:column>
    </h:dataTable>
    <h:commandButton id="details" action="#{checkboxBean.doStuff}" value="do Stuff"></h:commandButton>
    </h:form>
    </f:view>
    public class CheckboxBean {
    private static final Logger logger = Logger.getLogger(CheckboxBean.class);
    private List beans = null;
    public CheckboxBean() {
    logger.debug("CheckboxBean()");
    public String doStuff() {
    logger.debug("doStuff()");
    logger.debug("Some Bean selected data :" );
    return "test";
    public List getBeans() {
    beans = new ArrayList();
    SomeBean[] someBeans = new SomeBean[3];
    someBeans[0] = new SomeBean("first Person", false);
    someBeans[1] = new SomeBean("2nd Person", true);
    someBeans[2] = new SomeBean("third person", false);
    beans.add(someBeans[0]);
    beans.add(someBeans[1]);
    beans.add(someBeans[2]);
    logger.debug("Inside getBeans()");
    return this.beans;
    <managed-bean>
    <description>Checkbox bean.</description>
    <managed-bean-name>checkboxBean</managed-bean-name>
    <managed-bean-class>com.view.bean.CheckboxBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    * Created on Mar 17, 2006
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package com.view.bean;
    public class SomeBean {
    private boolean checked = false;
    private String id ;
    public SomeBean() {
    public SomeBean(String anId, boolean bool) {
    super();
    this.id = anId;
    this.checked = bool;
    public String getId() {
    return this.id;
    public void setId(String id) {
    this.id = id;
    public boolean isChecked() {
    return this.checked;
    public boolean getChecked() {
    return this.checked;
    public void setChecked(boolean checked) {
    this.checked = checked;
    public String toString() {
    return "Id: " + id + ", checked :" + checked;
    }

    Hello,
    If you post in ASP.NET forums, you'll get more help.
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Javascript to check if a checkbox is selected in datatable

    Hi,
    I have a form with some command buttons and couple of datatables with checkboxes in one of the columns. How do I make sure when a user clicks on any command button to generate an action only if any checkbox is selected else shows an error to atleast select one checkbox. Is it possible do that using javascript rather than on the server side. Any small example will help.
    Thanks

    Hi Detlev,
    I searched for the file controls_ie5.js. But I have only one function for cell click in js file. I didnt get any methods you mentioned in the reply.
    The workaround I could see is, get the name of the tableview control using 'myContext.getParamIdForComponent("tableviewcontrolname")'. Then append '-chk'(that is the name generated dynamically for the radio button in the HTML page). With this we can do a javascript validation if a radio button is selected. The only disadvantage is if they change the naming conventions(say instead of -chk if they use _chk) for HTMLB implementation this code will fail.
    In another post I saw a reply from Stephan Batzdorf for similar post. He says, "Now to the client side. The only thing you can do on client-side is to retrieve the selected rows and get the values from the key column.
    It's not possible to manipulate data. Of course you can render InputFields into table cells and let the user manipulate them, but then you have to retrieve each value for each InputField again on server side (pageContext.getComponentForId(tableCellInputFieldId);)."
      Does he say we cant get the value of inputfield in the client side?
    I will definitely award points once the problem is fixed.
    Regards,
    Priya

  • How to set selected all checkboxes in all dataTable's rows?

    Hi there,
    I'm trying to perform this simple task: having a dataTable with a column containing checkboxes, how can I allow (with a button, a "super" checkbox or so) to simultaneously set selected all checkboxes in all rows?
    And - is it possible to do so without calling the submit of the page?
    Thanks to everyone!

    Yes, the paging for <h:dataTable> works pretty good, it manages the task through four methods created in the java code -- DataTable1_firstPageAction(), DataTable1_previousPageAction(), DataTable1_nextPageAction(), DataTable1_lastPageAction() -- without adding any javascript in the jsp page.
    Maybe I could test if a java script similar to the <ui:table>'s one fit also the dataTable...
    thanks

  • Bug : Datatable with disabled checkboxes

    Hello,
    I was able to implement a datatable with modify, delete links for each row.
    The following code works:
    <h:data_table id="DataTable" value="#{DataScreen.records}" var="record">
      <h:column>
         <f:facet name="header"><h:output_text value=" " /></f:facet>
         <h:command_link action="#{DataScreen.modifyAction}">
           <h:output_text value="#{DataScreen.modifyLabel" />
         </h:command_link>
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value=" " /></f:facet>
         <h:command_link action="#{DataScreen.deleteAction}">
           <h:output_text value="#{DataScreen.deleteLabel" />
         </h:command_link>
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value="Column1_Header" /></f:facet>
         <h:output_text value="#{DataScreen.column1}" />
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value="Column2_Header" /></f:facet>
         <h:output_text value="#{DataScreen.column2}" />
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
    </h:data_table>But, I added a third column of type boolean, which is displayed as a disabled checkbox.
    The table is displayed properly in the browser. But, when I click on the modify, delete links,
    the corresponding action method (DataScreen.modifyAction() or DataScreen.deleteAction())
    is not called.
    <h:data_table id="DataTable" value="#{DataScreen.records}" var="record">
      <h:column>
         <f:facet name="header"><h:output_text value=" " /></f:facet>
         <h:command_link action="#{DataScreen.modifyAction}">
           <h:output_text value="#{DataScreen.modifyLabel" />
         </h:command_link>
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value=" " /></f:facet>
         <h:command_link action="#{DataScreen.deleteAction}">
           <h:output_text value="#{DataScreen.deleteLabel" />
         </h:command_link>
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value="Column1_Header" /></f:facet>
         <h:output_text value="#{DataScreen.column1}" />
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value="Column2_Header" /></f:facet>
         <h:output_text value="#{DataScreen.column2}" />
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
      <h:column>
         <f:facet name="header"><h:output_text value="Column3_Header" /></f:facet>
         <h:selectboolean_checkbox value="#{DataScreen.column3}" disabled="true" />
         <f:facet name="footer"><h:output_text value=" " /></f:facet>
      </h:column>
    </h:data_table>I would be glad to know if there is any workaround.
    Thanks,
    Ajay

    I forgot to mention that there is no error message in the log file. The same page is displayed again
    after clicking on the Modify or Delete Link.
    If I remove the third column (disabled checkbox), the modify and delete links work fine.

  • Editing selcted checkboxes in JSF when using h:dataTable

    I have a few records coming in from the Database which are displayed with checkboxes . The JSP code for them is as follows
    <h:dataTable value="#{InvestigationDefendantView.investDefsFindingsModel}" var="def" border="0" >
    <h:column>
    <h:selectManyCheckbox value="#{InvestigationDefendantView.addtype1}" disabled="false">
    <f:selectItem itemValue="Current" itemLabel="Current"/>
    <f:selectItem itemValue="Mailing" itemLabel="Mailing"/>
    <f:selectItem itemValue="Posible" itemLabel="Posible"/>
    <j4j:idProxy id="DefAddTypeProxy"/>
    </h:selectManyCheckbox>
    </h:column>
    </h:dataTable>***********************************************8
    The View class has this get method
    ======================================
    public String[] getAddtype1()
    Logger.info(this, "addtype testing", this.faddType.size());
    if (this.faddType.size() > 0 )
    ArrayList<String> alcb = new ArrayList<String>();
    for (int i = 0; i < this.faddType.size(); i++)
    alcb.add(this.faddType.get(i));
    String[] tempArr = new String[alcb.size()];
    for (int i = 0; i < alcb.size(); i++)
    tempArr[i] = alcb.get(i).intern();
    return tempArr;
    return new String[0];
    }===========================================================
    Now when i edit , It shows all the checkBoxes for a perticuler type (e.g. current ) selected even if one of them was selected while adding the record since the h:datatable runs a loop for all the records in a row and my getaddtype1 shows gets called every time and the value faddType.size() is reset every time this method is called .
    What i want to do is show only those records checked which were selected while adding . please help me in solving the issue

    You need to bind the input values of each row to the row object behind the 'var' attribute of the h:dataTable.
    Also see this article how to use datatables: [http://balusc.blogspot.com/2006/06/using-datatables.html].

  • Nested Datatables and checkbox trouble

    Hi,
    i am having a datatable with 3 rows mapping to a column in the database table..now i have another datatable inside the previous datatable mapping to another column in the database.... i am able to fetch the values from the database and populate in the 2 datatables.my first datatable has one column and it is a component label.my second datatable has 4 columns..a select many checkboxes,a component label,and 2 text fields.
    Now the problem comes when i need to save the values that are being entered in the datatable..how do i get the values of the checkbox and the textfields and update in the database.and remember i need to get the values of all the components in both the datatables and update in the database...my JSP code and the backing bean codes are as follows.......pls help me with this problem
    JSP Code:
    <h:dataTable binding="#{AttributeSelection.uiTable2}" id="dataTable2" rowClasses="form"
    value="#{AttributeSelection.arrayDataModel}" var="currentRow1">
    <h:column binding="#{AttributeSelection.column5}" id="column5">
    <h:outputText binding="#{AttributeSelection.outputText1}" id="outputText1" value=""/>
    <f:facet name="header"/>
    <h:dataTable binding="#{AttributeSelection.uiTable1}" border="1" headerClass="form_bold"
    id="dataTable1" rowClasses="form" value="#{currentRow1['attributes']}" var="currentRow">
    <h:column binding="#{AttributeSelection.column1}" id="column1">
    <h:selectBooleanCheckbox binding="#{AttributeSelection.checkbox1}" id="checkbox1" value="#{currentRow.checkbox1}"/>
    <f:facet name="header"/>
    </h:column>
    <h:column binding="#{AttributeSelection.column2}" id="column2">
    <h:outputText binding="#{AttributeSelection.outputText3}" id="outputText3" value="#{currentRow['name']}"/>
    <f:facet name="header">
    <h:outputText binding="#{AttributeSelection.outputText4}" id="outputText4"
    style="height: 23px; width: 50%" styleClass="form_bold" value="#{currentRow1['category']}"/>
    </f:facet>
    </h:column>
    <h:column binding="#{AttributeSelection.column3}" id="column3">
    <h:inputText binding="#{AttributeSelection.textField1}" id="textField1"
    style="height: 24px; width: 65%" styleClass="input" value="#{currentRow['defaultMin']}"/>
    <f:facet name="header">
    <h:outputText binding="#{AttributeSelection.outputText8}" id="outputText8" value="Min"/>
    </f:facet>
    </h:column>
    <h:column binding="#{AttributeSelection.column4}" id="column4">
    <h:inputText binding="#{AttributeSelection.textField2}" id="textField2"
    style="height: 24px; width: 65%" styleClass="input" value="#{currentRow['defaultMax']}"/>
    <f:facet name="header">
    <h:outputText binding="#{AttributeSelection.outputText9}" id="outputText9" style="" value="Max"/>
    </f:facet>
    </h:column>
    </h:dataTable>
    </h:column>
    </h:dataTable>
    Backing Bean Code:
    * AttributeSelection1.java
    * Created on January 23, 2006, 10:46 AM
    * Copyright Sidharth_Mohan
    package tpalt;
    import com.equifax.ems.tpalt.order.dao.OrderDataDAO;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import com.sun.jsfcl.data.*;
    import java.util.ArrayList;
    import javax.faces.component.*;
    import javax.faces.model.ArrayDataModel;
    import com.equifax.ems.tpalt.order.model.OrderAttribute;
    import com.equifax.ems.tpalt.order.model.OrderCategory;
    import com.sun.faces.el.MethodBindingImpl;
    import java.util.Iterator;
    import java.util.Map;
    import javax.faces.application.Application;
    import javax.faces.context.FacesContext;
    import javax.faces.el.MethodBinding;
    public class AttributeSelection extends AbstractPageBean {
    * Bean initialization.
    // </editor-fold>
    public AttributeSelection() {
    // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
    try {
    } catch (Exception e) {
    log("AttributeSelection Initialization Failure", e);
    throw e instanceof javax.faces.FacesException ? (FacesException) e : new FacesException(e);
    // </editor-fold>
    // Additional user provided initialization code
    protected tpalt.ApplicationBean1 getApplicationBean1() {
    return (tpalt.ApplicationBean1)getBean("ApplicationBean1");
    protected tpalt.SessionBean1 getSessionBean1() {
    return (tpalt.SessionBean1)getBean("SessionBean1");
    // </editor-fold>
    * Bean cleanup.
    protected void afterRenderResponse() {
    }private int __placeholder;
    private HtmlForm form1 = new HtmlForm();
    public HtmlForm getForm1() {
    return form1;
    public void setForm1(HtmlForm hf) {
    this.form1 = hf;
    public UIData uiTable1 = new UIData();
    * Getter for property uiTable.
    * @return Value of property uiTable.
    public UIData getUiTable1() {
    return uiTable1;
    * Setter for property uiTable.
    * @param uiTable New value of property uiTable.
    public void setUiTable1(UIData uiTable1) {
    this.uiTable1 = uiTable1;
    private UIColumn column1 = new UIColumn();
    public UIColumn getColumn1() {
    return column1;
    public void setColumn1(UIColumn uic) {
    this.column1 = uic;
    private UIColumn column5 = new UIColumn();
    public UIColumn getColumn5() {
    return column5;
    public void setColumn5(UIColumn uic) {
    this.column5 = uic;
    private HtmlOutputText outputText1 = new HtmlOutputText();
    public HtmlOutputText getOutputText1() {
    return outputText1;
    public void setOutputText1(HtmlOutputText hot) {
    this.outputText1 = hot;
    public UIData uiTable2 = new UIData();
    * Getter for property uiTable.
    * @return Value of property uiTable.
    public UIData getUiTable2() {
    return uiTable2;
    * Setter for property uiTable.
    * @param uiTable New value of property uiTable.
    public void setUiTable2(UIData uiTable2) {
    this.uiTable2 = uiTable2;
    private ArrayDataModel arrayDataModel = new ArrayDataModel();
    public ArrayDataModel getArrayDataModel() {
    ArrayList orderList =new ArrayList();
    OrderDataDAO orderData =new OrderDataDAO();
    ArrayList orderCategories = new ArrayList();
    try
    orderList = (ArrayList) orderData.getAllAttributes();
    for (int i =0;i<orderList.size();i++)
    OrderAttribute or =(OrderAttribute)orderList.get(i);
    //or.setCheckbox1(true);
    String category = (String)or.getCategory();
    OrderCategory orderCategory = new OrderCategory();
    ArrayList attributesforCategory = new ArrayList();
    for (int j = i;j<orderList.size();j++){
    OrderAttribute ora =(OrderAttribute)orderList.get(j);
    if (category.equals(ora.getCategory())){
    attributesforCategory.add(ora);
    orderList.remove(j);
    j = i;
    orderCategory.setCategory(category);
    orderCategory.setAttributes(attributesforCategory);
    orderCategories.add(orderCategory);
    //dataTable2Model.setWrappedData(orderCategories);
    arrayDataModel = new ArrayDataModel(orderCategories.toArray());
    catch (Exception ex) {
    return arrayDataModel;
    public void setArrayDataModel(ArrayDataModel dtdm) {
    this.arrayDataModel = dtdm;
    private UIColumn column2 = new UIColumn();
    public UIColumn getColumn2() {
    return column2;
    public void setColumn2(UIColumn uic) {
    this.column2 = uic;
    private HtmlOutputText outputText3 = new HtmlOutputText();
    public HtmlOutputText getOutputText3() {
    return outputText3;
    public void setOutputText3(HtmlOutputText hot) {
    this.outputText3 = hot;
    private UIColumn column3 = new UIColumn();
    public UIColumn getColumn3() {
    return column3;
    public void setColumn3(UIColumn uic) {
    this.column3 = uic;
    private HtmlOutputText outputText4 = new HtmlOutputText();
    public HtmlOutputText getOutputText4() {
    return outputText4;
    public void setOutputText4(HtmlOutputText hot) {
    this.outputText4 = hot;
    private UIColumn column4 = new UIColumn();
    public UIColumn getColumn4() {
    return column4;
    public void setColumn4(UIColumn uic) {
    this.column4 = uic;
    private HtmlOutputText outputText8 = new HtmlOutputText();
    public HtmlOutputText getOutputText8() {
    return outputText8;
    public void setOutputText8(HtmlOutputText hot) {
    this.outputText8 = hot;
    private HtmlOutputText outputText9 = new HtmlOutputText();
    public HtmlOutputText getOutputText9() {
    return outputText9;
    public void setOutputText9(HtmlOutputText hot) {
    this.outputText9 = hot;
    public UIInput textField1 = new UIInput();
    public UIInput getTextField1() {
    return textField1;
    public void setTextField1(UIInput hit) {
    this.textField1 = hit;
    public UIInput textField2 = new UIInput();
    public UIInput getTextField2() {
    return textField2;
    public void setTextField2(UIInput hit) {
    this.textField2 = hit;
    public UISelectBoolean checkbox1 = new UISelectBoolean();
    public UISelectBoolean getCheckbox1() {
    return checkbox1;
    public void setCheckbox1(UISelectBoolean hsbc) {
    this.checkbox1 = hsbc;
    public String save_action() {
    try{
    java.lang.System.out.println("><<<<<<<<<<<<<<<Button Came><<<<<<<<<<<<<<<<<<>>>>>>>");
    java.lang.System.out.println("====================Welcome to the Button action======================");
    int firstIndex = uiTable2.getFirst();
    int rows = uiTable2.getRowCount();
    java.lang.System.out.println("----------------------FIRST INDEX-----------------------"+firstIndex);
    java.lang.System.out.println("----------------------ROWS-----------------------"+rows);
    ArrayList orderAttribs = orderCat.getAttributes();
    Iterator it = orderAttribs.iterator();
    while(it.hasNext())
    OrderAttribute currentAttribute = (OrderAttribute) it.next();
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getCheckbox1());
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getName());
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getDefaultMin());
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getDefaultMax());
    catch (Exception e) {
    e.printStackTrace();
    return "Test";
    private HtmlCommandButton save = new HtmlCommandButton();
    public HtmlCommandButton getSave() {
    return save;
    public void setSave(HtmlCommandButton hcb) {
    this.save = hcb;
    Please Reply me with this solution soon.............
    Thanx
    }

    Hi Tabitha,
    You have mentioned extraction of data from two database tables. Can those two tables be joined to put the data in one single table component?
    Cheers
    Giri

  • Hello guy i have problem with my code that it shows that "Datatable name tblCustomer already belongs to this Dataset" Notes : it happen when i uncheck and check my checkbox again

          string sProduct = "SELECT * FROM tbl_Product";
                string sCustomer = "SELECT * FROM tbl_CustomerInfo WHERE type = 'vip'";
                try
                    if (cbvipcus.Checked == true)
                        dtVipCustomer = FillComboBoxDataSource(cbcusname, sCustomer, "cus_id", "cus_name");
                        dtVipCustomer.TableName = "tblCustomer";
                        ds.Tables.Add(dtVipCustomer);
                        dtVipProduct = FillComboBoxDataSource(cbproname, sProduct, "pro_id", "pro_name");
                        dtVipProduct.TableName = "tblProduct";
                        ds.Tables.Add(dtVipProduct);

    Since you are appearantly reusing the same DataSet, you should clear it before adding the new DataTables. If you do this before the if-case you can make sure that they are always removed:
    if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
    foreach (DataTable dt in ds.Tables)
    ds.Tables.Remove(dt);
    if (cbvipcus.Checked == true)
    dtVipCustomer = FillComboBoxDataSource(cbcusname, sCustomer, "cus_id", "cus_name");
    dtVipCustomer.TableName = "tblCustomer";
    ds.Tables.Add(dtVipCustomer);
    dtVipProduct = FillComboBoxDataSource(cbproname, sProduct, "pro_id", "pro_name");
    dtVipProduct.TableName = "tblProduct";
    ds.Tables.Add(dtVipProduct);
    else if(cbvipcus.Checked == false)
    ds.Clear();
    cbcusname.DataSource = null;
    cbproname.DataSource = null;
    ClearTextBox(this.Controls);
    If this doesn't work you will have to tell us on what line the exception occurs and how the FillComboBoxDataSource method is implemented.
    Please remember to mark helpful posts as answer and/or helpful.

  • How to add a column of checkboxes in a table?

    Hello, can anyone help me with this?
    I'm using myfaces , and I want to add a selectManyCheckBox inside a table, in order to select multi-row of the
    table.
    My code didn't work. It seems that I can only use static values for the 'itemValue' attribute of <f:selectItem> tag.
    May someone give me some suggestion?
    Here is my page:
    <f:view>
    <x:saveState value="#{fishSalesBean}"></x:saveState>
    <h:form>
    <h:panelGrid columns="1" columnClasses="first, first, first, first">
    <x:dataTable id="dataTable" value="#{fishSalesBean.fishes}" var="fish"
    width="800" columnClasses="first, first, first, first" binding="#{fishSalesBean.dataTable}">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Select"/>
    </f:facet>
    <x:selectManyCheckbox id="checkboxes" layout="pageDirection" value="#{fishSalesBean.selected}">
    <f:selectItem itemValue="#{fishSalesBean.dataTable.rowIndex}" itemLabel=" a"/>
    </x:selectManyCheckbox>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="FishName"/>
    </f:facet>
    <h:outputText value="#{fish.name}"></h:outputText>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="picture"/>
    </f:facet>
    <h:graphicImage value="#{fish.picUrl }" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="price"/>
    </f:facet>
    <h:outputText value="#{fish.price}"></h:outputText>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="isSold"/>
    </f:facet>
    <h:outputText value="#{fish.sold}"></h:outputText>
    </h:column>
    </x:dataTable>
    <h:commandButton value="Show Selected" action="#{fishSalesBean.showSelected}"></h:commandButton>
    </h:panelGrid>
    </h:form>
    </f:view>

    Check the "Select multiple rows" chapter of this article for 2 ways of selecting multiple rows in a table using checkboxes: http://balusc.blogspot.com/2006/06/using-datatables.html

  • Multi Select in a DataTable

    Is there a good way to do multiselect in a datatable. I want to use checkboxes (with the submit being after all checkboxes are selected), but the value for the checkbox would not be bound to the dataset. As a result the datatablemodel would not know that the row had been updated. In this instance, how do you tell that the checkboxes in a datatable have been clicked??
    LES

    check out the AppModel application - the OnePage Table Based example in it shows exactly this kind of thing for deleting multiple rows from a datatable...
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    v

  • How to get selected values from datatable with paging

    hi all
    here is my problem
    I have a datatable with paging size of 2 and first column as checkbox.
    now i have total record of 5 data,2 row on each page.
    Now i m selecting 1-1 row from each page.
    When i m clicking Command button to display all the selected row from different page ,i m only able to display values selected from last page.
    Through debug i can see that only last page value is set to TRUE OR FALSE and every other value is neither true nor false.
    any help???
    thanks

    <f:facet name="footer">
    <h:panelGroup binding="#{Page1.groupPanel1}" id="groupPanel1"
    style="display: block; text-align: center" styleClass="list-paging-footer">
    <h:commandButton action="#{Page1.dataTable1_firstPageAction}" binding="#{Page1.dataTable1FooterFirstButton}" id="dataTable1FooterFirstButton" image="resources/paging_first.gif" immediate="true"/>
    <h:commandButton action="# Page1.dataTable1_previousPageAction}" binding="#{Page1.dataTable1FooterPreviousButton}"
    id="dataTable1FooterPreviousButton" image="resources/paging_previous.gif" immediate="true"/>
    <h:commandButton action="#{Page1.dataTable1_nextPageAction}" binding="#{Page1.dataTable1FooterNextButton}"
    id="dataTable1FooterNextButton" image="resources/paging_next.gif" immediate="true"/>
    <h:commandButton action="#{Page1.dataTable1_lastPageAction}" binding="#{Page1.dataTable1FooterLastButton}"
    id="dataTable1FooterLastButton" image="resources/paging_last.gif" immediate="true"/>
    </h:panelGroup>
    </f:facet>
    Above is the code which i m using for paging which is command button
    Any problem with it.???
    thanks

  • How to get the values of a selectManyCheckBox when that is in h:dataTable

    Hello,
    I have a jsp page. in that user can choose multile checkboxes and these checkboxes labled as Current, Mailing, PosibleMailing, length is 3 fixed.
    And i am displaying this in a <h:dataTable> this datatable length depends upon the users there may be more than 1 user, for every user there is multiplecheckbox with length 3(fixed).
    code is look like this
    <h:dataTable value="#{InvestigationDefendantView.investDefsFindingsModel}" var="def" border="0" >
    <h:column>
    <h:selectManyCheckbox value="#{InvestigationDefendantView.addtype1}" disabled="false">
    <f:selectItem itemValue="Current" itemLabel="Current"/>
    <f:selectItem itemValue="Mailing" itemLabel="Mailing"/>
    <f:selectItem itemValue="Posible" itemLabel="Posible"/>
    <j4j:idProxy id="DefAddTypeProxy"/>
    </h:selectManyCheckbox>
    </h:column>
    </h:dataTable>
    here abovevalue="#{InvestigationDefendantView.investDefsFindingsModel}" suppose 3(we can assume) then there are 3 pairs of selectManyCheckBoxes are there in my jsp page.
    So u can assume in my jsp page checkboxes are look like 3*3 Matrix
    from my backing bean i am fetching the values of this checkboxes with the below code
    java code:
    InvestDefAddressTypeGetter inv = new InvestDefAddressTypeGetter();
    InvestDefAddressTypeBean[] inb = inv.get(pID);
    this.fMap = new HashMap<String, ArrayList<String>>();
    for(int i=0; i<inb.length; i++)
    String str1 = inb.getGivenDefID().toString();
    this.fdefid.add(str1);
    this.fGivenDefID.add(inb[i].getGivenDefID());
    String addType = inb[i].getAddType();
    Logger.info(this, "adding type value", addType);
    this.fdefid.add(str1);
    this.faddType.add(addType);
    Logger.info(this, "length of strings", this.faddType);
    this.fMap.put(str1, this.faddType);
    i am fetching the checkboxes value through my get method
    public String[] getAddtype1() throws SQLException, SearchException
    Logger.info(this, "addtype testing", this.faddType.size());
    if (this.faddType.size() > 0 )
    ArrayList<String> alcb = new ArrayList<String>();
    for (int i = 0; i < this.faddType.size(); i++)
    alcb.add(this.faddType.get(i));
    String[] tempArr = new String[alcb.size()];
    for (int i = 0; i < alcb.size(); i++)
    tempArr[i] = alcb.get(i).intern();
    return tempArr;
    return new String[0];
    from the above code if i have clicked (you can assume 3*3 matrix here) 1*1, 1*2 and 2*1 and 2*2and saving the value in database records are saved as per requirement but when i am editing the records with the above code i am getting 1*1, 1*2 and 2*1, 2*2 and 3*1, 3*2 checked but i did not checked the 3*1 and 3*2 ckeck boxes.
    Because the same get method will be called in the multipleckeck boxes. how can i prevent does not display the unchecked value from my backing bean.
    Please anybody help me in this issue.

    Is this you? [http://forums.sun.com/thread.jspa?threadID=5335038].

  • Deleting a single row in a report using checkbox

    Hi,
    Can anyone please help me on how to perform a deletion of a single row/multiple rows in a report when one clicks on a checkbox ..
    I went throught the HOWTO's guide .. But when i select a checkbox and say delete i get the following error:
    ORA-20001: Error in multi row delete operation: row= 12, ORA-01403: no data found,
    Waiting for your replies soon
    Thanks in advance
    Rakesh

    jabalsad wrote:
    Hi,
    I am fairly new to JSF so please bear with me if the answer is obvious :D. I'm using a dataTable component to display data from a database and would like to add a commandLink component to every row in the table that deletes that row from the database. What is the most effective way of doing this?
    I'm thinking of using a ListDataModel with some function that removes the correct row (though I'm not sure how it will tie in with a commandLink and exactly where the database will be updated). I'll appreciate any pointers or perhaps even an online example of something similar.
    Alternatively I suppose you could pass an "id" parameter on with the commandLink that somehow gets read in the request and the appropriate row is removed accordingly. This solution seems cumbersome however.Yes, your instincts are correct there. Binding the data model to a backing bean to get the UIData instance for the table. Then use UIData.getRowData() to get the object corresponding to the row containing the link/button. Then execute your business logic to delete the row from the database. Then you need to ensure the data model is updated to reflect the new state of the database.

Maybe you are looking for

  • Photoshop cc 2014 / Bridge cc (automated tasks not available under "Tools" menu)

    I Have downloaded the new Photoshop CC 2014 and updated Bridge. I am no longer able to run automated tasks from Bridge in Photoshop because the "photoshop" submenu is not available under tools...

  • Update interupted... Any way to get photos off?

    Hi everyone, This is my first time posting here so if it's the wrong area, I appologize. I did the latest update this morning for my IPhone (I have an IPhone 3G) from the ITunes store.. I'm not sure of the exact number of the update. I was doing the

  • What's with the artwork?

    Some times, when somebody forwards me something, my e-mail program won't display the art. It only gives me a small blue square with a question mark in it. Other times, when I forward something to my wife, on her G4, the same thing happens, even thoug

  • Fields "Used " upon Leave Request show carry forward instead of al

    Dear all, Staff  have apply 1 days annual leave. However when the staff submit leave request via ess, fields "used" in leave request show carry forward leave insteqad of annual leave . The staff have carry forward but have fully utilize it before his

  • USB printer not seen wirelessly on Airport Express through Airport Extreme

    Hey everyone, I just bought an Airport extreme and a new Airport express for my house. I've got the Extreme in the basement where it is sending out wifi and directly plugged into a PS3 and the new Airport Express, which is 2 floors upstairs. The Expr