use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class TextRange method setText.
/**
* Sets the text contained within the range.
* @param text the text contained within the range
*/
@JsxSetter
public void setText(final String text) {
if (range_.getStartContainer() == range_.getEndContainer() && range_.getStartContainer() instanceof SelectableTextInput) {
final SelectableTextInput input = (SelectableTextInput) range_.getStartContainer();
final String oldValue = input.getText();
input.setText(oldValue.substring(0, input.getSelectionStart()) + text + oldValue.substring(input.getSelectionEnd()));
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLDocument method setCookie.
/**
* Adds a cookie, as long as cookies are enabled.
* @see <a href="http://msdn.microsoft.com/en-us/library/ms533693.aspx">MSDN documentation</a>
* @param newCookie in the format "name=value[;expires=date][;domain=domainname][;path=path][;secure]
*/
@JsxSetter
public void setCookie(final String newCookie) {
final HtmlPage page = getPage();
final WebClient client = page.getWebClient();
if (StringUtils.isBlank(newCookie) && client.getBrowserVersion().hasFeature(HTMLDOCUMENT_COOKIES_IGNORE_BLANK)) {
return;
}
client.addCookie(newCookie, getPage().getUrl(), this);
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLObjectElement method setClassid.
/**
* Sets the {@code classid} attribute.
* @param classid the {@code classid} attribute
*/
@JsxSetter(IE)
public void setClassid(final String classid) {
getDomNodeOrDie().setAttribute("classid", classid);
if (classid.indexOf(':') != -1 && getBrowserVersion().hasFeature(HTML_OBJECT_CLASSID)) {
final WebClient webClient = getWindow().getWebWindow().getWebClient();
final Map<String, String> map = webClient.getActiveXObjectMap();
if (map != null) {
final String xClassString = map.get(classid);
if (xClassString != null) {
try {
final Class<?> xClass = Class.forName(xClassString);
final Object object = xClass.newInstance();
boolean contextCreated = false;
if (Context.getCurrentContext() == null) {
new HtmlUnitContextFactory(webClient).enterContext();
contextCreated = true;
}
wrappedActiveX_ = Context.toObject(object, getParentScope());
if (contextCreated) {
Context.exit();
}
} catch (final Exception e) {
throw Context.reportRuntimeError("ActiveXObject Error: failed instantiating class " + xClassString + " because " + e.getMessage() + ".");
}
return;
}
}
if (webClient.getOptions().isActiveXNative() && System.getProperty("os.name").contains("Windows")) {
try {
wrappedActiveX_ = new ActiveXObjectImpl(classid);
wrappedActiveX_.setParentScope(getParentScope());
} catch (final Exception e) {
Context.throwAsScriptRuntimeEx(e);
}
}
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLAnchorElement method setText.
/**
* Sets the {@code text} attribute.
* @param text the {@code text} attribute
*/
@JsxSetter
public void setText(final String text) {
final DomNode htmlElement = getDomNodeOrDie();
htmlElement.setTextContent(text);
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLScriptElement method setText.
/**
* Sets the {@code text} property.
* @param text the {@code text} property
*/
@JsxSetter
public void setText(final String text) {
final HtmlElement htmlElement = getDomNodeOrDie();
htmlElement.removeAllChildren();
final DomNode textChild = new DomText(htmlElement.getPage(), text);
htmlElement.appendChild(textChild);
ScriptElementSupport.executeScriptIfNeeded(htmlElement, false, false);
}
Aggregations