I wanted to use window.name as a holder for some identifier to use whenever page refresh happens (or being forced). However, I've noticed that GWT sets it to rename-to property value defined in module definition. Is there any way to avoid it?
P.S. I know I can use sessionStorage, or maybe even some other mechanism. I'm just curious about this specific case -- would like to know how could I override such GWT behavior.
Are you sure the window is getting its name changed? I recall that the module changes the iframe that it loads into, but not the global window. Or are you using a different linker? Or referring to the window as window in your jsni instead of $wnd?
private native void setWindowName(String newName) /*-{
$wnd.name=newName;
}-*/;
Related
In my e4 application, I am using the default ISaveHandler(which i have not defined explicitly anywhere) as shown in the image.
I just need to update the icon, title & text of this handler, rest works fine for me for single mPart save or multiple mPart save prompt.
I don't want to create my own save handler UI. Even if I could inherit the original one, that will work for me.
[
That dialog is an inner class of org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer so you can't get at it. I don't think you have any choice but to write your own ISaveHandler and the dialog.
You might be able to use org.eclipse.e4.ui.internal.workbench.PartServiceSaveHandler to do some of the work.
To use your save handler everywhere set it in the main window context. (see this question).
I'm using Magnolia 5.4 and have developed an app following the documentation:
https://documentation.magnolia-cms.com/display/DOCS54/Apps
The app is being rendered correctly in the magnolia shell.
Opening the app shows a «Hello World» message as described in the documentation:
https://documentation.magnolia-cms.com/display/DOCS54/Programming+an+app#Programminganapp-MainSubApp
I've removed the unnecessary code and ended up with this:
public class HelloWorldMainSubAppViewImpl implements HelloWorldMainSubAppView {
private VerticalLayout layout = new VerticalLayout();
private Listener listener;
public HelloWorldMainSubAppViewImpl() {
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponent(new Label("Hello World!"));
}
#Override
public Component asVaadinComponent() {
return layout;
}
}
Instead of using the Label component I would like to use a FreeMarker template where I define a custom view.
Having read through the documentation I haven't figured out yet how to do this.
Here is the solution to my problem, based on the previous work.
This is the «EmbeddedPageSubApp» approach as described under «Custom App»
Create a regular page somewhere in your navigation.
Open the Configuration app, go to /modules/<APP_NAME>/apps/<APP_NAME>/subApps/main and add a url property to the mainSubApp with an absolute path to the previously created page.
Change value of the class property /modules/<APP_NAME>/apps/<APP_NAME>/subApps/main to info.magnolia.ui.framework.app.embedded.EmbeddedPageSubAppDescriptor
Change the value of the subAppClass property to info.magnolia.ui.framework.app.embedded.EmbeddedPageSubApp
If you don't want that page to be visible restrict its access within 'superuser' group / role so that only administrators can use it.
This binds that with an iframe. You should choose a blank template since the navigation elements of the embedded page are visible within the app.
I might be wrong here but to my knowledge Freemarker is only used to create templates and unfortunately limited to it. https://documentation.magnolia-cms.com/display/DOCS60/Template+scripts
On the other hand, What you want to do is to develop your custom app and here is an example of how to do that.
https://documentation.magnolia-cms.com/display/DOCS54/My+first+content+app
Also, if you are motivated to move to latest Magnolia version, you can define your custom app pretty easily using Content Types.
Hope that helps,
Cheers,
I am currently working on a GWT project where I am displaying an HTML file within an iframe in my application. This HTML file is actually being written to as it is getting displayed, and I am hoping to be able to reload the frame so that the changes made to the HTML file are reflected on screen. I am able to do this two different ways that both work when running in development mode, however neither seem to work when the project is deployed.
The first method I tried was setting the frame's URL to itself:
frame.setUrl(frame.getUrl());
The second method I tried using JSNI:
public native void refresh() /*-{
if($doc.getElementById('__reportFrame') != null) {
$doc.getElementById('__reportFrame').src =
$doc.getElementById('__reportFrame').src;
}
}-*/;
When deployed, the frame gets displayed in a Window, and when the file is finished being written to, a call to either of these refresh methods is made, and the frame refreshes to contain the finished HTML file. When I am deployed, the call to refresh does not reload the contents of the frame, however if I bring up the frame's context menu (in Firefox), then go into 'This Frame', and click Reload, it successfully reloads the frame to contain the finished HTML file. I have tested this on multiple versions of Firefox without any luck.
Does anyone have any suggestions? Why would the behavior be different from one mode to the other?
Thanks.
wow, google is really fast with his search^^
You can use some JSNI to do this. Create a method such as
protected native void reloadIFrame(Element iframeEl) /-{
iframeEl.contentWindow.location.reload(true); }-/;
Then call it with your iFrame element
so your question you posted twice was already answerd here
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/64aa7712890652d3
We had a requirement where one GWT application(parent) had another GWT application(child) loaded in an iframe. The child application had to refresh the iframe after it performs certain DB operations. We used JSNI to accomplish the same.
private native void refreshChild(String url)/*-{
$wnd.location.href=url;
}-*/
In case, if the child frame needs to be redirected to another webpage, the url can be modified accordingly.
We did try to use the reload() method, but it did not help.
The above piece of code, of course needs to be written in the child application.
We use MVP with custom EventBus to navigate across the views. One of our GWT module loads an ebook within a view. We have a button named "Expand", which upon clicked, loads the ebook in expanded mode thereby hiding the header, footer, etc.
Let us say the view (UiBinder) with "Expand" button is named as "ShowEbookView". Upon clicking "Expand" button, the ClickEvent is captured and fired to the EventBus. The logic onExpand(final ExpandEvent expandEvent) is written in the same "ShowExpandedMod" class.
Everything is okay, but we have a button named "Popout" in the expanded mode, which when clicked, should open the Ebook in a NEW page! We need to abstract the "ShowExpandedMod" class so that it can operate with the EbookId and can be used in the new page.
We have created a new Module with EntryPoint class, HTML page and UiBinder page for this new popout window. I am not sure how to proceed now with the abstraction and to use EventBus across different modules to load the same content ... (with re-usability ofcourse)
I've explained to my best, but perhaps not very clear! Please let me know if you want more details.
Thanks!
When you open a new window in browser you basically get a new instance of your GWT app. You can not use EventBus across different browser windows, i.e. across different GWT module instances.
What you can do is:
Add an argument to the Popout page URL. This is easies done via "history tokens" (fragment identifiers), like this http://yourdomain.com/popout.html#theIdOfTheDocument. Then you can retrieve the token via History.getToken()
Use DOM to communicate between browser windows: window.open() in javascript opens a new window and returns a reference to DOM of the new window. You can then access properties and functions of the new window. This is all javascript, in order to make this work in GWT you'll need to wrap it in JSNI.
Try and use MVP4G, in specific - take a look at their multi-modules feature (which utilizes GWT's code splitting capabilities).
This should make things like multiple EventBus's and cross-module event triggers a lot easier to handle.
Before you start shooting me down i have checked for answers and i have googled till my fingers bled but i havent been able to find a simple, concise answer. So im asking again for all those that might have this problem.
Question: how to open a new window with a formpanel in side.
Context: i have an app that lists lots of items, i want someone to edit an entry, i want a new window to open so they can edit properties then hit save. A standard thing you find in a lot of applications.
Architecture:
I have one client module called UI, it has a dozen classes that draw widgets and fill a main area when selected from a menu. I have a single html page called UI.html which has the tag in the head. Thats it.
Options Ive Seen
Call Window.Open() but you need to define a html file. I dont have one. I can create an empty one but how do you inject a widget in to it ?
use jsni $wnd to create a new window and get a reference to it. But how do i inject a form panel into it ??
use a popuppanel. They look sucky - plus if opening a window through JS is quite simple i would expect it to be in gwt.
Maybe im miss understanding how to use GWT i dont know.
Any help would be appreciated
Thanks
The way i got this to work is as follows:
i wrote a jsni method to open a new window
public static native BodyElement getBodyElement() /*-{
var win = window.open("", "win", "width=940,height=400,status=1,resizeable=1,scrollbars=1"); // a window object
win.document.open("text/html", "replace");
i added a basic body to the new window and returned the body element
win.document.write("<HTML><HEAD>"+css1+css2+"</HEAD><BODY><div class=\"mainpanel\"><div style=\"width: 100%; height: 54px;\"><div id=\"mainbody\"class=\"mainbody\" style=\"width: 100%;\"></div></div></div></BODY></HTML>");
win.document.close();
win.focus();
return win.document.body;
}-*/;
i then called this method from my main java method
BodyElement bdElement = getBodyElement();
I then injected my panel which has lots of widgets into the returned body element
SystemConfiguration config = new SystemConfiguration(); bdElement.getOwnerDocument().getElementById("mainbody").appendChild(config.getElement());
I agree with Bogdan: Use a DialogBox.
If you can't, you Window.open() as you mentioned in option 1:
Create another GWT module, and form.html that will load it
Window.open("form.html?entry=54")
Have the form gwt module read from the URL, load the entry, allow it to be edited, and provide Save and Cancel buttons
Close the popup when Save or Cancel is clicked
Can't you just use a DialogBox?
Example