return $wnd.itmtk.appUri;
}-*/;
+ private native String getPathInfo()/*-{
+ return $wnd.itmtk.pathInfo;
+ }-*/;
+
private void makeUidlRequest(String requestData) {
console.log("Making UIDL Request with params: " + requestData);
rb = new RequestBuilder(RequestBuilder.POST, appUri
- + "/UIDL/?requestId=" + (Math.random()) + "&" + requestData);
+ + "/UIDL" + getPathInfo() + "?requestId=" + (Math.random()) + "&" + requestData);
try {
rb.sendRequest(requestData, new RequestCallback() {
public void onError(Request request, Throwable exception) {
+ uidl.getTag()
+ ", but there is no such paintable ("
+ uidl.getId() + ") registered yet.");
- if(uidl.getId().equals("PID0")) {
- // view
view.updateFromUIDL(uidl, this);
- } else {
- Widget window = widgetFactory.createWidget(uidl);
- registerPaintable(uidl.getId(), (Paintable) window);
- RootPanel.get().add(window);
- ((Paintable) window).updateFromUIDL(uidl, this);
- }
- }
+ }
} catch (Throwable e) {
e.printStackTrace();
}
import java.util.HashSet;
import java.util.Iterator;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
}
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+ // Start drawing from scratch
clear();
+
+ // Some attributes to note
theme = uidl.getStringAttribute("theme");
com.google.gwt.user.client.Window.setTitle(uidl.getStringAttribute("caption"));
- UIDL childUidl = uidl.getChildUIDL(0);
+
+ // Process children
+ int childIndex = 0;
+
+ // Open URL:s
+ while (childIndex < uidl.getChidlCount() &&
+ "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
+ UIDL open = uidl.getChildUIDL(childIndex);
+ String url = open.getStringAttribute("src");
+ String target = open.getStringAttribute("target");
+ Window.open(url, target != null ? target : null, "");
+ childIndex++;
+ }
+
+ // Draw this application level window
+ UIDL childUidl = uidl.getChildUIDL(childIndex);
Paintable lo = (Paintable) client.getWidget(childUidl);
if(layout != null) {
if(layout != lo) {
}
lo.updateFromUIDL(childUidl, client);
- int i=1;
+ // Update subwindows
HashSet removedSubWindows = new HashSet(subWindows);
- while ((childUidl = uidl.getChildUIDL(i++)) != null) {
+
+ // Open new windows
+ while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {
if ("window".equals(childUidl.getTag())) {
Widget w = client.getWidget(childUidl);
if (subWindows.contains(w)) {
((Paintable)w).updateFromUIDL(childUidl, client);
}
}
+
+ // Close old windows
for (Iterator rem=removedSubWindows.iterator(); rem.hasNext();) {
IWindow w = (IWindow) rem.next();
client.unregisterPaintable(w);
String uri = request.getRequestURL().toString();
boolean hasSlash = (uri.charAt(uri.length()-1) == '/') ? true : false;
+ String relative = "";
+ String t = request.getPathInfo().substring(1);
+ while (t.indexOf('/')>=0) {
+ t = t.substring(t.indexOf('/')+1);
+ relative += "../";
+ }
+
+
page
.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
page.write(appUrl);
- page.write("'\n};\n" +
+ page.write("', pathInfo: '"+request.getPathInfo()+"'\n};\n" +
"</script>\n" +
- "<script language='javascript' src='"+ (hasSlash ? "../" : "") + "com.itmill.toolkit.terminal.gwt.Client/com.itmill.toolkit.terminal.gwt.Client.nocache.js'></script>" +
+ "<script language='javascript' src='"+ (hasSlash ? "../" : "") + relative + "com.itmill.toolkit.terminal.gwt.Client/com.itmill.toolkit.terminal.gwt.Client.nocache.js'></script>" +
"<link REL=\"stylesheet\" TYPE=\"text/css\" HREF=\""+request.getContextPath() + THEME_DIRECTORY_PATH+themeName+"/style.css\">" +
"</head>\n<body>\n" +
// Reset sent locales
locales = null;
requireLocale(application.getLocale().toString());
-
- // Adds all non-native windows
- for (Iterator i = window.getApplication().getWindows()
- .iterator(); i.hasNext();) {
- Window w = (Window) i.next();
- if (!"native".equals(w.getStyle()) && w != window)
- paintables.add(w);
- }
+
} else
paintables = getDirtyComponents();
if (paintables != null) {
outWriter.print(", \"meta\" : {");
boolean metaOpen = false;
- // .. or initializion (first uidl-request)
- if (application.ajaxInit()) {
- outWriter.print("\"appInit\":true");
- }
// add meta instruction for client to set focus if it is set
Paintable f = (Paintable) application.consumeFocus();
if (f != null) {
// Find the window where the request is handled
String path = request.getPathInfo();
+
+ // Remove UIDL from the path
+ path = path.substring("/UIDL".length());
// Main window as the URI is empty
if (path == null || path.length() == 0 || path.equals("/"))
* @author IT Mill Ltd.
* @version
* @VERSION@
+ * @deprecated
* @since 3.0
*/
public class FrameWindow extends Window {
/**
* Sets the name.
* <p>
- * The name of the window must be unique inside the application. Also the
- * name may only contain the following characters: a-z, A-Z and 0-9.
+ * The name of the window must be unique inside the application.
* </p>
*
* <p>
"Window name can not be changed while "
+ "the window is in application");
- // Checks the name format
- if (name != null)
- for (int i = 0; i < name.length(); i++) {
- char c = name.charAt(i);
- if (!(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9')))
- throw new IllegalArgumentException(
- "Window name can contain "
- + "only a-z, A-Z and 0-9 characters: '"
- + name + "' given.");
- }
-
this.name = name;
}