TableView with dynamic and updatable columns

Hello!!

Im trying to encode a TableView with dynamic columns and I saw a lot of examples like this: create columns dynamically

But none who would work for my needs.

Its very simple:

I got a list of customers, and each has a list of purchases.

A purchase has a string "buyDetail" and a Date for the ship.

My TableView need the first column with the name of the client, and a column more for each day of existing ships.

We do not know previously days that will be used.

If the sum is greater than 100, for example, I need to be able to apply different styles.

Example:

Customer 02/01/2015 03/01/2015 09/01/2015
Morgan$400 (buyDetail)0$100
Luis00$20
Steven$1000
Hulk0$5$32

I can't use the properties because I don't know how to buy will have to each customer.

My best test (only for the first column) was next, but I can't buy it updated if I change the value in the cell:

I did not try to write other code columns because I feel that I don't hurt really...

This shows the names of Customer´s, but I can't manage if data modification.

table = new TableView<Customer>();
ObservableList<Customer> lista = FXCollections.observableList(registros);

table.setItems(lista);

TableColumn<Customer, Customer> customerNameColumn = new TableColumn<Customer, Customer>("");
  customerNameColumn.setCellValueFactory(new Callback<CellDataFeatures<Customer, Customer>, ObservableValue<Customer>>() {
  public ObservableValue<Customer> call(CellDataFeatures<Customer, Customer> p) {
  return new SimpleObjectProperty(p.getValue());
  }
  });

  customerNameColumn.setCellFactory(column -> {return new TableCell<Customer, Customer>() {
  @Override
  protected void updateItem(Customer item, boolean empty) {
  super.updateItem(item, empty);

  if (item == null || empty) {
  } else {
  setText(item.getName());
  //APPLY STYLE
  }
  }
  };
  });

  table.getColumns().addAll(customerNameColumn);

Post edited by: user13425433

The columns are available already update default... If you happen to use JavaFX properties for the value of the source.

The core of you're your question lies in your cellValueFactory.

Here we have only the cellValueFactory for the name, not for the other columns. So I'll take the name for example, and you have to adapt to the other columns.

But if you do something like this to your cellValueFactory:

new SimpleObjectProperty(p.getValue().getName());

Then the name can never be updated if it modifies the client instance: there is no "link" between the name and the property used by the table.

We have therefore 3 test case:

  • If the name is a property of JavaFX and you do something like:
TableColumn customerNameColumn = new TableColumn("Customer");
customerNameColumn .setCellValueFactory(new PropertyValueFactory<>("name"));

Then, if the name change pending Customer-> value in the table automatically changes.

It also works the other way around: If the table is editable, and the name property is not unalterable-> the value of the changes of names in the Customer instance follows the table has been changed.

  • Now, if your name is not a property of JavaFX but a Java Bean observable property instead (this means that you can register and unregister an instance of Java Bean PropertyChangeListener to this property), you can do:
TableColumn customerNameColumn = new TableColumn("Customer");
customerNameColumn.setCellValueFactory(new Callback, ObservableValue>() {
    @Override
    public ObservableValue call(TableColumn.CellDataFeatures p) {
        final Customer t = p.getValue();
        try {
            return JavaBeanStringPropertyBuilder.create().bean(t).name("name").build();
        } catch (NoSuchMethodException ex) {
            // Log that.
            return null;
        }
    }
});

In this way, you have created a JavaFX property that is bound to an observable property Java Bean.

Same as above, it works both ways when possible.

  • The latter case is that your name is neither a JavaFX property or a Java Bean-> you can not update unless you happen to create a kind of observer/listener that can update the property with the most recent value.

Something like that:

TableColumn customerNameColumn = new TableColumn("Customer");
customerNameColumn.setCellValueFactory(new Callback ObservableValue>() {
  public ObservableValue call(CellDataFeatures p) {
    final Customer t = p.getValue();
    final SimpleStringProperty result = new SimpleStringProperty ();
    result.setvalue(t.getName());
    t.addNameChangeListener(new NameChangeListener() {
      @Override
      public void nameChanged() {
        result.setvalue(t.getName());
      }
    });
    return result;
  }
});

If you don't do something like that, the value of the table will never change when the name changes in the instance because the table does not change.

Now, you will need to apply this theory to your price columns. I hope that I was clear enough to help you.

