opendolphindolphin-platform

Dolphin Platform Chart Objects not working?


in my Dolphin Platform project, the XYChart.Series Object, which contains a series of XYChart.Data, does not seem to synchronize its datamodel.

My viewbinder binds the data of the BarChart with the PM and sets it to the BarChartObjekt

public class GesamtErgebnisViewBinder extends AbstractViewBinder<GesamtErgebnisModel> {
 @Override
    protected void init() {
       ....
        ObservableList<XYChart.Series<String, Integer>> data = FXWrapper.wrapList(getModel().getData()) 
        barChart.setData(data); 
    }
}

The model consists of an observable list of BarChart Data

@DolphinBean
public class GesamtErgebnisModel {

   ....

    private ObservableList<XYChart.Series<String, Integer>> data;

    ....
}

On the serverside I am computing the BarChart data to pass it to my model object.

@DolphinController("GesamtErgebnisController")
public class GesamtErgebnisController {

@Inject
private BeanManager beanManager;

@DolphinModel
private GesamtErgebnisModel model;
...
        taskExecutor.execute(GesamtErgebnisController.class, e -> {
            final Series<String, Integer> series = beanManager.create(XYChart.Series.class);
            rawFilterData.entrySet().stream().map((mitgliedToFilterResultEntry) -> {
                final XYChart.Data<String, Integer> datas = beanManager.create(XYChart.Data.class);
                ....
            }).forEach((datas) -> {
            series.getData().add(datas);
        });
        model.getData().add(series);
});

But the bar chart just stays empty. Just the category is visible. Because I thought maybe my data that I put together is flawed, I altered an example from the Oracle website and tested the data manually. On server side, this doesn´t work either.. same output. If I put this code on clientside inside the init method of my viewbinder, the data shows correctly. So there should be nothing wrong with the data being passed. Observerable lists with String i.e work just fine. Maybe I am missing something else?


Solution

  • I think it's not a good idea to use the JavaFX classes on the server (or in the shared model). When using Dolphin Platform it should be best practice to create a client API independent (presentation) model. You can bind this model easily to the client model that uses the specific classes of the UI-Toolkit (like JavaFX). I created a sample for your concrete problem that uses a BarChart in a JavaFX client that is bound to a Dolphin Platform model. You can find it at Github.