Create dialog window in JSF - jsf-2.2

I would like to create a usual dialog window:
The user clicks a link or button
The screen becomes blackish, a new window appears (a DIV is created)
By using Ajax, the DIV is populated with a form.xhtml
By clicking on a cross in the DIV, the DIV is removed and the blackish screen too.
I know how to do some of this stuff with usual CSS/Jquery. However, I am lost on how the JSF link/button should call the Jquery code to create the dialog (because I am supposing that JSF cannot do it alone) and make the Ajax call to get the form.
I am not using auxiliary libraries.

Related

Delphi - Application main form gets focussed incorrectly

In two parts of my application, the main form gets focussed at the wrong moment:
Bug 1. When clicking 'OK' from a specific printer form.
I open a FastReports PDF preview - that's the first popup. That popup is not shown seperately in the taskbar. This form is modal.
Then I click print,
That opens another window with standard printing options.
Then I click properties - that opens the specific form of the driver. I change the double printing setting.
When I click 'OK', the preview form (1) should be focussed, but the main form is brought to front. Because the preview form is still modal, it is hard to get back to the preview form. Only with random clicks, the preview form gets focussed again.
Bug 2. Clicking on or dragging this specific scrollbox focusses the main form
This window is active. This is a seperated window in the Windows task bar and is not modal. There is a gnostice pdf viewer on this form.
When I click the scrollbox to start dragging, the main form is brought to front. When I keep dragging, the scrolling at the pdf form still continues. Also, a tooltip near the mouse indicates what page is currently shown.
I want to solve this strange behaviour. So, my question is:
What can be causing these focussing bugs?
About the application:
I already noticed: the popup forms seems a bit too large, as you can see here:
see edit
Some forms are MDI child.
I searched in the code for all mouse events and put there breakpoints. But that code was not executed at the moment of the two bugs.
VCLskin is used.
Bug 1 occurs with Fast reports version 5.6.1 and 5.6.8.
Windows 10.
Delphi XE 10.2.
Edit
The application main form is set correctly. At startup, first a login form is shown. After your login, the datamodules are created, some forms are created without a owner (they are freed on application end).
All other forms, also the main form are owned by Application and not by the Login form. And indeed not as parent, but as owner, like #uwe-raabe said.
Then the main form is created. This is created via the Login form:
Frm_DatabaseLogin.CreateForm(TFrm_MainMenu, Frm_MainMenu);
That calls:
procedure TFrm_DataBaseLogin.CreateForm(InstanceClass: TComponentClass;
var Reference);
begin
Updateprogress(InstanceClass.ClassName);
Application.CreateForm(InstanceClass,Reference);
end;
In UpdateProgress nothing special happens.
After that, the other forms are created too, owned by application. At the end, the login form hides and therefore the main form is shown.
I'm making some assumptions here on your startup code.
"Main Form" can be a confusing term. From the TApplication point of view Application.MainForm is always the first form that is created using Application.CreateForm.
Since your login form creates your application's primary form and then hides itself, the login form is still the "main" form.
Your screenshot has two icons shown on the taskbar. I'm assuming you are either orverriding CreateParams or calling SetWindowLong to make that happen.
I have a similar setup with a "main" login form that is then hidden.
In my application, I override CreateParams for forms that should be standalone and have a taskbar icon:
procedure TMgrMain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := 0;
end;
Then when showing popups I create the form with an owner (probably not needed), and then set PopupMode and PopupParent. Since I started this I no longer have forms that pop-behind.
procedure ShowAbout(Owner: TForm);
var
LocalForm: TAbout;
begin
LocalForm := TAbout.Create(Owner);
try
LocalForm.PopupMode := pmExplicit;
LocalForm.PopupParent := Owner;
LocalForm.ShowModal;
finally
FreeAndNil(LocalForm);
end;
end;
From the PopupParent help:
If the PopupMode property is set to pmExplicit and PopupParent is nil,
then the Application.MainForm is implicitly used as the PopupParent.
If no Application.MainForm is assigned, then Application.Handle is
used as the PopupParent.
If the PopupMode property is set to pmAuto, Screen.ActiveForm is used
as the PopupParent property.
Part of where I took my steps from were from an old Peter Below newsgroup post. Also this is really old advice now and was before the addition of PopupParent/PopupMode
Newsgroups: borland.public.delphi.winapi
From: "Peter Below (TeamB)" <100113.1...#compuXXserve.com>
Date: 2000/11/30
Subject: Re: Modeless window act like .exe
.. cut ..
Note that this can cause
some problems with modal forms shown from secondary forms. If the user
switches away from the app while a modal form is up and then back to
the form that showed it the modal form may hide beneath the form. It
is possible to deal with this by making sure the modal form is
parented to the form that showed it (using params.WndParent as above)
but this is not possible with the standard dialogs from the Dialogs
unit and exceptions, which need more effort to get them to work right
(basically handling Application.OnActivate, looking for modal forms
parented to Application via GetLastActivepopup and bringing them to
the top of the Z-order via SetWindowPos).
.. cut ..
Finally here is a blog post that talks about why the changes to PopupMode and PopupParent were made.

