Automatically closing a popup (action-view) with grid-only after a toolbar action

Hello everyone,

I’m struggling with closing a popup opened via an action-view that only contains a grid view.

I added a button in the toolbar that performs an action on the selected rows. I would like the popup to close automatically once the action is done… but neither the XML action close nor response.setCanClose(true) in the controller actually close the window.

Environment

  • Axelor Open Platform: 7.x
  • Context: popup opened by action-view with <view type="grid"> only (no form/wizard)

Minimal reproduction (XML + Java)

1) Opening the popup (action-view)

<action-view name="my.lines.select.popup" model="com.example.db.MyLine">
  <view type="grid" name="my-line-grid"/>
  <view-param name="popup" value="true"/>
  <view-param name="title" value="Select lines"/>
</action-view>

2) Grid with toolbar button

<grid name="my-line-grid" model="com.example.db.MyLine">
  <toolbar>
    <!-- Run the action on the selected rows and (ideally) close the popup -->
    <button name="btnApply" title="Apply"
            onClick="my.applySelection,close"/>
  </toolbar>
  <!-- columns… -->
</grid>

<!-- Action wrapping the controller call -->
<action-method name="my.applySelection" model="com.example.db.MyLine">
  <call class="com.example.web.MyLineController" method="apply">
    <arg name="ids" expr="__ids__"/> <!-- selected rows -->
  </call>
</action-method>

3) Java controller

public class MyLineController {

  @SuppressWarnings("unchecked")
  public void apply(ActionRequest request, ActionResponse response) {
    List<Long> ids = (List<Long>) request.getContext().get("ids"); // passed from action-method
    // ... business logic on the selected rows ...

    // Attempts to close the popup:
    // 1) XML action: onClick="my.applySelection,close"  --> does not close
    // 2) Java side:
    response.setCanClose(true);  // also doesn’t close in this "grid-only" context
    // (I’m not doing any response.setView(...) afterwards)
  }
}

Expected behavior

  • After clicking “Apply”, the action runs correctly and the popup closes.

Actual behavior

  • The action executes correctly but the popup remains open.

What I’ve already tried / checked

  • Chaining ,close after an action-method (not calling class: method directly).
  • Using response.setCanClose(true) at the end of the controller method.
  • I also tried using a button with only close (without my custom action), but that didn’t work either.

Questions to the community

  1. Is this an expected behavior/limitation of “grid-only” popups opened with action-view? Are close and/or setCanClose(true) ignored in this context?
  2. Is there a recognized way to force closing a grid popup after a toolbar action (e.g., some intermediate action, additional view parameter, etc.)?
  3. Does anyone have a working example (XML/Java) where a grid toolbar button in a popup executes an action on __ids__ and closes the popup afterwards?

Thanks in advance for any help or hints

Not long ago I read the topic regarding popup closing. It can be your case also.
Recommended solution was to move close to the button attribute

<button name="cancelConfirmBtn" title="Confirm cancellation" colspan="4" coloffset="4" onclick="action production-order-the-cancel,close"/>

and remove it from controller

Found it here

Hope it helps!