Using Checkboxes in a Table Component

I have a table bound to a sql-query. I added an additional checkbox-row not bounded to the sql-query. now, I would like to check, which checkboxes are checked.
I used these code-snippets to do so:
http://blogs.sun.com/divas/entry/using_checkboxes_in_a_table
there is written
"Use code like the following to determine which checkboxes are selected."
Iterator rows = getSessionBean1().getSelectedRows().iterator();
while (rows.hasNext()) {
    String rowId = (String) rows.next();
    RowKey rowKey = <your table's data provider>.getRowKey(rowId);
    ... use the row key to access the data in the data provider
}However, I don't understand what <your table's data provider> is and how I should be able to access the data in the provider.
my provider is not related to the checkboxes! Where do I need isSelected()?
Thanks for helping me with this.

Hi there,
Try this
http://blogs.sun.com/winston/entry/single_selectable_row_table_component .
http://blogs.sun.com/winston/entry/multi_column_listbox_table
Thanks
K

Similar Messages

  • Problem with checkbox on table component

    Hello i am having a problem with checkbox in table component
    i am developing something like a shopping cart app and i have a checkbox in my table component , i want users to select items from the checkbox to add to thier cart, They can select the items from cartegory combobox , my problem is when they select the items from the checkbox if they select another category the alread selected once do not display in my collection opbject please how can i maintain the state of the already selected items in my collection object

    Hi,
    Please go through the tutorial "Understanding scope and managed beans". This is available at:
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/scopes.html
    The details of the selected items need to be stored in an object that is in session scope.
    Hope this helps
    Cheers
    Girish

  • How can i uncheck a checkbox in table component on clicking a button

    In my application I have a table component that display data from the database and a submit button outside the table component, the first column in the table component is a checkbox, How can i uncheck the checkbox in the table component when the submit button is clicked?
    Thanks in advance.

    Something like this ... I THINK it will uncheck all checkboxes in table, but I'm not positive ... you can test!
    if checkbox id is checkbox1...
    <script type="text/javascript"><![CDATA[                                         
    function disableCheckbox()
    document.getElementById('form1:checkbox1').selected = false;
    }]]></script>Put above code inside of head tag in JSP View
    NEXT...
    go to Design View and select your button and go to properties section and select onClick property and insert this javascript in dialog...
    setTimeout('disableCheckbox()', 1)Now run the project when you click the button does the checkbox become unselected?
    Anyway this is where I would start...as far as selecting just the first checkbox if there is more than 1 record...I'm not sure...but I'm curious if this works.
    Jason

  • Jsf data table component + print null cell

    I am using the jsf data table component and binding the column values to a backing bean.
    <h:dataTable binding="#{backing_showDifferences.dataTable2}"
    id="dataTable2">
    <h:column binding="#{backing_showDifferences.userColumn1}"/>
    <h:column binding="#{backing_showDifferences.userColumn2}"/>
    <h:column binding="#{backing_showDifferences.userColumn3}"/>
    </h:dataTable>
    - some code from my showDifferences.java
    HtmlOutputText column1Text = new HtmlOutputText();
    vb =
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{users.uclass}");
    column1Text.setValueBinding("value", vb);
    usercolumn1.getChildren().add(column1Text);
    HtmlOutputText column2Text = new HtmlOutputText();
    vb =
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{users.ue1}");
    column2Text.setValueBinding("value", vb);
    usercolumn2.getChildren().add(column2Text);
    HtmlOutputText column3Text = new HtmlOutputText();
    vb =
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{users.ue2}");
    column3Text.setValueBinding("value", vb);
    usercolumn3.getChildren().add(column3Text);
    ResultSetDataModel dataModel = new ResultSetDataModel();
    dataModel.setWrappedData(rs);
    dataTable2.setValue(dataModel);
    The raw HTML:
    <table id="form1:dataTable2" class="iuptable" border="1">
    <thead>
    <tr>
    <th scope="col">Heading 1</th>
    <th scope="col">Heading 2</th>
    <th scope="col">Heading3</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>some data in this column</td>
    <td>X</td>
    <td></td>
    </tr>
    <tr>
    <td>Some more data in this row</td>
    <td>X</td>
    <td></td>
    </tr>
    </tbody>
    </table>
    My problem is this...in the raw HTML the <td></td> tag is not formatted nicely on my table output. I have lines around my entire table and each cell within it. When the <td></td> prints there are no lines. I am new to the JSF table data component, but if I were writing some JSP or servlet code I would check that if value was null I would append an &nbsp to the <td> tag (ex. <td>&nbsp</td>) and the table would be formatted properly. The backing bean that I am binding to is pulling the data from a database table...so my sql looks like this:
    SELECT uclass, ue1, ue2 from table1; my problem is when ue1 or ue2 is a null value.
    Any ideas would be greatly appreciated!

    Hi,
    the h:dataTable belongs to the JSF Reference Implementation from Sun, not to Oracle ADF Faces. The rendering is within this component set and I suggest to report your issue on one of the SUN forums (http://forum.java.sun.com/forum.jspa?forumID=427) as we have no handle to e.g. fix an issue if it exists in the component set.
    Frank

  • Dealing with Check in a table component

    In my application I have a table component that display data from the database and a submit button outside the table component,the first column in the table component is a checkbox ,How can i uncheck the checkbox in the table component when the submit button is clicked?
    Thanks in advance.

    Hi!
    Try to read this:
    http://blogs.sun.com/winston/entry/button_header_table
    I hope it will help You.
    Thanks,
    Roman.

  • Java script error when using a "Table" component (jsc2)

    using a table component, I get a js errors, when lodiing the HTML page, sorting rows etc.
    can some one helpe me or can some one have the same problem ?

    Hi,
    Please post JSC2 related queries at:
    https://feedbackprograms.sun.com/login.html
    Cheers
    Giri

  • Use checkbox to select rows in a af:table

    How to use a checkbox on the first column of a table as row selection control?
    Just like most of the web email client (Yahoo, Hotmail...).
    I am using JDeveloper 11.1.1.2 with Fusion Web Application - ADF.
    The control I am using is a <af:table>.
    Thanks,
    Samson Fu

    The sample you provide is very usefull. But it has some limitations to my working application. It dose not work for tables in clickToEdit mode. User has to click a row in the table to enable the selection checkbox, and the tick the checkbox again to have the row to be selected, if the table is in clickToEdit mode.
    Anyway, that is really a good example. Thank you!
    Regards,
    Samson Fu

  • Using table component,not binding

    Hi all,
    I've been searching info about using the table component
    , adding,deleting,etc programatically, not binding to a Database how the JSC tutorial works.
    The idea is simply:
    - add and remove rows when the user fills a textbox and push a button to add the item.....
    Anyone have an example or a link with examples??
    thanks in advance!

    What I do is create a list with, say, two Person objects then use ObjectListDataProvider's setList(List) method to associate the list with the data provider's list property.
    I create the data provider in a session bean. In the bean's init method I call remove the dummy list items.
    Before you can bind this data provider's list to any components you have to build the project, then close and reopen the project. Otherwise, JSC won't detect the presence of the data provider.
    Here's an example from my program. Note that any package or import beginning with com.cfi.office refers to custom code.
    This first class is the data provider. I added a convenience method clear the list but you don't have to do that.package com.cfi.office.dataproviders;
    import com.cfi.office.schema.tables.Phone;
    import com.sun.data.provider.impl.ObjectListDataProvider;
    import java.util.ArrayList;
    import java.util.List;
    public class PhoneListDataProvider extends ObjectListDataProvider {
        public PhoneListDataProvider() {
            List phoneList = new ArrayList();
            phoneList.add(new Phone("1112223333", "444");
            phoneList.add(new Phone("5556667777", "888");
            this.setList(phoneList);
        public void clearList() {
            this.getList().clear();
            return;
    }This next code fragment is from a session bean.    public void init() {
            super.init();
            try {
                _init();
            } catch (Exception e) {
                log("BidSessionBean Initialization Failure", e);
                throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
            abContactPhoneListDP.clearList();
        private PhoneListDataProvider abContactPhoneListDP = new PhoneListDataProvider();
        public PhoneListDataProvider getAbContactPhoneListDP() {
            return this.abContactPhoneListDP;
        public void setAbContactPhoneListDP(PhoneListDataProvider abContactPhoneListDP) {
            this.abContactPhoneListDP = abContactPhoneListDP;
        }After you build the project, close it and reopen it, you should see the data provider in the binding dialog box.

  • How to use CheckBox in Table to do mulit-selection in Creator2 Update1?

    Hi.
    I put CheckBox(checkbox1) into Table to do a multi-selection effect..
    and I set checkbox1's selected to true to make default selection.
    however checkbox1 doesn't show selected in at Design Time in Creator2 , and also at Runtime in Firefox.
    then I put another CheckBox(checkbox2) outside the Table, and set selected to ture.
    chekcbox2 is default selected both in Designtime and Runtime.
    I am confused about that
    And, more troubles is, I can't know which Row datas were checked.
    I call CheckBox.getSelected(checkbox1.getID()) got NULL.
    I call checkbox1.getSelected() got NULL.
    Then I write a TableDataProvider to handle this Table and always return Boolean.TRUE at selection field
    But still no work.
    Does anyone know how to do multi-selection in Table?
    Thanks a lot.

    Hi,
    I also test RadioBox in Table and set RadioBox named 'rbSelection' , the table is bind to a dataprovider.
    But, It does't work, too.
    I can't get the selection from any API I know in a Button action (outside of Table)
    RadioButton.getSelected(rbSelection.getName())) return null
    rbSelection.getSelectedValue() return true
    rbSelection.getSelected()) return null
    rbSelection.getSubmittedValue()) return null
    tableRowGroup1.getSelectedRowKeys().length size is 0
    But when I use ((HttpServletRequest)this.getFacesContext().getExternalContext().getRequest()).getParameter("rbSelection")
    I can get the correct selection result.
    Is this a Creator2 bug or my mistake?
    THANKS~

  • Table component uses outdated attributes

    The text editor's table plugin [The table component] uses outdated markup for centering items vertically in a table cell:
    It renders: <td valign="middle">
    instead of using the modern:
    <td style="vertical-align:middle">
    This breaks the layout. I need to find out how to update the table plugin for the text editor.
    Anyone knows how to fix this?
    Thanks in advance,
    David

    I got a patch from Adobe support:
    You can do this change in [1] around line 672. You can change it to [3].
    Note that isIE is declared in [2] around line 67. You can remove the setAttribute all together if you want to use style attribute for all browsers.
    [1] /libs/cq/ui/widgets/source/widgets/form/rte/commands/Table.js
    [2] /libs/cq/ui/widgets/source/ext/source/ext-core/src/core/Ext.js
    [3]
    if (config.valign) {
                if (config.valign != noneConfig) {
    com.setAttribute(dom, "valign", config.valign);
                    if (!CQ.Ext.isIE){
    dom.style.verticalAlign = config.valign;
                } else {
    com.removeAttribute(dom, "valign");
                    if (!CQ.Ext.isIE){
    dom.style.verticalAlign = "";
    Regards,
      Pierre Chamoun

  • How feed many record in table component and not use append command again

    hi master
    How I feed Multiple records in table component and not use append and save command again and again
    Same as oracle grid
    I give many record and save one time
    Please give me idea how I add Multiple record and save one time not use append and save command again and again
    Thank�s
    aamir

    Hi!
    appendRow() method just add temporal row. For add them to DB commitChanges() method should be used. So you can use appendRow() method several times, fill every new row and only then use commitChanges() method. In this case all new rows will be added to DB per one time.
    Thanks,
    Roman.

  • Use table component without data provider

    Since it is very difficult to solve the browser "BACK" button problem caused by my data provider, I decide not to use data provider to populate the table.
    Does anyone know some sample code about playing around with the table component without using data provider?
    Thanks in advance,

    Unfortunately, Table Component from basic category does not work with out Data Provider. But Data Table component from standard section works with out data provider. But it does not have the frills and whistles of basic table component.
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • BUG: CheckBox colum inside table (ADF 11.1.2.1)

    I find a bug using CheckBox inside table, this are steps to get the bug.
    1.Create a view object from database table.
    2.Create a where clause in view Object
    3.Create a parameter form (using where clause)
    4.Create a editable table with filter enable
    -- AFTER TEST, ALL WORK
    5. Convert inputText to af:selectBooleanCheckbox
    -- AFTER TEST GET THIS ERROR:
    1- FIlter adf tabla and data is ok.
    2- Apply a filter using parameter form and same time adf:table filter. (Data is not well.)
    As I say this happend only when i change my inputText to af:selectBooleanCheckbox.
    With inputText work well, with booleanCheacBox work bad..
    Someone know if this was fix in 11.1.2.2 ??

    My attribute is not boolean but I fix it in viewRowImplementation accesor:
      public String getProgramada() {
            String dbValue= (String) getAttributeInternal(PROGRAMADA);
            if("S".equals(dbValue))
                retreturn  "true";
            else
                return  "false";       
    public void setProgramada(String value) {
            String valorSeleccionado = null;
            if("true".equals(value))
                valorSeleccionado = "S";
            else
                valorSeleccionado = "N";       
            setAttributeInternal(PROGRAMADA, valorSeleccionado);
        }Seems that change was the problem.. this code work bat generate the BUG i post here.
    SOLUTION:
    1. Revert the viewRowImpl to default accesor.
    2. Modify page definition in tis way using idea from Vinay Agarwal
    <tree IterBinding="VSiriusCorreriasUsuView1Iterator" id="VSiriusCorreriasUsuView1">
          <nodeDefinition DefName="modelo.vistas.VSiriusCorreriasUsuView" Name="VSiriusCorreriasUsuView10">
            <AttrNames>
              <Item Value="Correria"/>
              <Item Value="Descripcion"/>
              <Item Value="Instleer"/>
              <Item Value="Descargadas"/>
              <Item Value="Ejecutadas"/>
              <Item Value="Codusuario"/>
              <Item Value="Codterminal"/>
              <Item Value="Placaveh"/>
              <Item Value="Fechaprog"/>
              <Item Value="Programada" Binds="Programada"/>
            </AttrNames>
          </nodeDefinition>
        </tree>
    <button IterBinding="VSiriusCorreriasUsuView1Iterator" id="Programada" DTSupportsMRU="false" StaticList="true">
          <AttrNames>
            <Item Value="Programada"/>
          </AttrNames>
          <ValueList>
            <Item Value="S"/>
            <Item Value="N"/>
          </ValueList>
        </button>And everything Seems to work Well. Seems to be more easy than add code to accesors in viewRowImpl and work better.
    My checkbox value is get from tree component:
    <af:selectBooleanCheckbox value="#{row.bindings.Programada.inputValue}"
                                                 shortDesc="#{bindings.VSiriusCorreriasUsuView1.hints.Programada.tooltip}"
                                                 id="it7" label="#{bindings.Programada.label}" simple="true" autoSubmit="true">
    </af:selectBooleanCheckbox>

  • Clicking a tree node does not refresh the fields in the table component

    hi all,
    I am using a tree component along with a table component in my page.so whenever i am clicking on a node it should display the relevant information of that node in the table from the database.But whenever i am doing the page is not refreshing and the old values of the textfields in the table still exist.i have written the code to populate the table in a button click event.It is working fine but the same is not working when i am clicking any node in the tree component.Can anyone provide a solution to this problem.
    Thanks and regards,
    Prasant Kumar

    Never mind... I actually found something that works...
    treeModel.nodeStructureChanged(leadSelection);

  • 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

Maybe you are looking for

  • How to get all lines in a paragraph?

    Hey all, I've got a confusing question, see the codes below: tell application "Adobe InDesign CS4"           set doc to open orphan_check           tell doc                     set myPage to page 4                     set myTextFrame to first text fr

  • Facebook logging me out continuously?

    The problem started after I installed the new version of Skype on my mac. This version allows me to log into facebook from skype itself. However, suppose, my mac is on sleep mode, after it wakes up and connects to skype automatically, Safari logs me

  • How to monitor OOM error

    Hello Experts, Periodically I'm having problems with some Enqueue-Locks and Communication Channels JDBC Sender stop processing messages. Perform the procedure in item 29 of the SAP Note "831162 - FAQ: XI 3.0 / 7.0 IP / IP 7.1 JDBC Adapter" Communicat

  • BIG troubles after Security Update 2007-002 (Universal): Apps gone dead!!!!

    After doing the above Update, all ADOBE apps went dead at once. Had to reinstall everything. Same thing happening with Apples iWork. Apps won't start anymore! tried to restore access rights, deleted the prefs but still there is no success. This Updat

  • Can't uninstall JRE.

    I have Windows Vista Home Premium. I'm trying to uninstall the latest version of Java Runtime Environment (Java(TM) 6 Update 13). Whenever I attempt to do so, the green loading bar fills up underneath "Preparing to remove...", and it asks for my admi