protected function getInlineJavaScript()
    {
        $javascript = sprintf(
            "var %s_obj = new %s(%s, %s);",
            $this->id,
            $this->getJavaScriptClass(),
            SwatString::quoteJavaScriptString($this->id),
            SwatString::quoteJavaScriptString($this->connection_close_uri)
        );

        if ($this->autofocus) {
            $focusable = true;
            if ($this->default_focused_control === null) {
                $control = $this->getFirstDescendant('SwatControl');
                if ($control === null) {
                    $focusable = false;
                } else {
                    $focus_id = $control->getFocusableHtmlId();
                    if ($focus_id === null) {
                        $focusable = false;
                    }
                }
            } else {
                $focus_id = $this->default_focused_control->getFocusableHtmlId();

                if ($focus_id === null) {
                    $focusable = false;
                }
            }

            if ($focusable) {
                $javascript .= "\n{$this->id}_obj.setDefaultFocus('{$focus_id}');";
            }
        }

        if (!$this->autocomplete) {
            $javascript .= "\n{$this->id}_obj.setAutocomplete(false);";
        }

        return $javascript;
    }