Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ClientCallable documentation issues, must reference @AllowInert #17496

Closed
jflamy opened this issue Aug 24, 2023 · 2 comments · Fixed by vaadin/docs#3111 or vaadin/docs#3147
Closed

@ClientCallable documentation issues, must reference @AllowInert #17496

jflamy opened this issue Aug 24, 2023 · 2 comments · Fixed by vaadin/docs#3111 or vaadin/docs#3147

Comments

@jflamy
Copy link

jflamy commented Aug 24, 2023

Description of the bug

  1. The v24 documentation for @ClientCallable only mentions Polymer, making the reader doubt that it applies to LitElement.
    When in fact, elsewhere it is mentioned that ClientCallable is the correct way to call back instead of propagating events.

  2. The documentation to @ClientCallable MUST explain when @AllowInert is be needed. I just lost 2 days trying to figure out why something worked in v14 and v23 but not in v24:

    • even though the need for AllowInert is said to have been introduced in v23, my code ported from v14 to v23 worked fine without @AllowInert
    • but in v24, if a page starts a modal dialog but has a running web component (for example a timer) in the background, then @clientcallable calls don't work.

Expected behavior

N/A, documentation
Or maybe make AllowInert the default, as it is completely counter-intuitive.

Minimal reproducible example

N/A

Versions

Vaadin: 24.1.4
Flow: 24.1.5
Java: JetBrains s.r.o. 17.0.6
OS: amd64 Windows 11 10.0
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54
Live reload: Java unavailable (HotswapAgent): Front end unavailable

@mshabarov
Copy link
Contributor

@jflamy thank you for the issue! Just checked and @AllowInert explanation is missing on the online documentation website, indeed. For better understanding and further work on docs, could you please provide your use case and codes that doesn't work?

@jflamy
Copy link
Author

jflamy commented Aug 29, 2023

The code that does not work is trivial, and the need for @AllowInert is mysterious to me. I have a dialog to manage a LitElement Timer. The dialog tells calls a method in its parent page to show the timer and start it. There is no threading involved, the timer is entirely JavaScript.
image

When the timer expires, it simply does a callback to the Java UI.

this.$server.clientTimeOver(this.fopName);

Without @AllowInert, the code simply does not get called. It does not matter if the dialog is still open or not.

@AllowInert
@ClientCallable
public void clientTimeOver(String fopName) {
	logger.debug("{}Received time over.", fopName);
	getFopTimer(fop).timeOver(this);
}

The only case where the time over routine is not called in the modal dialogue scenario.

The exact same timer component is used at several locations in the program. Indeed, the "1:00" next to the red box in the screenshot is another instance of the timer, which always works -- it is started from the background page itself, or from events occurring in other UIs. Removing that second timer does not change anything, all the IDs are correct and all events go to the proper destinations.

Adding @AllowInert fixes the problem and everything works as expected. There was no need for this @AllowInert in v14 and v23.

mcollovati added a commit to vaadin/docs that referenced this issue Jan 9, 2024
Adds a note about the usage of AllowInert annotation to allow RPC calls
to components behind a modal dialog or component.

Fixes vaadin/flow#17496
tepi pushed a commit to vaadin/docs that referenced this issue Jan 29, 2024
* docs: add note about AllowInert on RPC calls

Adds a note about the usage of AllowInert annotation to allow RPC calls
to components behind a modal dialog or component.

Fixes vaadin/flow#17496

* First pass at editing.

* Second pass -- edited rest of document touched.

---------

Co-authored-by: russelljtdyer <[email protected]>
mcollovati added a commit to vaadin/docs that referenced this issue Jan 29, 2024
Adds a note about the usage of AllowInert annotation to allow RPC calls
to components behind a modal dialog or component.

Fixes vaadin/flow#17496
---------

Co-authored-by: russelljtdyer <[email protected]>
tepi pushed a commit to vaadin/docs that referenced this issue Jan 29, 2024
Adds a note about the usage of AllowInert annotation to allow RPC calls
to components behind a modal dialog or component.

Fixes vaadin/flow#17496
---------

Co-authored-by: russelljtdyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants