Primefaces - using dialogs and layouts - primefaces

I have a (JSF 2.0/ Primefaces 2.2RC-SNAPSHOT) app that has
<p:layout>
I use a lot of dialog in my application and before the newest version of primefaces came out there was no way to display a dialog with a modal on top of the layout without putting the dialogs outside of the tags.
So I did just that. The issue I am having now is I am noticing that constructors and postcontructs are being called when my application is loaded. This is because the view with the layout is being loaded and therefore all my dialogs are being loaded.
I don't want these constructors being called until I am actually dealing with the appropriate views in my application.
I have been testing the appendToBody attribute on the
<p:dialog>
tag but it seems really buggy. Everything works fine on the initial rendering of a view. I can open a dialog close it etc and it works fine. If I navigate away to another view and then come back to the initial view and open the dialog, everything is running off the page. The dialog window is in the correct place but the content is not.
My question is 1. Is there a way I can have the dialog windows outside of my layout as a child of the
<h:body>
without having all the managed bean constructors associated with them initiated when the application loads?
Or does anyone know how to fix the alignment issue when using the appendToBody tag? Thanks.

When using layout and dialog, I usually place my dialogs outside of the layout as a direct child of the body element. I have a special ui:insert part in my page template for this.
appendToBody was added to make this easier, if it doesn't work well for you, give this approach a try. I know modal dialogs and layout can work this way.

without having all the managed bean constructors associated with them
initiated when the application loads
Maybe the managedbean gets loaded when your dialog is rendered.
Try rendering the dialog only after the button click, perhaps byputting rendered="#{mybean.flagLoadMyDialog}" on the dialog, and set the flagLoadMyDialog when the button is clicked using ajax.
Also remember to ajax-update the dialog after the button click.

Related

Modify DOM in content-script as a replacement for the non-ability to trigger pop-ups programmatically?

I'm working on an extension that's supposed to use the content of the page to determine whether to show an interface to the user.
The ways to show an interface, if I'm correct, are using a browser action or a page action.
And neither can be triggered programmatically. But content scripts could be written to inject an equivalent GUI into the webpage.
So, does it make sense to modify the DOM using content-scripts to display an interface as a substitute for page action? It seems like an obvious work around to me, and I'm sure there are good reasons to not let page actions be triggered programmatically.
Well, modifying DOM must be done by only Content Scripts, as that is the reason they exist.
Want to fetch any data from current page, alter anything in the page, add new UI in the page - whatever, content script will help you do that.
It has nothing to do with Page script Or Browser Script.
YES, you can not programatically trigger page/browser action. It has to be done by explicit clicking.
But if you want to open a UI by clicking a chrome extension, then there is a popup js for that.

Yii2 nested pjax

I have page with tabs (which are actually links handled by parent pjax). Which loads the tab content via pjax calls.
In one of the tabs, I have a gridview which is inside a pjax container. So that makes it a nested one.
The problem is that the nested one when loaded and inserted into the page, does not include it's own javascript i.e:
jQuery(document).pjax("#history-gridview a", "#history-pjax", {"push":true,"replace":false,"timeout":5000,"scrollTo":false});
You need to call renderAjax() when requesting the tab page (or content). I do something like this:
if (Yii::$app->request->isAjax) return $this->renderAjax('myview');
else return $this->render('myview');
However, it may not fix your problem. I've found if I navigate tabs and a grid is loaded dynamically in the tab (with its own pjax container), then any interaction with grid sort and filter tries to reload from the outer (pjax tab) container even with skipOuterContainers set to true.
On a side note, the developers are thinking of dropping pjax support completely as per here as well as how asset bundles work.
The question remains:
How to create super fast performance like an SPA (single page app)
without Angular2 or similar? The grid container within a tab container
is the perfect example which, if could be achieved (catering for
back/forward buttons, initialisation scripts) would be awesome.

Content Dialog template in Visual Studio C#

I'm starting to learn Windows 8.1 phone development and I am trying to get the Content Dialog template to work inside a Pivot page. Work some reason, when I try to get the Add app bar button to navigate to the ContentDialog.xaml page, it is not displaying, but I see the navigate go to the ContentDialog constructor where the this.InitializeComponent() occurs.
I am finding very little online in way of examples on this template, so I am at a loss as to what I am missing. I understand that the ContentDialog page that was created from the template is inheriting from ContentDialog and not Page, but I'm not sure if this is still supposed to be directly accessed or if this XAML is supposed to be inside another "Page" XAML file.
Can someone please help.
The code looks like this in the Pivot page when the click event is selected:
Frame.Navigate(typeof(ContentDialog1));
I really haven't even touched the ContentDialog template from it's default yet, so it is set up like a set password page.
Thanks in advance
UPDATE
I found the answer to my question above. apparently, because it is a Content control, it needs to be called like a normal dialog would need to be called in it's code behind. I think my missconseption was that I thought it being "a template", that when I called it with the navigation calls that it would already have everything needed to get fired. You can also add the Content control to an existing page if you would like.
In either scenario, you need to add a method similar to this in your XAML.CS file.
private async void OpenDialog()
{
await this.contentStuff.ShowAsync();
}
You then need to call this method in the constructor. Then, when called, your dialog will appear.
Hope this helps others just starting out.

Flex 4 (Air) - ShowDialog-like behavior

The ShowDialog function in VB.NET allows a child window (form) to be opened in front of another without letting the user interact with the parent window until the child is closed.
To see what I'm referring to (in Windows), open up notepad, click help > about, and then click back on the main window. You'll notice that the dialog flashes and makes a noise. That happens with dialogs in a great many applications, and that is what I'm trying to achieve.
I can't seem to find any way to replicate this in Flex 4 (Air) applications. Any suggestions?
EDIT 2
Based on your comment, you then have to create a new window component(mxml component with the functionality and interface you want defined in it) and can then attach it to the click event of the link/button on the main window. And for the focus issue you can use setFocus from IFocusManager component

ASP.NET 4 UpdatePanel breaking change

I am porting an ASP.NET application from 3.5SP1 to 4.0. The application works perfectly in 3.5SP1. In 4.0, I am seeing a difference in UpdatePanel behavior.
We have a simple user control with a testbox, a button, and some text. The user control lives inside an UpdatePanel with UpdateMode="Conditional" and ChildAsTriggers="true".
Users type into the textbox and click the button. We do a search. If we find something, content elsewhere on the page is updated - this works great. If we don't find it, we change the text in the user control. That change never appears.
So I know the button and logic is working. The user control does not own the UpdatePanel it lives in, and it would be nice if it didn't have to. But even though the button is raising an event back to the server, the update panel content is not updating.
Has anyone seen this?
My problem turned out to be 4.0's new client-ID mechanism. Check out the new features here.
4.0 defaults to 'Inherit' while 'autoID' is the 'old' behavior. By adding this to the web.config pages element:
clientIDMode="AutoID"
my problem went away. I'm not wild about forcing backward-compatible behavior but until I can sort thru all the control relationhips this will have to do.