I'm facing an issue to update the panel data on the change of some filed.
The usecase is, on the change of field F1, making a database call and retrived the related value in the list and want to populate the data dynamical.
Somehow it is working on the start of the application and call the db, bring the data and create row dynamically but on the change of filed F1, it makes the call, bring the data but not updating the row.
Here the code snippet:
Parent:
public class MyTab extends TabItem {
final MyDataPanel panel = new MyDataPanel();
public MyTab() {
super("DATA");
}
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
this.add(this.panel);
this.setAutoHeight(true);
}
}
Child:
public class MyDataPanel extends LayoutContainer implements Listener<BaseEvent> {
public MyDataPanel() {
super(new RowLayout(Orientation.VERTICAL));
MyDataPanel.this.loadData();
}
Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
final FieldSet myFieldSet = this.myDataFiledSet();
this.add(myFieldSet, new RowData(1234, 75));
this.addListeners();
}
private void addListeners() {
this.field1.addListener(Events.Select, this);
}
public void handleEvent(BaseEvent pBaseEvent) {
if (pBaseEvent.getSource().equals(this.field1)) {
MyDataPanel.this.loadData();
}
private FieldSet myDataFiledSet() {
final FieldSet fs = new FieldSet();
fs.setLayout(new RowLayout(Orientation.VERTICAL));
fs.setHeadingHtml("My Data");
final HorizontalPanel horizontalPanel = new HorizontalPanel();
final Label label1 = new Label("Movie Name");
horizontalPanel.add(label1);
final Label label2 = new Label("Movie Budget");
horizontalPanel.add(label2);
final Label label3 = new Label("Movie Release Year");
horizontalPanel.add(label3);
for (MyDataDTO dto : dataDTOList) {
HorizontalPanel row = new HorizontalPanel();
Label name = new Label(dto.getName());
row.add(name);
Label budget = new Label(dto.getBudget());
row.add(budget);
Label year = new Label(dto.getYear());
row.add(year);
}
return fs;
}
}
Summary: Want to re-render the myDataFiledSet() on the change of field1.
Thanks in Advance :)
Tried dynamically re-render the myDataFieldSet() on change of filed1 but it did not work.