Results 1 to 4 of 4
  1. #1
    lizz_pena is offline Member
    Join Date
    Apr 2015
    Posts
    1
    Rep Power
    0

    Default ObservableList<Object> not displaying new values -- newbie question --thxs

    Hi all! I am using an ObservableList to show and hide information retrieved from the database. The TableView<> is attempting to display my ObservableList<>.
    The only values I get are the last ones in my object. I apologize if I am using incorrect wording to explain my issue Code follows. Using Netbean 8 with java 8

    Thanks for any ideas, I tried to removed extraneous code:


    package gov.fws.sami.pages;

    import gov.fws.sami.Page;
    import gov.fws.sami.BasePane;
    import gov.fws.sami.Constants;
    import gov.fws.sami.domain.SelectListDO;
    import javafx.scene.control.*;
    import javafx.scene.layout.*;
    import javafx.scene.text.Text;
    import gov.fws.sami.Sami;
    import gov.fws.sami.controls.CrvDialog;
    import gov.fws.sami.domain.AssetCodeDO;
    import gov.fws.sami.domain.AssetDO;
    import gov.fws.sami.domain.CrvAssemblyDO;
    import gov.fws.sami.domain.CrvDO;
    import gov.fws.sami.domain.CrvSectionDO;
    import gov.fws.sami.domain.SamiDAO;
    import gov.fws.sami.domain.StationDO;
    import java.io.IOException;
    import java.text.DecimalFormat;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.logging.Level;

    import java.util.logging.Logger;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.event.EventHandler;
    import javafx.geometry.HPos;
    import javafx.geometry.Insets;
    import javafx.geometry.Pos;
    import javafx.geometry.VPos;
    import javafx.scene.Node;
    import javafx.scene.control.Button;
    import javafx.scene.control.CheckBox;
    import javafx.scene.control.Control;
    import javafx.scene.control.Label;
    import javafx.scene.control.ScrollPane;
    import javafx.scene.control.Separator;
    import javafx.scene.control.TextArea;
    import javafx.scene.control.TextField;
    import javafx.scene.control.Tooltip;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.GridPane;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.Pane;
    import javafx.scene.layout.Region;
    import javafx.scene.layout.VBox;
    import javafx.scene.web.HTMLEditor;
    /**
    * SummaryPage
    */
    public class CrvCalculatorPage extends Page {
    private static double DIALOG_WIDTH = 900;
    private Class basePaneClass;
    private SamiDAO dao = null;
    private StationDO currentStation = null;
    private AssetDO currentAsset = null;
    private AssetCodeDO currentAssetCode = null;
    private TextField separatorTextField = null; //empty grid value

    DecimalFormat twoDigits = new DecimalFormat ("#,##0.00");
    boolean isNewSectionName = true;
    String currentSectionName = "";
    private final static PropertyValueFactory secItemsPvf = new PropertyValueFactory("calculatorSectionItemsName") ;
    private final static PropertyValueFactory assQtyPvf = new PropertyValueFactory("assemblyQty");
    private final static PropertyValueFactory assUOMPvf = new PropertyValueFactory("assemblyUOM");
    private final static PropertyValueFactory assUnitCostPvf = new PropertyValueFactory("assemblyUnitCost");
    private final static PropertyValueFactory assFixedCostPvf = new PropertyValueFactory("assemblyFixedCost");
    private final static PropertyValueFactory prevQtyPvf = new PropertyValueFactory("prevQty");
    private final static PropertyValueFactory costPvf = new PropertyValueFactory("cost");

    public CrvCalculatorPage(String name) throws IllegalArgumentException {
    super(name);

    // Add API back references
    Sami sami = Sami.getSami();
    dao = sami.getDao();
    }

    public CrvCalculatorPage(CrvCalculatorPage pageToClone) {
    super(pageToClone.getName());
    }

    public StationDO getCurrentStation() {
    return currentStation;
    }
    public AssetDO getCurrentAsset() {
    return currentAsset;
    }

    public void setCurrentAsset(AssetDO currentAsset) {
    this.currentAsset = currentAsset;
    }

    public AssetCodeDO getCurrentAssetCode() {
    return currentAssetCode;
    }

    public void setCurrentAssetCode(AssetCodeDO currentAssetCode) {
    this.currentAssetCode = currentAssetCode;

    }

    public void setCurrentStation(StationDO currentStation) {
    this.currentStation = currentStation;
    Sami sami = Sami.getSami();
    if (sami.getImportFromFhwaMenuItem() != null)
    sami.getImportFromFhwaMenuItem().setDisable(
    (currentStation == null) ? true : false);
    }

    public String getWebCrvDescStatus(Integer webCrvId) {
    if (webCrvId != null) {
    switch (webCrvId) {
    case 1: return(Constants.CRV_UPDATE_DUE_1);
    case 2: return(Constants.CRV_APPROVED_2);
    case 3: return("PHA"); // Acronym for Pending Headquarter Approval
    case 4: return(Constants.CRV_REJECTED_4);
    default: return(Constants.CRV_UPDATE_DUE_1);
    }
    } else { //the default
    return(Constants.CRV_UPDATE_DUE_1);
    }
    }

    @Override public Node createView() {
    try {
    Sami sami = Sami.getSami();
    if (sami.getCameraButton() != null)
    sami.getCameraButton().setDisable(true);
    StationDO station = sami.getCurrentStation();
    setCurrentStation(station);
    setCurrentAsset(sami.getCurrentAsset());
    if (this.currentAsset != null) {
    try {
    setCurrentAssetCode(dao.readAssetCodeFS(this.curre ntAsset.getAssetcode()));
    } catch (IOException ex) {
    Logger.getLogger(CrvDialog.class.getName()).log(Le vel.SEVERE, null, ex);
    } catch (IllegalArgumentException ex) {
    Logger.getLogger(CrvDialog.class.getName()).log(Le vel.SEVERE, null, ex);
    }
    }
    //set up crvdo
    CrvDO crvdo = null;
    try {
    SamiDAO dao = Sami.getSami().getDao();
    crvdo = dao.selectWebCrvDB(dao.getConnection(), getCurrentAsset().getLocation());
    } catch (Exception ex) {
    Logger.getLogger(CrvDialog.class.getName());
    }




    // create header
    StringBuilder sb = new StringBuilder("CRV Calculator");
    SelectListDO stn = station.getStation();
    if ((stn != null) && (stn.getName() != null))
    {
    sb.append(" - ");
    sb.append(stn.toString());
    }
    Label headerLabel = new Label(sb.toString());
    headerLabel.getStyleClass().add("page-subheader");
    HBox header = new HBox();
    header.setAlignment(Pos.CENTER);
    header.getChildren().addAll(headerLabel);

    VBox center = new VBox();

    GridPane grid1 = new GridPane();
    grid1.setId("gridPane-crvdialog");
    grid1.setHgap(1);
    grid1.setVgap(6);
    grid1.setGridLinesVisible(false); //For development only

    grid1.setPadding(new Insets(18, 18, 18, 18));
    ObservableList<Node> content = grid1.getChildren();

    int contentRow = -1;







    //Get section data list data
    final ObservableList<CrvSectionDO> sectionDataList =
    FXCollections.observableArrayList(crvdo.getSection List(getCurrentAsset().getAssetcode()));
    if (sectionDataList != null) {
    TableColumn secitemCol = new TableColumn();
    secitemCol.setId("asset-page");
    secitemCol.setText("Asset/Feature/Type Description");
    secitemCol.setMaxWidth(400);
    secitemCol.setCellValueFactory(secItemsPvf);

    TableColumn qtyCol = new TableColumn();
    qtyCol.setId("asset-page");
    qtyCol.setText("Quantity");
    qtyCol.setMinWidth(100);
    qtyCol.setCellValueFactory(assQtyPvf);

    TableColumn uomCol = new TableColumn();
    uomCol.setId("asset-page");
    uomCol.setText("UOM");
    uomCol.setMinWidth(100);
    uomCol.setCellValueFactory(assUOMPvf);

    TableColumn unitCostCol = new TableColumn();
    unitCostCol.setId("asset-page");
    unitCostCol.setText("Unit Price");
    unitCostCol.setMaxWidth(150);
    unitCostCol.setCellValueFactory(assUnitCostPvf);


    TableColumn fixedCostCol = new TableColumn();
    fixedCostCol.setId("asset-page");
    fixedCostCol.setText("Fixed Price");
    fixedCostCol.setMinWidth(100);
    fixedCostCol.setCellValueFactory(assFixedCostPvf);


    TableColumn prevQtyCol = new TableColumn();
    prevQtyCol.setId("asset-page");
    prevQtyCol.setText("Previous Qty");
    prevQtyCol.setMinWidth(100);
    prevQtyCol.setCellValueFactory(prevQtyPvf);

    TableColumn costCol = new TableColumn();
    costCol.setId("asset-page");
    costCol.setText("Cost");
    costCol.setMinWidth(80);
    costCol.setCellValueFactory(costPvf);



    for (CrvSectionDO section : sectionDataList)
    {
    TableView<CrvAssemblyDO> crvAssemblyTableView = new TableView<CrvAssemblyDO>();
    ObservableList<CrvAssemblyDO> assemblySectionNameDataList = FXCollections.observableArrayList(section.getAssem blyList());
    crvAssemblyTableView.setId("asset-page");
    crvAssemblyTableView.setItems(assemblySectionNameD ataList); //THIS IS NOT SETTING CORRECT VALUES
    crvAssemblyTableView.setPrefHeight((section.getAss emblyList().size() + 1) * Constants.ROW_HEIGHT + 3);
    crvAssemblyTableView.setMinHeight((section.getAsse mblyList().size() + 2) * Constants.ROW_HEIGHT + 2);
    crvAssemblyTableView.getColumns().addAll(secitemCo l,qtyCol,uomCol,unitCostCol,fixedCostCol,prevQtyCo l,costCol);



    crvAssemblyTableView.setUserData(this);
    crvAssemblyTableView.setVisible(false);
    crvAssemblyTableView.setManaged(false);
    GridPane.setConstraints(crvAssemblyTableView, 1, ++contentRow,6,1);
    GridPane.setHalignment(crvAssemblyTableView, HPos.LEFT);
    GridPane.setValignment(crvAssemblyTableView, VPos.TOP);
    content.add(crvAssemblyTableView);



    StringBuffer secname = new StringBuffer("Show ");
    secname.append(section.getSectionName());
    Button shdeButton1 = new Button(secname.toString());
    shdeButton1.setId("asset-page");
    shdeButton1.setUserData(this);
    shdeButton1.setContentDisplay(ContentDisplay.LEFT) ;
    shdeButton1.setMinWidth(Control.USE_PREF_SIZE);
    shdeButton1.setTooltip(new Tooltip("Show/Hide Assemblies"));
    shdeButton1.setOnMouseClicked(new EventHandler<MouseEvent>() {
    @Override public void handle(MouseEvent event) {

    Logger.getGlobal().info("Show/Hide Assemblies Pressed");
    Button but = (Button) event.getSource();
    String txt = but.getText();

    if ((txt != null) && txt.startsWith("Hide "))
    {

    crvAssemblyTableView.setVisible(false);
    crvAssemblyTableView.setManaged(false);
    crvAssemblyTableView.setUserData(section.getAssemb lyList());
    StringBuffer buttonName = new StringBuffer("Show ");
    buttonName.append(section.getSectionName());
    but.setText(buttonName.toString());
    }
    else
    {

    crvAssemblyTableView.setVisible(true);
    crvAssemblyTableView.setManaged(true);
    StringBuffer buttonName = new StringBuffer("Hide ");
    buttonName.append(section.getSectionName());
    but.setText(buttonName.toString());
    }
    }
    });

    GridPane.setConstraints(shdeButton1, 0, contentRow);
    GridPane.setValignment(shdeButton1, VPos.TOP);
    GridPane.setHalignment(shdeButton1, HPos.LEFT);
    content.add(shdeButton1);

    } // end for each user sectionDataList


    }

    Region hspacer1 = new Region();
    hspacer1.setMinWidth(10);



    Region vspacer = new Region();
    vspacer.setMinHeight(10);
    GridPane.setConstraints(vspacer, 0, ++contentRow);
    content.add(vspacer);
    vspacer = new Region();
    vspacer.setMinHeight(5);

    Region vspacer2 = new Region();
    vspacer2.setMinHeight(5);
    Region vspacer3 = new Region();
    vspacer3.setMinHeight(5);


    //Everything is in grid1


    center.getChildren().addAll(vspacer, buildButtonHBox(stn),
    vspacer2,
    grid1,
    vspacer3, buildButtonHBox(stn));

    // create border pane for main content and sidebar
    BorderPane borderPane = new BorderPane();
    borderPane.getStyleClass().add("content-page");
    borderPane.setTop(header);
    borderPane.setCenter(center);
    borderPane.setBottom(new SamiFooter());

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(borderPane);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setMinWidth(725);

    return scrollPane;
    } catch (Exception e) {
    e.printStackTrace();
    return new Text("Failed to create sample because of ["+e.getMessage()+"]");
    }
    }

    private List<CrvAssemblyDO> getSectionNameAssemblyList(List<CrvSectionDO> assemblyAllDataList, String calculatorsectionname) {
    List<CrvAssemblyDO> assemblyList = new ArrayList<CrvAssemblyDO>();
    for (CrvSectionDO assembly : assemblyAllDataList)
    {
    if (assembly.getSectionName().equalsIgnoreCase(calcul atorsectionname))
    return(assembly.getAssemblyList());
    }
    return assemblyList;
    }

    public static class SummaryPageView extends TabPane {
    private BasePane bp;

    public SummaryPageView(BasePane bp) {
    super();
    this.bp = bp;
    }

    public void stop() {
    bp.stop();
    }
    }

    public HBox buildButtonHBox(SelectListDO stn) throws IOException
    {
    Sami sami = Sami.getSami();
    // build reports menu

    Button saveButton = new Button("Save");
    saveButton.setId("asset-page");
    saveButton.setUserData(this);
    saveButton.setTooltip(new Tooltip("Save contents"));
    saveButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
    @Override public void handle(MouseEvent event) {
    Logger.getGlobal().info("Save Pressed");
    Button but = (Button) event.getSource();
    Sami.getSami().goToPreviousPage();
    }
    });


    Region hspacer4 = new Region();
    hspacer4.setMinWidth(20);

    Button cancelButton = new Button(Constants.CANCEL);
    cancelButton.setId("asset-page");
    cancelButton.setTooltip(
    new Tooltip("Return to Home Page"));
    cancelButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
    @Override public void handle(MouseEvent event) {
    Logger.getGlobal().info("Cancel Summary Page Pressed");
    Sami.getSami().goToPreviousPage();
    }
    });

    HBox saveCancel = new HBox();
    saveCancel.getChildren().addAll( saveButton,
    hspacer4, cancelButton);
    saveCancel.setAlignment(Pos.CENTER);

    return saveCancel;

    } // end build buttonHBox(stn)

    } //end class CrvCalculatorPage

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: ObservableList<Object> not displaying new values -- newbie question --thxs

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: ObservableList<Object> not displaying new values -- newbie question --thxs

    Quote Originally Posted by DarrylBurke View Post
    I think it's about time the forum software incorporated a new button for you. You read a post, and then, if appropriate, press it. Automatically replies to the current thread with the appropriate message. :)

    But then, I am not a moderator so perhaps similar tools already exist.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: ObservableList<Object> not displaying new values -- newbie question --thxs

    I would prefer a filter that detects 'public class' in a new post and prompts the poster to use the code tags.

    And no, there are no magic buttons, just an old-fashioned boilerplate text file and ^C -^V

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. displaying values from HashMap
    By Debra in forum New To Java
    Replies: 6
    Last Post: 05-13-2012, 06:30 AM
  2. Replies: 2
    Last Post: 09-27-2011, 01:38 AM
  3. Replies: 1
    Last Post: 03-24-2011, 12:51 PM
  4. need help displaying hex values
    By intrepid604 in forum New To Java
    Replies: 1
    Last Post: 03-05-2011, 10:51 PM
  5. Displaying array values in jstl page
    By keshaba in forum Advanced Java
    Replies: 0
    Last Post: 04-23-2010, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •