Wicket: Modal Windows and callback functionality - ajax

I have a modal window that shows a panel which contains a form that has some textfields and a submit button
on submit an insert into the database occurs and then I have some ajax behaviour that i want to activate on the modal windows containing page on click of the button.
So flow is at present:
click link
modal window appears
user fills out form
user submits form
form data persisted to db
modal window closes
I need it to do this in addition:
activate some ajax behaviour on the page that contains the panel
any help on how best to do this in the wicket way is appreciated.

I resolved this by passing an instance of the page containing the panel to the panel (i.e. - in the constructor), then calling a method on the page from the panel to perform the Ajax update.
I would be interested to see what others have done or to hear if there are issues with the approach I have taken.

Set up a WindowClose callback.
In the WicketStuff project called ModelX (Disclaimer: I'm the developer of that) I have created an IWindowClosedListener interface which has a method:
void windowClosed(Panel panel, AjaxRequestTarget target)
So then any Page or Panel that can open a modal that needs to do something when that modal is closed simply implements that interface and its windowClosed method gets called at the right time.

Related

Livewire Event Causing Route Change Results in Nav Buttons Not Being Active

So I have this Laravel 9 project. In this view below you can see the navigation bar:
The menu above for the active link (Overview) styling (Tailwind) is active via the check below in the view for the component looking at the request information:
#if(request()->is('dashboard/*/overview'))
This works great as the url currently is
localhost/dashboard/{ID}/overview
When clicking the bottom nav link for the Dividends this fires a livewire event for this account as they don't have permissions to access the page. No navigation away from the page Overview is performed. This event is used to setup a popup when the user doesn't have access to a feature. (I have these in a few places)
The issue is that when one of these fires it sets the 'is' check value in the request to
/livewire/message/{COMPONENT_NAME}
This seems to be the expected behaviour of the livewire events. I attempted a similar check using the code below but the same result occurred as the data is still tied to the request.
#if(request()->pathInfo == "dashboard/7/overview")
If anyone knows of another way or a better way I could have the intended functionality so that the button keeps it's 'active' properties after a livewire event has ran, I'd appreciate it :)

How can I show new modal or update the existed one after an input submit in Slack via API?

I need to show new modal after the submit of the previous one, but I need a trigger_id for it, and there is nothing about it after the submit.
I can use views.update API only instead, and I have a valid response, but the submit button closes the window and nothing happens on the client side after it all.
Slack doesn't show an input in modals without a submit button, so I can't use alternative buttons in the modal too, because a user anyway can click on the submit button and it will be closed.
Is it possible to show or update the modal after an input submit? For example, I need to take a data from the input and show it in the modal after, is it possible?
You could try updating the view using the response_action. That needs to happen within 3 seconds, but doesn't require a trigger_id. Docs for that are here.

Modal dialog - refresh the parent page on close modal dialog or submit button

Using Apex 5.1.3
I have everyting working, but I have a requreimet to refresh the entire page (parent page) on the close of the modal page or press submit button.
I have tried quite a few things in dynamic actions on the parent page etc, but nothing is working.
How can I get the parent page to fully refresh when the modal dialog is submitted and closed.
Your help would be most appreciated.
Regards,
Morshed
You could either place a branch after processing on your modal that redirects to the parent page, or create a dynamic action 'on dialog close' on the button/region that invokes the dialog page, which then submits/refreshes the page.
If you think 'nothing is working', put APEX in debug mode, open your browser console, and check if the dynamic actions are actually firing.

How to close modal dialog windows from javascript

I have a page from which modal dialog page gets opened. After page is opened, the user makes some selections and clicks on the button and some javascript gets executed. After it is done, I need to close the modal page. I tried window.close() but it did not work. How can I close the modal dialog page from javascript?
Try this:
apex.navigation.dialog.close(true)
https://docs.oracle.com/cd/E59726_01/doc.50/e39149/javascript_api.htm#AEAPI30096
I have rarely seen the documentation on the method below. I had to read a book to find out.
Try this:
redirect to URL:
javascript:closeModal();
You can also pass the modal parameter if necessary:
javascript:closeModal('P2_HELP_MODAL');
You can also open the same way:
javascript:openModal('P2_HELP_MODAL');

spring form submission in a popup

I have a small problem in my first spring&hibernate application.
In my page, I would like to create a popup window (modal) which gives the possibility to send an email. So, this popup would display a spring form with a fied "subject" and a field "content".
The question is : how can I use the form binding mechanism of spring with this popup form if I don't want my main page (displayed behind the popup form) to be reloaded?
If i am not wrong, the content of the popup is a div present in the main page. So, If I submit the form in the popup, the whole page will be reloaded (through the mvc mechanism of spring) and this is exactly what I don't want.
Of course, I can submit my form via an ajax call to a spring controller, but in this case, how to handle the eventual errors in the form? I cannot use the spring form binding mechanism to display the errors on the popupform. Is it possible?
Do you know if there is a way to open a new window in a modal popup? So that this page and only this page would be reloaded during the submission of the form?
Actually, I am not sure of the best way to combine a popup containing a form and the form submission mechanism of spring. How to display the errors on the form in case of errors? after reload of the page, If there are some errors, I need to open my popup again in javascript and then display the errors on the popup, this is the only mean I see, but maybe there are easier solutions.
If you have, I would be happy to know it.
thanks a lot

Resources