I am trying to pass collection data to the editor screen as parameter when the table action is clicked. I tried to use setWindowParams of the standard actions but the result is unexpected.
For example, in below code i’m trying to pass the collection of order lines to the Order Line editor :
I’ve replicated your code and added the following to OrderLineEdit:
public class OrderLineEdit extends AbstractEditor<OrderLine> {
@WindowParam
private Collection<OrderLine> orderLines;
...
@Override
public void init(Map<String, Object> params) {
...
System.out.println("orderLines: " + orderLines);
}
}
The orderLines field is not null and contains the collection of OrderLine entities on the moment of opening OrderEdit (i.e. when postInit() was called).
Essentially, what i’m trying to do is to implement a check that a Product cannot be entered twice in the same Order. For this, i need to pass the collection of order lines to OrderLineEdit for the validation.
The current behaviour is (which is not what i expected):
For new Order, the lines collection will always be null and is not updated after adding some new lines.
For existing Order, the lines collection is not updated with newly added new lines.
For the validation to be work, I need the lines collection that includes any added / changed lines.
When you initialize the parameter in postInit(), it keeps the collection as it was on the moment of screen opening (it’s never null though, just can be empty). So to reflect the current state, the parameter should be initialized right before the action is invoked:
Hi Konatantin
I am trying to run this app in V6.7 and having the following exception:
:app-core:deploy
:app-gui:compileJavaD:\Studio Projects\demo\Demo-Parameter\modules\gui\src\com\company\sales\gui\order\OrderEdit.java:49: error: incompatible types: bad return type in lambda expression
linesTableCreate.setBeforeActionPerformedHandler(() -> {
^
missing return value
D:\Studio Projects\demo\Demo-Parameter\modules\gui\src\com\company\sales\gui\order\OrderEdit.java:52: error: incompatible types: bad return type in lambda expression
linesTableEdit.setBeforeActionPerformedHandler(() -> {
^
missing return value
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
FAILED
the exception is coming from the lines marked below:
The project was created a year ago on platform version 6.1. Since then, the BeforeActionPerformedHandler interface was changed (don’t remember in what version but certainly earlier than 6.7) and its method must return a boolean value indicating whether to execute the action. So the code should be as follows: