Skip to content

Commit

Permalink
1.40
Browse files Browse the repository at this point in the history
- vaadin flow itemlabelgenerator
  • Loading branch information
Osiris-Team committed Mar 12, 2024
1 parent 547e6c1 commit fd92192
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.osiris.jsqlgen</groupId>
<artifactId>jSQL-Gen</artifactId>
<version>1.39</version>
<version>1.40</version>
<name>jSQL-Gen</name>

<properties>
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/osiris/jsqlgen/generator/GenVaadinFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,20 @@ public static String s(Database db, Table t, LinkedHashSet<String> importsList)
s.append(" {"+fieldName+".setItems("+refTable.name+".get());\n" +
" "+fieldName+".setRenderer(new ComponentRenderer<>(obj -> {\n" +
" Div div = new Div();\n"+
" div.setText(\"\"+");
" div.setText(");
String valAsString = "\"\"+";
for (Column refCol : refTable.columns) {
if (refCol.type.isBlob() || refCol.type.isDateOrTime()) continue;
s.append("obj." + refCol.name);
s.append("+\"; \"+");
valAsString += "obj." + refCol.name;
valAsString += "+\"; \"+";
}
s.append("\"\");\n" +
valAsString += "\"\"";
s.append(valAsString + ");\n" +
" return div;}));\n" +
" }");
" "+fieldName+".setItemLabelGenerator(obj -> {\n" +
" return "+valAsString+";\n" +
" });\n" +
" }\n");
} else{
fieldName = "nf" + colName;
s.append(" public NumberField " + fieldName + " = new NumberField(\"" + colName + "\");\n");
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/com/osiris/jsqlgen/testDB/PersonOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,11 @@ public static class PersonOrderComp extends VerticalLayout{
Div div = new Div();
div.setText(""+obj.id+"; "+obj.name+"; "+obj.age+"; "+obj.flair+"; "+obj.lastName+"; "+obj.parentAge+"; "+"");
return div;}));
} public TextField tfName = new TextField("Name");
cbPerson.setItemLabelGenerator(obj -> {
return ""+obj.id+"; "+obj.name+"; "+obj.age+"; "+obj.flair+"; "+obj.lastName+"; "+obj.parentAge+"; "+"";
});
}
public TextField tfName = new TextField("Name");
// Buttons
public HorizontalLayout hlButtons = new HorizontalLayout();
public Button btnAdd = new Button("Add");
Expand Down

0 comments on commit fd92192

Please sign in to comment.