EDITING TABLEVIEW

HI EVERYBODY.
I'VE GOT PROBLEM WITH TABLEVIEW I'M USING. BASICALLY I'M ADDING ROWS TO THE TABLEVIEW THROUGH A BUTTON AND INSTEAD OF COMING EMPTY, THEY COME WITH THIS CODE ( ) WHICH IS THE EQUIVALENT OF 'EMPTY' IN HTML, BUT WHAT I REALLY NEED IS AN EMPTY BOX!!
ANY HELP IS REALLY APPRECIATED. MANY THNAKS IN ADVANCE.

never mind... found the answer it's in the super method call.

Similar Messages

  • Editable TableView (similar to Access datasheet)

    What is the easiest way to implement a TableView similar to an Access datasheet in JavaFX 2 with the following features:
    1) all cells are TextAreas and can be edited directly (with the textProperty bound to the data model)
    2) if the text in the TextArea wraps the row height enlarges to fit all the text
    3) one click on a cell selects all text, two clicks will put the curser on the location where the mouse was clicked
    4) tab key will move to the next cell (or next row if in the last column)
    5) an empty row will always exist on the bottom to be used for a new record

    By actually typing some code?
    Come on, you suppossedly know what you want, so start in with it.
    I hope you know JDBC and have at least some experience with JTable, Drag-n-Drop, and other Swing elements. And, of course, at least a working knowledge of POI or JExcel.

  • Javascript validation on editable tableview column

    Hi,
    Sample scenario:
    I have provided users with an option to enter say quantity in an editable column of tableview in all 5-6 rows. Now I want to check if the entered quantity is a numeric field or not.
    Query:
    had it been a single input field I could have written:
    <_script for="Quantity" _event=onchange _type="text/javascript">
    followed bt the required check
    but in this case there is an editable column of a table view and so I am unable to identify the element to write the javascript.
    Please help
    Best Regards,
    Saurabh Tripathi

    Hi Saurabh,
    Use tableView iterator method render_cell_start to define a call a javascript function for validation of entered value.
    Something like...
    case p_column_key
    when 'QTY' .
    IF p_edit_mode is not initial.
    DATA: find type string,
                replace type string.
    DATA: obj_fr type ref to cl_bsp_find_and_replace ,
               obj_bee type ref to cl_bsp_bee_table.
    DATA: qty type ref to cl_htmlb_inputfield.
    find = '<input' .
    replace = `<input on_change="checkQTY(this.value,this.name);" . <--this line of code will call a JS function and pass it                                                                                the value of this field and name of this field.
    obj_fr = cl_bsp_find_and_replace=>factory( find = find
                                                                            replace = replace
                                                                            mode = 'FIRST_OCCURANCE' ) .
    qty = cl_htmlb_inputfied=>factory( id = p_cell_id
                                                            type = 'num'  ) .
    CREATE OBJECT obj_bee.
    obj_bee->add( level = 1 element = obj_fr ) .
    obj_bee->add( level = 2 element = qty ) .
    p_replacement_bee = obj_bee .
    ENDIF.
    Now in the layout of BSP page you define the JS function
    checkQTY(val,name)
    and check the entered value and the name of inputield where it was entered.
    This name of inputfield will change dynamicaly when ever a new row is selected and page is refeshed.
    Regards,
    Anubhav

  • How to change the default KeyBinding of the TableView ?

    how to change the default key binding of the TableView ?
    When press Enter key on a editable TableView, the default action is to make the selceted cell to a editing state. I want to know if there is any way to make it select the right cell and wouldn't change the editing state of the selected cell when i press Enter key.
    here is something i've done.
          table.setOnKeyPressed(new EventHandler<KeyEvent>() {
                   @Override
                   public void handle(KeyEvent e) {;     
                        table.requestFocus();
                        KeyCode code =e.getCode();
                        if(code == KeyCode.ENTER){
                             try {
                                  new Robot().keyPress(java.awt.event.KeyEvent.VK_RIGHT);//XXX
                             } catch (Exception e1) {
    Thanks,
    ahiwoo
    Edited by: 911579 on 2012-2-1 上午3:15
    Edited by: 911579 on 2012-2-1 上午6:26
    Edited by: 911579 on 2012-2-1 上午6:41

    thanks jsmith. now it works well.
         table.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
                   @Override
                   public void handle(KeyEvent e) {
                        table.requestFocus();
                        KeyCode code =e.getCode();
                        if(code == KeyCode.ENTER){
                             try {
                                  new Robot().keyPress(key);//XXX  javafx  has no robot for key type...
                             } catch (Exception e1) {
                             e.consume();
              });

  • Error in receiving tableview data for selected row

    Hi Collegues ,
    We plan to realize an application for the maintanance of  planning data . In the first step we created a value help page by using a tableview with iterator class ( 1 of the 3 methods of the Interface was filled with logic ) . We don't use any controller for that application  .
    A global internal table with the relevant help value data ( fgrvalues ) is used for the tableview and the call is :
    TYPE I .
    +CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
    CLEAR ONCLICKEVENT.
    IF EVENT_ID = CL_HTMLB_MANAGER=>EVENT_ID.
        EVENT_DATA = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
        IF ( EVENT_DATA IS NOT INITIAL ) AND
                ( EVENT_DATA->EVENT_TYPE = 'click' ) .
                ONCLICKEVENT = EVENT_DATA->SERVER_EVENT .
        ENDIF.
    ENDIF.+
    CASE ONCLICKEVENT.
    WHEN 'take' .
       TABLE ?= CL_HTMLB_MANAGER=>GET_DATA( REQUEST = REQUEST
       NAME = 'tableView'
       ID = 'fgr1_vhelp' ) .
       TABLE_EVENT = TABLE->DATA.
       IF TABLE_EVENT->SELECTEDROWINDEX IS NOT INITIAL.
          ROWSELECTION = TABLE_EVENT->SELECTEDROWINDEX.  
    -> ROWSELECTION - Content is now the index of the selected tableview row
    We always get the selected row in TABLE_EVENT->SELECTEDROWINDEX and the table TABLE_EVENT->ALLCOLUMNNAMES filled ( column ZX_FGR1 is the 2nd column ) 
    but we never got the tableview data for that tableview row no matter what we tried . We tried it with a tableview-event fired on 'rowselection' by user line-selection . We have deactivated the iterator or changed the BPS design value . With the same result - nothing was given back .
    We found that the System-Call Return value of :
    +system-call ict
    did
    ihttp_scid_get_form_field
    parameters
    m_c_msg " > c handle
    name " > form field name                value " < form field value
                    m_last_error. " < return code+
    in the method IF_HTTP_ENTITY~GET_FORM_FIELD is empty .  M_LAST_ERROR occurs with value '20' .
      + ASSIGN ROWSELECTION TO .
    COLUMN_VALUE = TABLE_EVENT->GET_CELL_VALUE( ROW_INDEX =
    COLUMN_INDEX = '2' ). -> Column Value is empty !!+
       +CALL METHOD TABLE_EVENT->GET_CELL_VALUE
          EXPORTING
            ROW_INDEX = TABLE_EVENT->SELECTEDROWINDEX
            COLUMN_INDEX = '2'
          RECEIVING
            VALUE = COLUMN_VALUE -> Column Value is empty !!+
       +CALL METHOD TABLE_EVENT->GET_SIMPLE_DATA ....
             -> Column Value is empty !!+ *----
    What could be the reason for that problem ? In generally it must be possible somehow to read the tableview data for one or all rows of the mentioned tableview .
    We hope that someone can help and are very thankful for a hint or solution . If you need more details please let us know .
    Please Remark: It's no solution for us to read the data by using the created internal table fgrvalues and the selectedrowindex cause in a later step we plan to update an ODS table with the manual modified planning data of an editable tableview .
    Thanks a lot in advance
    Dirk Läufer

    Hi collegues ,
    It's done .
    After we've got a very helpful little hint from Brian :
    The <htmlb:tableView> renders a table to the browser. It does not keep a copy of the table. The browser will also never return the table. Never. What it can return are inputfields for each cell. But then only if each cell is custom rendered as an inputfield.
    we could certainly solve the problem .
    We set the field we want to get back from table view on not editable inputfield via the tableview-iterator method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START :
    DATA: LCL_TABLE       TYPE REF TO CL_BSP_BEE_TABLE   ,
          LCL_INPUTFIELD2 TYPE REF TO CL_HTMLB_INPUTFIELD .
    CASE P_COLUMN_KEY .
    WHEN 'ZX_FGR1'.
    *    Field Firm Group
         CREATE OBJECT LCL_INPUTFIELD2.
         LCL_INPUTFIELD2->ID        = P_CELL_ID.
         LCL_INPUTFIELD2->WIDTH     = '100%'.
         LCL_INPUTFIELD2->MAXLENGTH = 4.
         LCL_INPUTFIELD2->TYPE      = 'STRING'.
         LCL_INPUTFIELD2->DESIGN    = 'STANDARD'.
         LCL_INPUTFIELD2->DISABLED  = 'TRUE'.
         LCL_INPUTFIELD2->VALUE =
             GET_COLUMN_VALUE( COLUMN_NAME = 'ZX_FGR1').
         P_REPLACEMENT_BEE     = LCL_INPUTFIELD2 .
    Now the method in OnInputPorcessing:
    TRY.
          CALL METHOD CL_HTMLB_MANAGER=>GET_SIMPLE_DATA
              EXPORTING
                REQUEST       = RUNTIME->SERVER->REQUEST
                ID            = 'fgr1_vhelp'
                ROW_IDX       = TABLE_EVENT->SELECTEDROWINDEX
                COL_NAME      = 'ZX_FGR1'
              CHANGING
                DATA          = FGRVALUES_LINE-ZX_FGR1 .
             IF NOT FGRVALUES_LINE-ZX_FGR1  IS INITIAL.
    *                 selektierte Firmengruppe übernehmen
                      ZX_FGR1     = FGRVALUES_LINE-ZX_FGR1   .
                      CALL METHOD NAVIGATION->SET_PARAMETER
                            EXPORTING NAME  = 'ZX_FGR1'
                                      VALUE = ZX_FGR1.
             ENDIF.
          CATCH CX_SY_CONVERSION_ERROR .
       ENDTRY.
    works properly as it should be ...
    An enormous Thanksgiving to you , Brian !!!!

  • Checkbox cell factory + Tableview

    I'm writing a JavaFX client for my soap service, and of my fxml pages must contain a fully-editable TableView, which consists of Product-class entities.My table consists now of 2 text columns and one, which consists of Double values.I want to add a selection column with CheckBox items in it cells.Using a Ensemble demo app I extended a Cell class for using a CheckBoxes :
    public class CheckBoxCell<S, T> extends TableCell<S, T> {
    private final CheckBox checkBox;
    private ObservableValue<T> ov;
    public CheckBoxCell() {
        this.checkBox = new CheckBox();
        this.checkBox.setAlignment(Pos.CENTER);
        setAlignment(Pos.CENTER);
        setGraphic(checkBox);
    @Override
    public void updateItem(T item, boolean empty) {
        super.updateItem(item, empty);
        if (empty) {
            setText(null);
            setGraphic(null);
        } else {
            setGraphic(checkBox);
            if (ov instanceof BooleanProperty) {
                checkBox.selectedProperty().unbindBidirectional((BooleanProperty) ov);
            ov = getTableColumn().getCellObservableValue(getIndex());
            if (ov instanceof BooleanProperty) {
                checkBox.selectedProperty().bindBidirectional((BooleanProperty) ov);
    @Override
    public void startEdit() {
        super.startEdit();
        if (isEmpty()) {
            return;
        checkBox.setDisable(false);
        checkBox.requestFocus();
    @Override
    public void cancelEdit() {
        super.cancelEdit();
        checkBox.setDisable(true);
    }Then in fxml view controller class I set a cellFactory for requed TableColumn :
    private Callback<TableColumn, TableCell> createCheckBoxCellFactory() {
        Callback<TableColumn, TableCell> cellFactory = new Callback<TableColumn, TableCell>  () {
            @Override
            public TableCell call(TableColumn p) {
                return new CheckBoxCell();
        return cellFactory;
    products_table_remove.setCellFactory(createCheckBoxCellFactory());My question is :
    1) how to fill this column with unchecked CheckBoxes using PropertyValueFactory if i have
    private final ObservableList <Boolean> productsToRemove= FXCollections.observableArrayList();consists of Boolean.FALSE values then view is created. (TableView consists of Product class that does'nt have a Boolean property (only 3 String and one Double property)) ?
    2) Can i get acess to Product object, which contain selected row using EventHandler :
    private void setProductDescColumnCellHandler() {
        products_table_remove.setOnEditCommit(new EventHandler() {
            @Override
            public void handle(CellEditEvent t) {
            ...I saw a lot of examples with Entites, which have a Boolean field.In my case, i dont want to add boolean field to jax-ws generated classes.

    Thanks for advice. I decided to create a Product wrapper class like so :
    public class ProductWrapper extends Product {
        public ProductWrapper(Product product) {
            _product = product;
        final Product _product;
        Boolean to_delete = false;
        public Boolean getTo_delete() {
            return to_delete;
        public void setDelected(Boolean _delected) {
            this.to_delete = _delected;
        public double getCost() {
            return _product.getCost();
        public void setCost(double value) {
            _product.setCost(value);
        public String getDescription() {
            return _product.getDescription();
        public void setDescription(String value) {
            _product.setDescription(value);
        public String getName() {
            return _product.getName();
        public void setName(String value) {
            _product.setName(value);
        public Product getProduct() {
            return _product;
        public Boolean getDelected() {
            return to_delete;
    }Then I use this wrapper in all factories :
    products_table_remove.setCellValueFactory(new PropertyValueFactory<ProductWrapper, Boolean>("to_delete"));
    products_table_remove.setCellFactory(createCheckBoxCellFactory());
    private void setProductDeleteCellHandler() {
            products_table_remove.setOnEditStart(new EventHandler<CellEditEvent<ProductWrapper, Boolean>>() {
                @Override
                public void handle(CellEditEvent<ProductWrapper, Boolean> t) {
                    System.out.println("Checked");
    }My question - how to bind CheckBox click event to setProductDeleteCellHandler() method using that CheckBoxCell class :
    public class CheckBoxCell<S, T> extends TableCell<S, T> {
    private final CheckBox checkBox;
    private ObservableValue<T> ov;
    public CheckBoxCell() {
        this.checkBox = new CheckBox();
        this.checkBox.setAlignment(Pos.CENTER);
        setAlignment(Pos.CENTER);
        setGraphic(checkBox);
    @Override
    public void updateItem(T item, boolean empty) {
        super.updateItem(item, empty);
        if (empty) {
            setText(null);
            setGraphic(null);
        } else {
            setGraphic(checkBox);
            if (ov instanceof BooleanProperty) {
                checkBox.selectedProperty().unbindBidirectional((BooleanProperty) ov);
            ov = getTableColumn().getCellObservableValue(getIndex());
            if (ov instanceof BooleanProperty) {
                checkBox.selectedProperty().bindBidirectional((BooleanProperty) ov);
    @Override
    public void startEdit() {
        super.startEdit();
        if (isEmpty()) {
            return;
        checkBox.setDisable(false);
        checkBox.requestFocus();
    @Override
    public void cancelEdit() {
        super.cancelEdit();
        checkBox.setDisable(true);
    }

  • Calling javascript function at tableview

    Hi all,
    I have a tableview on my screen( not using iterator).
    I want to call a clientSide event on clicking on a particular cell of the table..I need something like onClientClick for buttons, for my tableview cells.
    How can this be done ? Please suggest.
    Thanks&regards
    Ananya

    i assume that is is non-editable tableview.
    write the following code in onmanipulation event to trigger javascript for 3rd column in the 2nd row.
    data: replace_string type string .
    clear replace_string .
    call method runtime->server->response->get_cdata
       receiving
         data = replace_string.
         replace all occurrences of 'cc="3" rr="2"' in replace_string with 'cc="3" rr="2" onmousedown="alert(this.innerText);"'.
    if sy-subrc eq 0 .
    runtime->server->response->set_cdata( replace_string ).
    endif .
    Note: do this at your own risk, as this method works on modifying the rendered html of BSP elements. if the rendering mechanicsm by SAP changes this may not work.
    Regards
    Raja

  • Display of missing values in a table view.

    Hi everyone,
    I have a table view with 7 columns and 10 rows which displays only those values which are missing in the DataBase Table.
    Is it possible to show only the missing values as '-' in a table view, the table view is having 7 different fields.
    Also when the value is inserted at run time the corresponding field should be updated accordingly and the value will no longer be displayed in the table view as '-'
    please advice.
    Regards
    Neo.

    Welcome to SDN.
    do you mean to say that in some rows some column values will be blank and you want to replace the blanks with '-'.
    loop thru the itab which you are passing to tableview and for the blank cells pass '-'.
    <i>Also when the value is inserted at run time</i>
    so you are having editable tableview. to update the value back to the dbtable, you have to read it in oninputprocessing and update it to dbtable .
    search the forum on how to read the user entered value from the table view so that you can update the dbtable.
    Regards
    Raja

  • Table View in FXML

    Hi,
    One of my requirements is to build Table, populate it and make it editable in fxml. I found quite an extensive resource about TableView Component in Javafx 2.0 UI Controls. However, I didn't find anything about doing so in fxml.
    Can someone suggest me how to build, populate and edit TableView Component in FXML.
    Thanks in Advance

    You create a TableView much as you would any other component in FXML. Just use the classname as the XML tag and then the attributes of the class can be set via XML properties and subnodes.
    For example:
        <TableView>
          <columns>
            <TableColumn text="Col 1"/>
            <TableColumn text="Col 2"/>
          </columns>
          <items>
          </items>
        </TableView>You typically woudn't set items in the FXML however, you would normally want this to be driven by the controller (which typically loads the data from somewhere).
    See how you go with that and if you get stuck post back with some more specific questions, and some attempts at coding it yourself based on the above tips.
    Cheers,
    zonski

  • Display Scientific Notation values in columns

    Hi,
    I have a column in a table that apparently displays the values in
    Scientific Notation. That is, the value in each column is always
    displayed as "6.4211E+15". Each value in this column should be a
    unique or different value. If I type "select * from <table_name>
    where <column_name> != 6.4211E+15;", I still get every row in
    this table. Is there a way to display the full value of this
    column so that I can view the unique value for each of these
    rows? If so, how does one accomplish this?
    Thank you,

    Welcome to SDN.
    do you mean to say that in some rows some column values will be blank and you want to replace the blanks with '-'.
    loop thru the itab which you are passing to tableview and for the blank cells pass '-'.
    <i>Also when the value is inserted at run time</i>
    so you are having editable tableview. to update the value back to the dbtable, you have to read it in oninputprocessing and update it to dbtable .
    search the forum on how to read the user entered value from the table view so that you can update the dbtable.
    Regards
    Raja

  • Hi, How to stop the open new view when i click button in OnClick event

    Hi,
    I have the popup window[window.showodelDialog] with one button called confirm.and table control values
    Actual requirement: when i click confirm button it saves the tablecontrol value in the internal table. it is fine.It saves.
    Currently working is : When i click the confirm button in the onClick event ,the new view is opening with empty tablecontrol popupin the new window.I don't want that one.
    my requirement is: When i click the confirm button through onclick event ,i want to close the currently showing popupwindow and it should come to main page.How to do that?
    view1.htm
    =======
       <htmlb:button id            = "sub1"
            onClick =""
            text          = "Confirm" />
    Do_handle_data
    ============
      LOOP AT lt_form_fields INTO lw_form_field WHERE name CS
                                              't_confirm' .
        CALL METHOD /ds1/cl_mdm_tablecontrol=>populate_table(
                       EXPORTING
                         im_id      = 't_confirm'
                         im_request = me->request
                       CHANGING
                       ch_table   = me->r_asset_data->t_maintain ).
        EXIT.
        ENDLOOP.
    t_maintain it stores the changed values.. It is fine..

    Hi raja,
    1.I have a main page like req_asset_create.htm. In this page one button called maintain. If i click the maintain button the popup window is opening using window.showModelDialog. 
    2. In this popup i have a Editable tableview and one button called confirm. User can edit the values. After editing he is clicking the confirm button.
    3.when he click the confirm button two things should happen a)Popup should vanish and it should go to main page ie req_asset_create.htm.The editrd values should store in to the internal table (t_maintain).it is in model class.
    What heppenings for me using this code
    =============================
    <%----
    confirm -
    --%>
        <htmlb:button id            = "con"
            onClientClick = "self.close();"
            text          = "confirm"
            onClick       = "confirm"/>
    When i click the confirm button ->popup is closing ->thats 100% fine and again one new view is coming with popupdisplay values.This should not happen.
    a)The server event is not happening.It should happen.
    b) The edited values are not stored in the internal table..
    Do_handle_data : for storing the edited tableview values
    ===========   
    confirm
      LOOP AT lt_form_fields INTO lw_form_field WHERE name CS
                                              'con' .
        CALL METHOD /ds1/cl_mdm_tablecontrol=>populate_table(
                       EXPORTING
                         im_id      = 'tv1'
                         im_request = me->request
                       CHANGING
                       ch_table   = me->r_asset_data->t_maintain ).
        EXIT.
        ENDLOOP.
    What should i do to happen for the server event to update the edited records.
    How can i achieve? ow to control the new opening view?

  • How to get editable value from thtmlb:tableView

    Hi,
    I create a tableview using tag thtmlb:tableView and set column editable. Now the value in the tableview can be changed, but I don't know how to get the changed value from tableview. Pls help me.
    thanks in advance!

    Hi,
    You can get the collection of the context node and any line of the table is an entity in the context node.
    If it is not helpfull try to find a table called 'table' or 'tableview', maye it's an attribute in your context node.
    Best regards,
    Caíque Escaler

  • Issue with editable cell of a tableVIew...

    Hi All,
    I have a tableView with 4 fields, one of the fields QUANTITY is editable .
    Now for ex. if there are 5 rows in the TV , if the user selects all 5 and then enters value for QUANTITY field and clicks on the SUBMIT button , the user is navigated to the next page and i can capture these values in my itab,
    but if the user selects one row and enters value for QUANTITY field  and then selects the second row , ROWSELECTION event is triggered and the page is refreshed ,
    so when the page is displayed agan the value enterd in the QUANTITY field for previous row  is gone and the fiels becomes blank.
    how to show the value for this field , after the page is displayed again after refreshing????
    Thanks,
    Anubhav.

    Hi Raja,
    I really cantfigure out how to solve my isuue using your code.
    The code for my TV is:
    <htmlb:tableView             id              = "material"
                                               headerText      = "Materials"
                                               headerVisible   = "true"
                                               design          = "alternating"
                                               visibleRowCount = "10"
                                               fillUpEmptyRows = "true"
                                               onRowSelection  = "MyEventRowSelection"
                                               selectionMode   = "MULTILINEEDIT"
                                               table           = "<%= itab_materials %>" >
                              <htmlb:tableViewColumns>
                                  <htmlb:tableViewColumn columnName="MATNR" title="Material Number" width="150">
                                  </htmlb:tableViewColumn>
                                  <htmlb:tableViewColumn columnName="MAKTG" title="DESCRIPTION" width="200">
                                  </htmlb:tableViewColumn>
                                  <htmlb:tableViewColumn columnName="VERPR" title="PRICE" width="150">
                                  </htmlb:tableViewColumn>
                                  <htmlb:tableViewColumn columnName="QUNTY" title="QUANTITY" edit="TRUE" width="200">
                                  </htmlb:tableViewColumn>
                                  <htmlb:tableViewColumn columnName="MEINS" title="UNIT" width="150">
                                  </htmlb:tableViewColumn>
                              </htmlb:tableViewColumns>
                           </htmlb:tableView>
    ITAB_MATERIALS has folowing fields:
    MATNR
    MEINS
    MAKTG
    VERPR
    How to capture the value of FIFTH field QUANTITY and display it when the next row is selected and the page is refrehsed?
    Thanks,
    ANubhav.

  • TableView.edit() is not working in JavaFX 2.1

    Hi All,
    Yesterday i have updated my javafx installation from JavaFX 2.0.2 to JavaFX 2.1 b07
    After that I am facing issues with TableView.edit() method. It stops working and not making the cell as editable.
    In the below example , select the first cell, and on click of 'tab' , the next cell is changed to editing state..and goes on for all the cells. If it reaches the end column, the first cell of the next row is selected.
    You can find the sscce example below. The same code is working well in 2.0.2 build.
    import javafx.application.Application;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.event.EventHandler;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.input.KeyCode;
    import javafx.scene.input.KeyEvent;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    import com.sun.javafx.scene.control.skin.TableRowSkin;
    public class StartEditDemo extends Application {
        public static void main(String[] args) {
            Application.launch(args);
        public void start(Stage primaryStage) {
            primaryStage.setTitle("Start Edit Test");
            StackPane root = new StackPane();
            Scene scene = new Scene(root, 600, 150);
            primaryStage.setScene(scene);
            primaryStage.show();
            configureTable(root);
         private void configureTable(StackPane root) {
              final ObservableList<MyDomain> data = FXCollections.observableArrayList(
                         new MyDomain("Apple","This is a fruit","Red"),
                         new MyDomain("PineApple","This is also a fruit","Yellow"),
                         new MyDomain("Potato","This is a vegetable","Brown")
              TableView<MyDomain> table = new TableView<MyDomain>();
              TableColumn<MyDomain,String> titleColumn = new TableColumn<MyDomain,String>("Name");
              titleColumn.setPrefWidth(150);
              titleColumn.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("name"));
              titleColumn.setCellFactory(getEditableCallBack(1));
              TableColumn<MyDomain,String> descCol = new TableColumn<MyDomain,String>("Description");
              descCol.setPrefWidth(150);
              descCol.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("description"));
              descCol.setCellFactory(getEditableCallBack(2));
              TableColumn<MyDomain,String> colorCol = new TableColumn<MyDomain,String>("Color");
              colorCol.setPrefWidth(150);
              colorCol.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("color"));
              colorCol.setCellFactory(getEditableCallBack(0));
              table.getColumns().addAll(titleColumn,descCol,colorCol);
              table.setItems(data);
              root.getChildren().add(table);
         private Callback<TableColumn<MyDomain, String>, TableCell<MyDomain, String>> getEditableCallBack(final int nextColumn) {
              /* Cell factory call back object */
              return new Callback<TableColumn<MyDomain, String>, TableCell<MyDomain, String>>() {
                   @Override
                   public TableCell<MyDomain, String> call(TableColumn<MyDomain, String> p) {
                        return new EditableCell<MyDomain>(nextColumn);
         public class EditableCell<T> extends TableCell<T, String> {
              private TextField textBox;
              private Label label;
              private int nextCol;
              public EditableCell(int nextcolumn) {
                   this.label = new Label();
                   this.nextCol = nextcolumn;
                   /* Enabling to get the edit cell on single mouse click over the cell. */
                   this.setOnMouseClicked(new EventHandler<MouseEvent>() {
                        @Override
                        public void handle(MouseEvent event) {
                             startEdit();
              @Override
              public void startEdit() {
                   super.startEdit();
                   if (isEmpty()) {
                        return;
                   if (textBox == null) {
                        createTextBox();
                   } else {
                        textBox.setText(getItem());
                   setGraphic(textBox);
                   textBox.requestFocus();
                   textBox.selectAll();
                   setEditable(true);
              @Override
              public void updateItem(String item, boolean empty) {
                   super.updateItem(item, empty);
                   if (!isEmpty()) {
                        if (textBox != null) {
                             textBox.setText(item);
                        label.setText(item);
                        setGraphic(label);
              private void createTextBox() {
                   textBox = new TextField(getItem());
                   /* On focus of the textbox, selecting the row.*/
                   textBox.focusedProperty().addListener(new ChangeListener<Boolean>() {
                        @Override
                        public void changed(ObservableValue<? extends Boolean> paramObservableValue,Boolean paramT1, Boolean paramT2) {
                             if(paramT2){
                                  EditableCell.this.getTableView().getSelectionModel().select(EditableCell.this.getIndex());
                   textBox.setOnKeyReleased(new EventHandler<KeyEvent>() {
                        @Override
                        public void handle(KeyEvent t) {
                             if (t.getCode() == KeyCode.ENTER) {
                                  callAction();
                             } else if (t.getCode() == KeyCode.ESCAPE) {
                                  cancelEdit();
                   textBox.setOnKeyPressed(new EventHandler<KeyEvent>() {
                        @Override
                        public void handle(KeyEvent t) {
                             if (t.getCode() == KeyCode.TAB){
                                  if(nextCol!=0){
                                       // Making the next as editable and focused.
                                       TableColumn nextColumn = getTableView().getColumns().get(nextCol);
                                       getTableView().edit(getTableRow().getIndex(), nextColumn);
                                       getTableView().getFocusModel().focus(getTableRow().getIndex(), nextColumn);
                                  }else{
                                       // Making the next row as editable.
                                       if(getTableRow().getIndex()<getTableView().getItems().size()){
                                            TableColumn nextColumn = getTableView().getColumns().get(0);
                                            getTableView().edit(getTableRow().getIndex()+1, nextColumn);
                                            getTableView().getFocusModel().focus(getTableRow().getIndex()+1, nextColumn);
              @Override
              public void cancelEdit() {
                   super.cancelEdit();
                   textBox = null;
                   setGraphic(label);
              @Override
              public void commitEdit(String t) {
                   super.commitEdit(t);
                   setItem(t);
                   textBox = null;
                   label.setText(t);
                   setGraphic(label);
              @SuppressWarnings("rawtypes")
              public ObservableList<Node> getAllCellsOfSameRow(TableCell cell) {
                   TableRowSkin rowSkin = (TableRowSkin) cell.getParent();
                   return rowSkin.getChildren();
              public void callAction() {
                   TableRowSkin<T> rowSkin = (TableRowSkin<T>) this.getParent();
                   ObservableList<Node> cells = rowSkin.getChildren();
                   for (Node node : cells) {
                        EditableCell<T> cell = (EditableCell<T>) node;
                        cell.commitEdit(cell.getTextBox().getText());
              public TextField getTextBox() {
                   return this.textBox;
              public Label getLabel() {
                   return this.label;
         public class MyDomain{
              private SimpleStringProperty name = new SimpleStringProperty();
              private SimpleStringProperty description = new SimpleStringProperty();
              private SimpleStringProperty color = new SimpleStringProperty();
              public MyDomain(String name, String desc, String color){
                   this.name.set(name);
                   this.description.set(desc);
                   this.color.set(color);
              public String getDescription() {
                 return description.get();
              public SimpleStringProperty descriptionProperty(){
                  return description;
             public String getName() {
                 return name.get();
             public SimpleStringProperty nameProperty(){
                  return name;
             public String getColor() {
                 return color.get();
             public SimpleStringProperty colorProperty(){
                  return color;
    }Regards,
    Sai Pradeep Dandem.

    As jsmith notes, the best place to report bugs is directly into the Jira tracker at http://javafx-jira.kenai.com. If you put it in the 'runtime' area against the 'controls' component, it'll end up on my plate.
    Thanks!
    Jonathan

  • How to save a row edited in the tableview

    Hi All
    I have implemented a flow logic based BSP table maintenance page as follows to display and maintain the data in SFLIGHTS table:
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page>
        <htmlb:form>
          <htmlb:tableView id              = "tv1"
                           visibleRowCount = "10"
                           selectionMode   = "lineEdit"
                           table           = "<%= flights %>"
                           filter = "SERVER"
                           sort = "server"
                           iterator        = "<%= iterator %>" />
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    When I click on the row and edit the row and exit the edit mode I still do not see the data that I changed is not reflected back when I exit the edit mode nor it is saved in the database table. Can you please kindly share the code how I can make only the following columns editable:
    FLDATE
    PRICE
    CURRENCY
    PLANETYPE
    the rest of the columns I want to disable for editing and whatever the changed data in these columns I want to reflect it back to the database table.
    Please kindly share the code for implementing to capture what was edited and save it back to the database table
    Thanks
    Karen

    Pls search this forum, this has been discussed N number of times.
    Raja

Maybe you are looking for