Tags: Java

Similar Questions

  • having problem to connect with itunes and update my iphone

    I have problem to connect with itunes and update my iphone. Everyone that nows how to fix this?

    What do you mean by communicating with itunes?

    In any case, ask in the Forums of Apple:
    https://discussions.Apple.com/index.jspa

  • How to modify the data with dynamic TableView with dynamic columns in JAVAFX

    Today, it is the demo to display the data from the CSV to the custom class without doing DAT file on tableView in JavaFX 2.0. I call this TableView as dynamic TableView because the tableview automatically manages the columns and rows.
    My research on the editable on tableView, we have a custom of the class and apply it to tableView to show that this demo is > http://docs.oracle.com/javafx/2/ui_controls/table-view.htm

    But in this case I can't do that because we don't know how many example of column with the csv file or .dat file... I want to make editable on this tableView in this case add TextField in the TableCell. How do custom class (because you don't have how column...) and so to do custom class then what thedesign of a custom for this case class?

    Could you please help me?

    It's the demo of code to display your csv or dat file in TableView

    private void getDataDetailWithDynamic() {
      tblView
    .getItems().clear();
      tblView
    .getColumns().clear();
      tblView
    .setPlaceholder(new Label("Loading..."));
      
    // @Override



      
    try {
           
    File aFile = new File(txtFilePath.getText());
           
    InputStream is = new BufferedInputStream(new FileInputStream(aFile));
           
    Reader reader = new InputStreamReader(is, "UTF-8");

           
    BufferedReader in = new BufferedReader(reader);

           
    final String headerLine = in.readLine();
           
    final String[] headerValues = headerLine.split("\t");
           
    for (int column = 0; column < headerValues.length; column++) {
                 tblView
    .getColumns().add(
                 createColumn
    (column, headerValues[column]));
           
    }

           
    // Data:

           
    String dataLine;
           
    while ((dataLine = in.readLine()) != null) {
                
    final String[] dataValues = dataLine.split("\t");
                
    // Add additional columns if necessary:
                
    for (int columnIndex = tblView.getColumns().size(); columnIndex < dataValues.length; columnIndex++) {
                      tblView
    .getColumns().add(createColumn(columnIndex, ""));
                
    }
                
    // Add data to table:
                
    ObservableList<StringProperty> data = FXCollections.observableArrayList();
                
    for (String value : dataValues) {
                     data
    .add(new SimpleStringProperty(value));
                
    }
                 tblView
    .getItems().add(data);
           
    }
      
    } catch (Exception ex) {
           
    System.out.println("ex: " + ex.toString());
      
    }


      
    for(int i=0; i<tblView.getColumns().size(); i++) {
           
    TableColumn col = (TableColumn)tblView.getColumns().get(i);
           col
    .setPrefWidth(70);
      
    }
    }

    private TableColumn createColumn(
      
    final int columnIndex, String columnTitle) {
           
    TableColumn column = new TableColumn(DefaultVars.BLANK_CHARACTER);
           
    String title;
           
    if (columnTitle == null || columnTitle.trim().length() == 0) {
                title
    = "Column " + (columnIndex + 1);
           
    } else {
                title
    = columnTitle;
           
    }


           
    Callback<TableColumn, TableCell> cellFactory = new Callback<TableColumn, TableCell>() {
           
    @Override
           
    public TableCell call(TableColumn p) {

                
    System.out.println("event cell");
                
    EditingCellData cellExtend = new EditingCellData();
                
    return cellExtend;
           
    }
      
    };

      column
    .setText(title);
      column
    .setCellValueFactory(cellFactory);
      
    return column;
    }


    Thanks for your reading.

    See this thread: Re: dynamically create columns

    This example is not editable, but to do so, simply add something like

        column.setCellFactory(TextFieldTableCell.>forTableColumn());
    

    the createTableColumn (...) method.

    Either said by the way, where did you code that you pasted in your post? It looks like in my previous post.

    Post edited by: James_D

  • Core 2 Duo Dimension 5150 with 0HJ054 and updated BIOS?

    Hello

    I know F1 and so on, but I got the 0 H 054 motherboard with the chipset 945G (which is suitable for the core 2 Duo) and a Pentium D 820 2.8 GHz and I would like to install a core 2 duo e4700 2.6 GHz with. Is it possible wit a BIOS updated to A07 (A04 and A05 said: it s what makes it possible to use newer processors...)
    Message edited by halali on 2008-09-30 11:57

  • Problems with payments and update Photoshop CC, CC with Lightroom and Bridge

    I installed on my Mac Pro 13 "retina package Photoshop CC, CC of Lightroom and Bridge. In November I started to receive information about problems with the payment and the request for Adobe to confirm the address and method of payment. Done by me already 3 times but still I find myself with this present message and even though I have bills confim me the subscription is paid every month, this request does not allow me update programs. Also, but maybe it's a consequence of the described problem, whenever I try to update Photoshop, Lightroom, and Bridge, I asked to enter the I Word cloud of past, which is not accepted and I don't know how to solve this problem.

    When you install or update programs will ask you your COMPUTER password, so that your operating system knows that you are authorized to make changes

    The problems of payment needs to talk to Adobe... This is an open forum, not a direct link to the Adobe support

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">
    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html
    -or by phone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • NLSSORT function not used with CHAR and VARCHAR2 column index

    Hello!

    Create a test bench:
    CREATE TABLE scott.nls_demo
          (
          col_varchar            varchar2(4),
          col_char               char(4),
          col_varchar_NLS_GERMAN varchar2(4),
          col_char_NLS_GERMAN    char(4)
          );
     
    INSERT INTO scott.nls_demo (
          col_varchar,
          col_char,
          col_varchar_NLS_GERMAN,
          col_char_NLS_GERMAN  )
      SELECT 
             substr(object_name,1,4),
             substr(object_name,1,4),
             substr(object_name,1,4),
             substr(object_name,1,4)
      FROM all_objects where rownum<5000;
    
    COMMIT; 
    
    create index scott.i_varchar on scott.nls_demo (col_varchar);  
    create index scott.i_char    on scott.nls_demo (col_char);
    
    create index scott.i_varchar_NLS_GERMAN on scott.nls_demo ( NLSSORT(col_varchar_NLS_GERMAN,'nls_sort=''GERMAN_CI'''));  
    create index scott.i_char_NLS_GERMAN    on scott.nls_demo ( NLSSORT(col_char_NLS_GERMAN,   'nls_sort=''GERMAN_CI'''));
     
    Now "explain plan" these 8 select statements in SQL * more:
    variable c char(4);
    variable v varchar2(4);
    
    exec :c:= 'abc';
    exec :v:= 'abc';
    
    explain plan for SELECT /* 1*/ * FROM scott.nls_demo where col_varchar=:v;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    explain plan for SELECT /* 2*/ * FROM scott.nls_demo where col_char=:c;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    explain plan for SELECT /* 3*/ * FROM scott.nls_demo where col_varchar_NLS_GERMAN=:v;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    explain plan for SELECT /* 4*/ * FROM scott.nls_demo where col_char_NLS_GERMAN=:c;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    ALTER SESSION SET NLS_COMP = linguistic;
    ALTER SESSION SET NLS_SORT = german_ci;
    
    explain plan for SELECT /* 5*/ * FROM scott.nls_demo where col_varchar=:v;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    explain plan for SELECT /* 6*/ * FROM scott.nls_demo where col_char=:c;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    explain plan for SELECT /* 7*/ * FROM scott.nls_demo where col_varchar_NLS_GERMAN=:v;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    explain plan for SELECT /* 8*/ * FROM scott.nls_demo where col_char_NLS_GERMAN=:c;
    SELECT * FROM TABLE(dbms_xplan.display);
     
    What I see on 11.2.0.2 is:

    1.) statement 1 would use the I_VARCHAR index, that is what I expected.
    2.) statement 2 would use the I_CHAR index, that is what I expected.
    3.) no clue used, because none are available right here for you. Understood.
    4.) no clue used, because none are available right here for you. Understood.

    And when define us NLS_SORT = german_ci:

    5.) no clue used, because none are available right here for you. Understood.
    6.) no clue used, because none are available right here for you. Understood.
    7.) I_VARCHAR_NLS_GERMAN we used. Large.
    8.) no index used, although I think that "i_char_NLS_GERMAN" would do the job...

    Why the index 'i_char_NLS_GERMAN' is not used with the 8 statement? Jonathan? Someone else?

    Thanks for your help!
    Marcus

    Not really a reason to not use TANK - although there are many of them.

    More than one reason to not always rely to "explain the plan for?

    All the variables passed in EXPLAINING the PLAN for are treated as VARCHAR2.
    In addition, there is no point setting the values of the variable because they will not cast a look either with MAP to EXPLAIN.

    SQL> CREATE TABLE nls_demo
      2        (
      3        col_varchar            varchar2(4),
      4        col_char               char(4),
      5        col_varchar_NLS_GERMAN varchar2(4),
      6        col_char_NLS_GERMAN    char(4)
      7        );
    
    Table created.
    
    SQL>
    SQL> INSERT INTO nls_demo (
      2        col_varchar,
      3        col_char,
      4        col_varchar_NLS_GERMAN,
      5        col_char_NLS_GERMAN  )
      6    SELECT
      7           substr(object_name,1,4),
      8           substr(object_name,1,4),
      9           substr(object_name,1,4),
     10           substr(object_name,1,4)
     11    FROM all_objects where rownum<5000;
    
    4999 rows created.
    
    SQL>
    SQL> commit; 
    
    Commit complete.
    
    SQL>
    SQL> create index i_varchar on nls_demo (col_varchar);  
    
    Index created.
    
    SQL> create index i_char    on nls_demo (col_char);
    
    Index created.
    
    SQL>
    SQL> create index i_varchar_NLS_GERMAN on nls_demo ( NLSSORT(col_varchar_NLS_GERMAN,'nls_sort=''GERM
    AN_CI'''));  
    
    Index created.
    
    SQL> create index i_char_NLS_GERMAN    on nls_demo ( NLSSORT(col_char_NLS_GERMAN,   'nls_sort=''GERM
    AN_CI'''));
    
    Index created.
    
    SQL>
    SQL> variable c char(4);
    SQL> variable v varchar2(4);
    SQL>
    SQL> exec :c:= 'abc';
    
    PL/SQL procedure successfully completed.
    
    SQL> exec :v:= 'abc';
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> ALTER SESSION SET NLS_COMP = linguistic;
    
    Session altered.
    
    SQL> ALTER SESSION SET NLS_SORT = german_ci;
    
    Session altered.
    
    SQL>
    SQL> SELECT /* 8*/ * FROM nls_demo where col_char_NLS_GERMAN=:c;
    
    no rows selected
    
    SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------
    SQL_ID  9su0j5vzuwzyj, child number 0
    -------------------------------------
    SELECT /* 8*/ * FROM nls_demo where col_char_NLS_GERMAN=:c
    
    Plan hash value: 2830339923
    
    -------------------------------------------------------------------------------------------------
    | Id  | Operation                   | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |                   |       |       |     3 (100)|          |
    |   1 |  TABLE ACCESS BY INDEX ROWID| NLS_DEMO          |    50 |  2150 |     3   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | I_CHAR_NLS_GERMAN |    20 |       |     1   (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("NLS_DEMO"."SYS_NC00006$"=NLSSORT(:C,'nls_sort=''GERMAN_CI'''))
    
    Note
    -----
       - dynamic sampling used for this statement (level=2)
    
    23 rows selected.
    
    SQL> 
    

    Published by: Dom Brooks on February 21, 2011 15:39

  • problem with trigger to update column

    I am creating a trigger when I INSERTS a record into the CHART table, it will also insert the record in the MASTER_TAB table as well. I can't make the statement to UPDATE the trigger.

    To do so, the relaxation, I have currently below.

    But what I am also eager to make, only to do an UPDATE if the 'REMARKS' column changes.

    So, something like:

    If the update and: NEW.COMMENTS! =: OLD.COMMENTS THEN
    do not include a record
    create or replace TRIGGER "TABLE_BIU"
    BEFORE
    INSERT OR UPDATE ON "CHART"
    FOR EACH ROW
    BEGIN
    INSERT INTO MASTER_TAB
    (
    CASE_NUMBER,
    COMMENTS
    )
    VALUES
    (
    :NEW.CASE_NUMBER,
    :NEW.COMMENTS
    );
    END;
    Thank you
    Deanna
    create or replace TRIGGER TABLE_BIU
    BEFORE
    INSERT OR UPDATE ON CHART
    FOR EACH ROW
    BEGIN
    IF INSERTING OR NOT NVL(:OLD.COMMENTS,:NEW.COMMENTS || 'X') = NVL(:NEW.COMMENTS,:OLD.COMMENTS || 'X')
    THEN
    INSERT INTO MASTER_TAB
    (
    CASE_NUMBER,
    COMMENTS
    )
    VALUES
    (
    :NEW.CASE_NUMBER,
    :NEW.COMMENTS
    );
    END IF;
    END;
    

    SY.

  • How to install LR5 cloud? LR4 says no update available. [was: help with purchases and updates.]

    I am a CC member.
    1. I can't find the chat support.
    2 - I need LR5 but my app says no updates, even if I'm only on 4.
    3 - this site sends me in circles and my app is no help whatsoever. I have now updated to OS X Yosemite v10.10 and need LR5. I bought the CC for this reason, but I still don't see how to change. After hours of upgrades and installs, I'm frustrated. Thanks for the help, its much appreciated.

    AprilThisWay it is likely that your Lightroom problem is related to the incorrect application of Adobe Application Manager/creating Cloud Desktop installed.  The current version is 1.8.0.447.  You can find more details at CC help | Creative Cloud app for desktop PC | Release notes.

    I would recommend using the uninstall instructions available in the link referenced in the #7 message.  Once you have run all the available in the Applications/Utilities/Adobe Installers folder available uninstallers, so please use the CC cleaning tool.  You can find details and a download link for the CC cleaning tool for the use of the CC cleaning tool to resolve installation problems. CC, CS3 - CS6 - http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html.

    If you continue to experience difficulties can you please post what changes to your computer in addition to the upgrade to Mac OS 10.10.

  • activation / deactivation of field with dynamic action and apply the attribute 'required value.

    Hello

    Wanted to know how to force the 'required' attribute for the element off after that is "activated" by a dynamic action.

    For example, consider employee form.  I would like to disable the column of employment and salary.  As soon as the user enters the name of the employee, I will 'activate' JOB and SAL columns using "dynamic action".

    IMG-1.png

    IMG-2.png

    And above works fine.  Please note that both JOBS & SAL of columns 'NULL' according to the DB table.  My question is, how to comply with the condition of 'value' Yes, after allowing them.

    Another example would be, when the user selects 'Check' or 'Project', the 'no project' column will be activated.  Otherwise, "Project No." column is disabled (that is, the value is not required).  However, when turned on, I want to apply "value required" in this column.   How to get there?   (I use APEX 4.2.6)

    Thank you

    -Anand

    Why you do not create a function that returns a Boolean, validation of the page?

    You can do something like

    BEGIN

    IF: P5_ENAME IS NOT NULL THEN

    IF: P5_JOB IS NULL THEN

    Returns false;

    ON THE OTHER

    Returns true;

    END IF;

    END IF;

    END;

    You can change it to any desired column.

  • Compare multiple columns and update a column based on the comparison

    Hi all

    I have to update the column STATUS of the slot structure of the table.

    Status should be 'P' if all the columns count are equal on the other should be "F".

    The value of the column can be "NA'. If the value is NA, then avoid this comparison column; compare only other 3 columns.

    My output should look like below.

    State of cnt1, cnt2 cnt3 ID cnt4

    1   4       4       4     4       P

    2   4       5       4     4       F

    3 4 4 NA 4 P

    NA 4 4 3 4

    I tried with the statemnt with BOX WHEN conditions and DECODE UPDATE, but could not succeed, can someone please help

    To do this, if you use my statement in response #11 box (Re: Re: comparison of multi-column and update a column based on the comparison of)

  • Create triggers in the table, sequence, insert and update with "model"?

    It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:

    1.), I add the table to the logic model

    2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary

    3.) then I have the new table to add

    -but

    I would then have auto-DDL of to be synchronized to database:

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    -Create triggers for insert and update

    -l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.

    -activate the triggers

    Each of them following the same naming convention.

    Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.

    rgrds Paavo

    Hi Paavo,

    most of the steps can be made in one or other way

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.

    fields of record defined in the table, so that each table has them

    You can add the same set of columns in all tables with the transformation script 'model of Table... ».

    You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts

    to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.

    Philippe

  • Select the checkbox in the column header everything inside TableView with CheckBoxTableCell

    Hello

    I have a TableView with a column filed with the box and a listener "changed" in the template class 'Code '. I also have a 'Select all' check box in the header of this column that call the method "handleSelectAllCheckbox()". But him 'select all' does not work!

    I'm really grateful for the help.

    Here is my code:

    Concerning

    import java.net.URL;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.ResourceBundle;
    import javafx.beans.property.SimpleBooleanProperty;
    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.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.fxml.FXML;
    import javafx.fxml.Initializable;
    import javafx.scene.control.CheckBox;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TitledPane;
    
    
    
    
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.util.Callback;
    
    
    
    
    public class FXMLController implements Initializable {
    
    
        private CodeService codeService = new CodeServiceImpl();
        @FXML
        private TableView<Code> codeTableView;
        @FXML
        private TableColumn codeNomCol;
        @FXML
        private TableColumn codeAbregeCol;
        @FXML
        private TableColumn codeSelectCol;
        // The table's data
        private ObservableList<Code> dataCode;
    
    
        // ---------- ---------- ---------- ---------- ----------
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            this.initCodeTableView();
            this.initColumnsSize();
        }
    
    
        /**
         *
         */
        private void initCodeTableView() {
            
            this.codeNomCol.setCellValueFactory(new PropertyValueFactory<Code, String>("nom"));
            this.codeAbregeCol.setCellValueFactory(new PropertyValueFactory<Code, String>("abrege"));
            //this.codeSelectCol.setCellValueFactory(new PropertyValueFactory<Code, String>("selected"));
    
    
            this.codeSelectCol.setCellValueFactory(new PropertyValueFactory("selected"));
            this.codeSelectCol.setCellFactory(new Callback<TableColumn<Code, Boolean>, TableCell<Code, Boolean>>() {
                @Override
                public TableCell<Code, Boolean> call(TableColumn<Code, Boolean> arg0) {
                    return new CheckBoxTableCell<Code, Boolean>();
                }
            });
            
            // Header CheckBox
            CheckBox cb = new CheckBox();
            cb.setUserData(this.codeSelectCol);
            cb.setOnAction(handleSelectAllCheckbox());
            this.codeSelectCol.setGraphic(cb);       
    
    
            this.codeTableView.getItems().clear();
            this.dataCode = FXCollections.observableArrayList((List<Code>) this.codeService.listCodes());
            this.codeTableView.setItems(this.dataCode);
        }
    
    
        /**
         * 
         * @return 
         */
        private EventHandler<ActionEvent> handleSelectAllCheckbox() {
    
    
            return new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                    CheckBox cb = (CheckBox) event.getSource();
                    TableColumn column = (TableColumn) cb.getUserData();
                    if (cb.isSelected()) {
                        for (Code c : dataCode) {
                            System.out.println("Nom: " + c.getNom() + " Selected: " + c.getSelected());
                            c.setSelected(new SimpleBooleanProperty(Boolean.TRUE));
                        }
                     } else {
                        for (Code c : dataCode) {
                            System.out.println("Nom: " + c.getNom() + " Selected: " + c.getSelected());                        
                            c.setSelected(new SimpleBooleanProperty(Boolean.FALSE));
                        }
                    }
    
    
                }
            };
        }
    
    
        /**
         *
         */
        private void initColumnsSize() {
            this.codeNomCol.setMinWidth(300);
            this.codeAbregeCol.setMinWidth(200);
            this.codeSelectCol.setMinWidth(50);
        }
    
    
    
    
    
    
    }
    

    The line

    c.setSelected(new SimpleBooleanProperty(Boolean.TRUE));
    

    bad air.

    It should be

    c.setSelected(true);
    

    This suggests that your class model Code is wrong: it should be built according to the model of properties JavaFX (see tutorial):

    public class Code {
         private final BooleanProperty selected ;
         public Code(boolean selected) {
              this.selected = new SimpleBooleanProperty(this, "selected", selected);
         }
         public final boolean getSelected() {
              return this.selected.get();
         }
         public final void setSelected(boolean selected) {
              this.selected.set(selected);
         }
         public final BooleanProperty selectedProperty() {
              return selected ;
         }
    }
    

    (And similarly for the other properties).

    The problem is that when you change the selected property, the individual check boxes in the column of the table are respecting the old instances of BooleanProperty changes, not the new instance you just created.

  • TableView problem of automatic update in points 2.1 and 2.2

    Hi, guys!

    Initial situation: I have a TableView with some elements inside. I update an element (a user object), I remove it from the table and then I put it again to the same index.

    The labour code in 2.0.2:
    // Gets selected item
    User selectedUser = (User) table.getSelectionModel().getSelectedItem();
    
    // Updates the User object to show the new data in the table
    selectedUser.setFirstName(fNameTF.getText());
    selectedUser.setLastName(lNameTF.getText());
    selectedUser.setRank((String) (rankCB.getSelectionModel().getSelectedItem()));
    selectedUser.setPassword(passTF.getText());
    
    // Updates table data.
    // First gets the user Object index in the items list,
    // then removes the user object from the table list,
    // then adds the updated user object at the same index it was before.
    int userObjectIndexInItemsList = table.getItems().indexOf(selectedUser);
    table.getItems().remove(table.getItems().indexOf(selectedUser));
    table.getItems().add(userObjectIndexInItemsList, selectedUser);
    Here's my problem: in the version 2.1 and 2.2 (b06) this no longer works. The table does not display the changed data. I also tried getTableItems tableData (new FXCollections.observableArrayList ()), then table.setItems (null), then table.setItems (tableData), but it did not work.
    So, the problem is that the FXCollections.observableArrayList () (which has been used to fill the table in the beginning) don't relate more to the table when a change is made.

    Possible, but not desired collaborative:
    1. total re-creation of the table.
    2. total recreation of the tableItems (create a new observable by new objects).

    Any suggestions?
    I don't want to recreate the table data whenever a change is made, in particular because it is based on a database.

    JavaFX has a fundamentally different way of handling these types of updates, which can make it difficult to implement this in your current system.

    In short, how updates work in JavaFX of the ListView, TreeView, and TableView is the following:

    Each view type is made of cells. The number of cells is usually pretty close to the amount of visible lines and each cell could be considered to represent a line.

    Each cell is basically a small piece of the user interface that adapts to everything that should appear on the line given at that time there. The updateItem method is called on these cells to associate them with an underlying element of the ObservableList (the model).

    Let's say that your "Items" in the model are objects with a person's name. An implementation of the cell could make this as follows:

      private static final class PersonTableCell extends TableCell {
    
        @Override
        protected void updateItem(final Person person, boolean empty) {
          super.updateItem(mediaNode, empty);
    
          if(!empty) {
            setText(person.getTitle());
          }
        }
      }
    

    The example above will also have the same problem to update your code, otherwise, if you change the subject Person in your model of the cell will not reflect the name changed.

    In JavaFX to inform the cell of the modification, you must add a listener to the property 'text' of your person object. This assumes that a Person object properties are the properties of style of JavaFX. This is done like this (using a binding that uses an internal auditor):

      private static final class PersonTableCell extends TableCell {
    
        @Override
        protected void updateItem(final Person person, boolean empty) {
          super.updateItem(mediaNode, empty);
    
          textProperty().unbind();
    
          if(!empty) {
            textProperty().bind(person.titleProperty());
          }
        }
      }
    

    The foregoing will automatically updated correctly each change to the title property of the person.

    However, this means that you need to change your Person object to use the JavaFX style properties. You donot have always this luxury hotel. However, there are other options. You could for example only support a "changedProperty" in the Person class and have cells listening to it, something like this:

      private static final class PersonTableCell extends TableCell {
        private Person oldPerson;
        private InvalidationListener listener;
    
        @Override
        protected void updateItem(final Person person, boolean empty) {
          super.updateItem(mediaNode, empty);
    
          if(oldPerson != null) {
            oldPerson.removeListener(listener);
            oldPerson = null;
          }
    
          if(!empty) {
            listener = new InvalidatonListener() {
              public void invalidated(Observable o) {
                 setText(person.getTitle());
              }
            };
            person.addListener(listener);
            setText(person.getTitle());
          }
        }
      }
    

    Now whenever you want to trigger a "change", you call a method on the Person object that triggers a cancel event. All cells that are tuned to this person object will be notified and update.

    If you donot change the class of the person itself, you could also do this with a wrapper. You will have to experiment a little.

  • You will need to insert update column with the username?

    Hi all

    I'm new to this forum of the apex. New to apex as well.

    My question is do we have a form and a single column is editable by the user. whenever an update to this column, I need to write their name in the update column.

    I heard that we can do with trigger using the variable app_user. But in our project, they made authentication ldap for this form and when an employee login with their company login id they can see only this form of apex. no other option.

    In the same form, they were able to show the user name. I checked how they did it. they used * & user * variable for this. , It makes sense for you gentlemen?

    all I have to do is insert this & user in the column value.

    How to do this. I'm started working in the apex for the past four days alone. willing to bare with me if im a very stupid question.

    Thank you
    knani

    PS: I know that what im asking is the user name for the Web page the user name of the apex.

    Published by: kart on May 26, 2010 11:45

    Hello

    You can use: APP_USER substitution string.
    If you like to use that in the syntax of database trigger is v('APP_USER') for example

    :NEW.CHANGED_BY := NVL(v('APP_USER'), user);
    

    BR, Jari

  • Update column in a table with several lines at a time

    I created a tabular presentation, page 19, with a single editable column, STATUS. Let's say that there are 300 rows in this form.

    I would like to have a button that selects all lines and change the status to "AUTHORIZED", if the status is set to "PLANNED".

    Without passing through and using checkboxes on the tabular form, is there a way I can do this with a button and a process? Then my code would look like this in a process of PL/SQL:

    BEGIN
    UPDATE of the elements
    SET
    State = "AUTHORIZED."
    auth_date = sysdate,
    status_date = sysdate
    WHERE
    ID =: P3_ID
    AND status = 'PLANNED ';
    END;


    Thank you very much
    Maggie

    Maggie,

    There are some things that you need to consider:

    <script language="JavaScript" type="text/javascript">
    function f_mass_update()
    {
    var counter = 0;
    for (var i = 0; i < document.wwv_flow.f03.length; i++)
    
    {var curr_id = document.wwv_flow.f03.id;
    
    if ($x(curr_id).value == 'COMPLETE')
    
    {$x(curr_id).value = 'CANCELED';
    $x(curr_id).style.color = "darkred";
    $x(curr_id).style.fontWeight = "bold";
    $x(curr_id).style.background = "yellow";
    $x(curr_id).style.width = "103px";
    counter = counter + 1;}}
    
    if (counter == 0)
    {alert ('There are no more statuses to change!');}
    else {alert(counter + ' Records updated!');}
    }
    </script>
    

    corresponds to the correct script if escape you COMPLETE as 'DONE' and CANCELLED as "CANCELLED". The same rules apply for the javascript that for most other languagas programming - numbers do not need to be escaped, but make the strings.

    The second thing is the question of your id to tabular presentation. In my case it was f03 but in your case, it's probably different. If you have created a tabular presentation Wizard does not touch, you could count the columns.
    If your column is the first column editable only be f03. The second will be f04 and so on. My recommendation is to use Firefox and download the Firebug extension. You can do this with firebug HTML > inspect and move the mouse on any item in your page. Click the actual cell in a table, and it will tell you a code like this:

    <input type="text" id="f03_0001" value="10" maxlength="2000" size="16" name="f03"/>
    

    Thus, the name of the element is f03.

    See the same page, now with an attached image of what I just explained:

    http://Apex.Oracle.com/pls/OTN/f?p=31517:213

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for

  • How can I fix my iPad to Miss email and password?

    my name is iPad new version and I fight second hand, I used for a while and one day I was updating the program format, unfortunately I missed my email and password. So, how do I open my iPad. ?

  • main problem with iPhone button 5

    Hello The button main iphone less sensitive when you press 5. Is this repairable? Thank you

  • How can I enter the BIOS of a Portege M100?

    I have in fact two problems: How can I get into the Bios and why I can't install the latest drivers for the graphics chip? I want to increase the performance of grafic maximally, as I increased the RAM and the laptop is fast enough.I would like to pl

  • Windows 7 - error Code: 80072F8F (cannot install updates)

    Original title: how is it, my windows cannot search for windows update and code error on East 80072F8F Dungeon and I was usin window7 throughout Please help mi to fix this cause I didn't really like my computer to spolit thx much

  • Change the name of the network printer wireless

    We have several Officejet Pro 8600 in our building.  We are printing wireless on their part and need to change the name of the printers so that we know who is who.  How can I change the name of the network to a printer?