refresh msflexgrid from another form

Working on some old code at the moment and a bit stuck
I have a main form that has a msflexgrid populated with data from SQL and on this form there is a button, which opens a modal form that allows me to enter data and save it to SQL (then closes the form).
The issue is the msflexgrid on the main form doesn't refresh after I save data from the modal, I need a way of automatically refreshing the msflexgrid after the modal form closes.
Any help would be appreciated :)
Maintain a global structure and update it when the changes are committed in the modal form. After modal form is unloaded, control comes back to the command button click event in main form and there, you update the msflexgrid with the data available in the global structure. Like this, explicitly we need to update the msflexgrid and it is not refreshed automatically.
It just hit me that because the second form is a modal form it only return to the main form when the second form unloads, so I can just add the refresh function right after showing the second form, I knew I was doing something stupid :/
Dim AddBusContact As New frmAddBusContact
AddBusContact.SetBusID (clsThisForm.BusID)
AddBusContact.Show (vbModal) 'code stops here until second form is unloaded
refreshgrid 'and I can just call the function that refreshes the grid here
I would suggest one more idea. If the modal form allows the user to cancel action, or to give up what started to do, probably it is better to trigger the grid refresh function before the modal form unloads and only if changes have been made...

MVC3 Navigation, browser positionin g

I have a C#.NET MVC3 web app. I have a View that has a List of Models. This list can be long, requiring the user to scroll down on the View. When selecting one of the models in the View to Edit, the user is taken to the Edit View. After submitting the Edit View, the user is redirected back to the List View. However, the List View is now displaying back at the top of the list. How can I redirect the user back to the same position in the List View where they clicked the Edit button?
You would probably be better suited using a modal popup dialog to edit the data, rather than navigating to another page.
While it's possible to do what you want, it's a pain. You would have to get the scroll location via javascript, save it to a hidden field, post that to your edit page, along with record number and anything else, then re-post it back to your original page when you return, then read the post value and scroll to it via javascript.
All that is avoided if you just use a modal edit dialog, then when the dialog goes away the page is still in the same place.

UPDATE (Event) PROBLEM WITH AJAX ACCORDION CONTROL

I Have three records which I want to display in three Accordion Panes
which (every pane) will have a Header and a content ( Two label controls, 1 text box and 1 checkbox and 1 link button)
I am able to display data on the accrodion from database but when I am trying to Update the text in textbox by clicking link button the LINKBUTTON doesnot fire and unabel to make the update. How can we create Update event working ??
I am creating the Accordion Panes and Content controls statically and directly assigning the values to the controls from Code behind in Page Load.
I was able to do it using the "ItemCommand" event of the Accordion Panel by using the Command Name property of a Link Button which will update the Text Boxes.
It works for me now but I felt JQUERY will be a better option which has no postback, css issues..

Monotouch UIScrollView and ModalView question

In my program I have the main window in the background which has a smaller, UIScrollView on it. I have buttons on each page of the scroll view which I want to bring up a modal view that can be dissmissed. It works fine for the first page, however, when I click the button on the second page of the scroll view the modal view that is brought up is on top of the first page instead of the second and the second page is completely blank. When I close the modal view, the first page has been replaced with the second page and the second page is still left blank... The code I am using is:
MVC = new NewsModalViewController(this);
MVC.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
MVC.ModalPresentationStyle = UIModalPresentationStyle.CurrentContext;
I've been trying to play around with the frames but having no luck...
Any insights?
Cheers
I would rewrite the subpages to fire an event that the parent view listens to. Then, display the modal from the parent view (you can actually create the modal in the child view and pass it up on the event). This eliminates any problems with the modal being applied to the wrong context.
There may be another explanation, but this is the method I've implemented on a couple applications and has served me well. It appears that modals are best displayed only from the highest level view in the stack.

Resources