/** * Add a script to the list waiting for remote execution. * @param script The script to execute */ public static void addScript(ScriptBuffer script) { Collection<ScriptSession> sessions = Browser.getTargetSessions(); for (ScriptSession scriptSession : sessions) { scriptSession.addScript(script); } }
/** * Removes the object bound with the specified name from this session. * If the session does not have an object bound with the specified name, * this method does nothing. * <p>After this method executes, and if the object implements * {@link ScriptSessionBindingListener}, the container calls * {@link ScriptSessionBindingListener#valueUnbound}. * @param name the name of the object to remove from this session * @throws IllegalStateException if the page has been invalidated */ public static void removeAttribute(String name) { Collection<ScriptSession> sessions = Browser.getTargetSessions(); for (ScriptSession scriptSession : sessions) { scriptSession.removeAttribute(name); } }
/** * Binds an object to this session, using the name specified. * If an object of the same name is already bound to the session, the * object is replaced. * <p>After this method executes, and if the new object implements * {@link ScriptSessionBindingListener}, the container calls * {@link ScriptSessionBindingListener#valueBound}. * <p>If an object was already bound to this session of this name that * implements {@link ScriptSessionBindingListener}, its * {@link ScriptSessionBindingListener#valueUnbound} method is called. * <p>If the value passed in is null, this has the same effect as calling * {@link #removeAttribute}. * @param name the name to which the object is bound; cannot be null * @param value the object to be bound * @throws IllegalStateException if the page has been invalidated */ public static void setAttribute(String name, Object value) { Collection<ScriptSession> sessions = Browser.getTargetSessions(); for (ScriptSession scriptSession : sessions) { scriptSession.setAttribute(name, value); } }