/** * @param evtnm the event name to echo back * @param data the data to sent with the event when echoed back * @param dt the desktop to receive the event. */ public AuEchoGlobal(String evtnm, String data, Desktop dt) { super("echoGx", new String[] { evtnm, data, dt.getId() }); }
/** * Creates a new performance data instance associated with the specified desktop. * * @param desktop desktop. */ public PerformanceData(Desktop desktop) { desktopId = desktop.getId(); }
/** Constructs an echo response with the specified desktop. * * @param desktop the desktop to send the echo response to. * If null, the echo response is sent to each desktop in the * same browser window. * @since 3.0.0 */ public AuEcho(Desktop desktop) { super("echo", desktop != null ? desktop.getId() : null); }
/** Constructs a client-info response with the specified desktop. * * @param desktop the desktop to get the client info back. * If null, the client info is sent back for each desktop in the * same browser window. * @since 3.0.0 */ public AuClientInfo(Desktop desktop) { super("clientInfo", desktop != null ? desktop.getId() : null); }
public String getId() { return desktop.getId(); }
private static String[] toArray(String evtnm, String data, Collection<Desktop> dts) { final List<String> l = new LinkedList<String>(); l.add(evtnm); l.add(data); for (Desktop desktop : dts) l.add(desktop.getId()); return l.toArray(new String[l.size()]); } }
public void addDesktop(Desktop desktop) { //final boolean added; final Desktop old; synchronized (_desktops) { old = _desktops.put(desktop.getId(), desktop); } if (old != null) { _desktops.put(old.getId(), old); //recover if (log.isWarnEnabled()) { log.warn(desktop == old ? "Register a desktop twice: " + desktop : "Replicated ID: " + desktop + "; already used by " + old); } } //if (log.isDebugEnabled()) log.debug("After added, desktops: "+_desktops); }
/** Handles the (client and) server start of load request * for the performance measurement. * * @return the request ID */ private static String meterLoadStart(PerformanceMeter pfmeter, Execution exec, long startTime) { //Future: handle the zkClientStart parameter final String pfReqId = exec.getDesktop().getId(); try { pfmeter.requestStartAtServer(pfReqId, exec, startTime); } catch (Throwable ex) { log.warn("Ingored: failed to invoke " + pfmeter, ex); } return pfReqId; }
public void removeDesktop(Desktop desktop) { final boolean oldexp = _desktops.disableExpunge(true); try { final Desktop old; synchronized (_desktops) { old = _desktops.remove(desktop.getId()); } if (old == null) log.warn("Removing non-existent desktop: " + desktop); else desktopDestroyed(desktop); } finally { _desktops.disableExpunge(oldexp); } }
/* package */OperationThread(Desktop desktop) { _desktop = desktop; _queue = new OperationQueue(); this.setName("OPThread-" + desktop.getId()); }
/** Sets the delay between each polling request. * <p>Default: use the preference called * <code>PollingServerPush.delay.min</code> * <code>PollingServerPush.delay.max</code>, * and <code>PollingServerPush.delay.factor</code>. * If not defined, min is 1000, max is 15000, and factor is 5. */ public void setDelay(int min, int max, int factor) { Clients.response( new AuScript(null, "zkau.setSPushInfo('" + _desktop.getId() + "',{min:" + min + ",max:" + max + ",factor:" + factor + "})")); }
/** * Remove desktop security context on desktop cleanup. */ @Override public void onCleanup(Desktop desktop) { HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); session.removeAttribute(getDesktopContextKey(desktop.getId())); }
/** Returns the result in the JavaScript. * The caller shall send it back and evaluate it at the client (<code>eval(jscode);</code>). * <p>After calling this method, the caller shall not modify the component's state any more. */ public String getResult() { final Desktop desktop = _exec.getDesktop(); try { JSONArray result = ((WebAppCtrl) desktop.getWebApp()).getUiEngine().finishUpdate(_updctx); return new StringBuffer(512).append("zAu.doCmds('").append(desktop.getId()).append("',") .append(result.toString()).append(");").toString(); } catch (Exception ex) { //not possible throw UiException.Aide.wrap(ex); } }
/** * Given a desktop, returns Spring security context object. * * @param desktop The desktop whose security context is sought. * @return SecurityContext The Spring security context. */ public static SecurityContext getSecurityContext(Desktop desktop) { String key = getDesktopContextKey(desktop.getId()); HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); return (SecurityContext) session.getAttribute(key); }
/** Returns the JavaScript codes to disable (aka., stop) the server push. * It is called by {@link #stopClientPush} to prepare the script * of {@link AuScript} that will be sent to the client. */ protected String getStopScript() { final String stop = _desktop.getWebApp().getConfiguration() .getPreference("CometServerPush.stop", null); return stop != null ? stop: "zkCmsp.stop('" + _desktop.getId() + "');"; }
/** * Force transfer of session-based security context to desktop. */ @Override public void onInit(Desktop desktop) { HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); getSecurityContext(session, desktop.getId()); }
/** Returns the JavaScript codes to disable (a.k.a., stop) the server push. * It is called by {@link #stopClientPush} to prepare the script * of {@link AuScript} that will be sent to the client. */ protected String getStopScript() { final String stop = _desktop.getWebApp().getConfiguration().getPreference("PollingServerPush.stop", null); return stop != null ? stop : "zk.cpsp.stop('" + _desktop.getId() + "');"; }
/** Returns the JavaScript codes to disable (aka., stop) the server push. * It is called by {@link #stopClientPush} to prepare the script * of {@link AuScript} that will be sent to the client. */ protected String getStopScript() { final String stop = _desktop.getWebApp().getConfiguration() .getPreference("PollingServerPush.stop", null); return stop != null ? stop: "zkCpsp.stop('" + _desktop.getId() + "');"; }
/** Returns the JavaScript codes to enable (aka., start) the server push. * It is called by {@link #startClientPush} to prepare the script * of {@link AuScript} that will be sent to the client. */ protected String getStartScript() { final String start = _desktop.getWebApp().getConfiguration() .getPreference("CometServerPush.start", null); if (start != null) return start; final String dtid = _desktop.getId(); return "zk.invoke('zkmax.ui.cmsp',function(){zkCmsp.start('" + dtid + "');},'" + dtid + "');"; } /** Returns the JavaScript codes to disable (aka., stop) the server push.
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Fileupload self = (Fileupload) comp; final String uuid = self.getUuid(); final Execution exec = Executions.getCurrent(); wh.write("<div id=\"").write(uuid).write("\""); wh.write(self.getOuterAttrs()).write(self.getInnerAttrs()).write(">"); String hgh = self.getNumber() > 3 ? (self.getNumber() * 16 + 30) + "pt" : ""; wh.write("<iframe style=\"width:100%;height:").write(hgh) .write("\" frameborder=\"0\" src=\"") .write(exec.encodeURL("~./zul/html/fileupload.html.dsp")) .write("?dtid=").write(self.getDesktop().getId()).write("&uuid=") .write(uuid).write("&max=").write(Integer.toString(self.getNumber())) .write("&native=").write(self.isNative()).writeln("\">") .write("</iframe></div>"); }