Sending parameters from composite table to next screen

The following code snippet helps sending parameter to calling lookup screen through lookup button:

@Named("fieldGroup.customerProfile")
private LookupPickerField customerProfileField;
PickerField.LookupAction customerLookupAction;// = customerProfileField.getLookupAction();
   @Override
public void init(Map<String, Object> params) {
    super.init(params);
    //2. To pass parameter to customerProfile.browse scree
    customerLookupAction = customerProfileField.getLookupAction();
    customerLookupAction.setLookupScreenParams(ParamsMap.of("isRetailCustomer", "no"));
}`

Is it Possible We can do the same from composite table in the screen? for example,

I have production recipe where operation is used at line item level (composit). When I select the Operation, the resources associated with that operation needs to be selected. for which I want to pass the parameter “operation” to lookup of resources.

Hi,

You can use, for example, CellClickListener, or a generated column with custom logic.

linesTable.setClickListener("product.name", (item, columnId) ->
        openLookup("sales$Product.browse", null, WindowManager.OpenType.NEW_TAB, ParamsMap.of("orderLine", item)));

Or something like that:

linesTable.addGeneratedColumn("product.name", entity -> {
    LookupPickerField pickerField = componentsFactory.createComponent(LookupPickerField.class);
    pickerField.setDatasource(linesTable.getItemDatasource(entity), "product");
    pickerField.setOptionsDatasource(productsDs);
    pickerField.getLookupAction().setLookupScreenParams(ParamsMap.of("OrderLine", entity));
    return pickerField;
});

Hi Shiryaeva
Thanks. Having hints from your code, now I am thinking of refreshing the resource data source when the resource cell is clicked based on the operation selected.

I have initialized a data source in editor screen
select e from erp$Resource e where e.operation.id = :custom$operationId

then used the following initilized code but getting the following NPE
recipeLineTable.setClickListener("recipeLine.resource",(item, columnId) -> { resourcesDs.refresh(ParamsMap.of("operationId", recipeLineDs.getItem().getOperation().getId())); });

java.lang.NullPointerException
at com.haulmont.cuba.web.gui.components.WebAbstractTable.setClickListener(WebAbstractTable.java:2660)
at com.inteacc.erp.web.pp.recipe.RecipeEdit.postInit(RecipeEdit.java:122)
at com.haulmont.cuba.gui.components.AbstractEditor.setItem(AbstractEditor.java:72)
at com.haulmont.cuba.gui.WindowManager.openEditor(WindowManager.java:888)
at com.haulmont.cuba.web.WebWindowManager.openEditor(WebWindowManager.java:178)

There must be an error somewhere in your code that causes a NPE, hard to say exactly without debugging.

Hi Olga
I have prepared a sample app to demo it and you may please use it to finish what is lacking here.

Before you use the recipe editor, please update the following data:

  1. create 2 records in Operation: Operation 1, Operation 2
  2. Create 2 records in Resource: Resource A, Resource B and use operation 1 & 2 respectively

Then go to Recipe, edit.create a new line in the table, select Operation. What I am expecting here that when we click Resource, it is filtered by the Operation selected.
tableCellClickDemo.zip (42.1 KB)