答:
Unlike some languages like Java where we can reference variables within a class without using this, this binding behaves much differently in JavaScript, as does scoping.

In Java, this is legal:

```<code>class Test {
  int i;
  void method() {
    System.out.print(i); // <-- Java compiler knows to look for the `i` on the class instance (technically it first looks for `i` locally in the scope of `method` and the goes to look on the class)
  }
}
</code>```

In JavaScript, we don't have this behavior, there's no such thing as a class variable (yet).

class Test {
  i; // <-- Uncaught SyntaxError: Unexpected token ;
  method() {
    console.log(i);
  }
}```
</div>
</div>
</p>

<p>For your example, this means you are always required to use <code>this</code> when referencing variables present in a class (technically on an object instance).</p>

<p>Thus you must use <code>this.myString</code>:</p>

```repeatString() {
  console.log(this.myString);
}
```

You are getting the Reference Error because the engine tries to find a variable called myString starting from the scope of repeatString and upward and there aren't any. The only scope that has a variable myString is the one within the constructor function, and that scope is unreachable from repeatString.

Classes in JavaScript are radically different (here's an overview) than Java, even though the syntax looks very similar.

Title: Difference between classes in Java vs JavaScript?

Body:
Unlike some languages like Java where we can reference variables within a class without using this, this binding behaves much differently in JavaScript, as does scoping.

In Java, this is legal:

class Test {
  int i;
  void method() {
    System.out.print(i); // <-- Java compiler knows to look for the `i` on the class instance (technically it first looks for `i` locally in the scope of `method` and the goes to look on the class)
  }
}

In JavaScript, we don't have this behavior, there's no such thing as a class variable (yet).

class Test {
  i; // <-- Uncaught SyntaxError: Unexpected token ;
  method() {
    console.log(i);
  }
}

For your example, this means you are always required to use this when referencing variables present in a class (technically on an object instance).

Thus you must use this.myString:

repeatString() {
  console.log(this.myString);
}

You are getting the Reference Error because the engine tries to find a variable called myString starting from the scope of repeatString and upward and there aren't any. The only scope that has a variable myString is the one within the constructor function, and that scope is unreachable from repeatString.

Classes in JavaScript are radically different (here's an overview) than Java, even though the syntax looks very similar.


来源: stackexchange

问:
Find max and second max salary for a employee table MySQL
Suppose that you are given the following simple database table called Employee that has 2 columns named Employee ID and Salary:

```<code>  Employee
  Employee ID    Salary
   3            200
   4            800
   7            450
</code>```

I wish to write a query select max(salary) as max_salary, 2nd_max_salary from employee

then it should return

```<code>  max_salary   2nd_max_salary
   800             450
</code>```

i know how to find 2nd highest salary

```<code>   SELECT MAX(Salary) FROM Employee
  WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee )
</code>```

or to find the nth

```<code>  SELECT FROM Employee Emp1 WHERE (N-1) = ( SELECT COUNT(DISTINCT(Emp2.Salary)) FROM Employee Emp2
  WHERE Emp2.Salary > Emp1.Salary)
</code>```

but i am unable to figureout how to join these 2 results for the desired result

答:
I think, It is the simplest way to find MAX and second MAX Salary.You may try this way.

```<code>SELECT MAX(Salary) FROM Employee; -- For Maximum Salary.

SELECT MAX(Salary) FROM Employee WHERE Salary < (SELECT MAX(Salary) FROM Employee); -- For Second Maximum Salary
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Suppose that you are given the following simple database table called Employee that has 2 columns named Employee ID and Salary:

  Employee
  Employee ID    Salary
   3            200
   4            800
   7            450

I wish to write a query select max(salary) as max_salary, 2nd_max_salary from employee

then it should return

  max_salary   2nd_max_salary
   800             450

i know how to find 2nd highest salary

   SELECT MAX(Salary) FROM Employee
  WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee )

or to find the nth

  SELECT FROM Employee Emp1 WHERE (N-1) = ( SELECT COUNT(DISTINCT(Emp2.Salary)) FROM Employee Emp2
  WHERE Emp2.Salary > Emp1.Salary)

but i am unable to figureout how to join these 2 results for the desired result

Body:
I think, It is the simplest way to find MAX and second MAX Salary.You may try this way.

SELECT MAX(Salary) FROM Employee; -- For Maximum Salary.

SELECT MAX(Salary) FROM Employee WHERE Salary < (SELECT MAX(Salary) FROM Employee); -- For Second Maximum Salary


问:
why android is built on a VM (Dalvik)
I am curious to know what made google choose to develop android's framework on java VM.

In the process of writing code for android for nearly 6 months now, I observed that running code on a VM in a resource limited platform is really slow. There is a lot of overhead involved. I know that java is portable etc etc, is it not possible at all to use native languages and get both performance and features offered by a VM ? For performance oriented applications one still ends up writing native code and wrap it with JNI,

So why did google choose this particular stack :

Arm based core (understandable, ARM is the best for mobile devices)

Linux (Open source)

Java VM (My question)

EDIT : I know java - JVM runs on par with C++ applications on my server, but not on android.
With respect to android its not the case - As a matter of my experience, a C++ code wrapped with JNI runs far faster than java code (note I have even checked with exact same code from a static block in java) I will agree with your answer on any other platform.

答:
The Dalvik VM uses its own bytecode, not Java bytecode. It's designed to be very fast (relatively speaking). I think the "VM" part of its title is a bit of a red herring, as people tend to assume that it will be "slow" no matter what. You said it yourself, you're working with a "resource-limited platform" -- that's likely your main cause of slow performance, much more so than the Dalvik VM.

Disclaimer: I am not an expert on Dalvik or Android in any way, shape, or form. However, it seems like people can tend to make a lot of assumptions about Android based on ideas like "it uses a VM" and "you write applications in Java", without looking into the platform further than that.

See this video for more information than you probably ever wanted to know on the Dalvik VM Internals (from Google I/O 2008).

ContentLicense: CC BY-SA 4.0

Title: why android is built on a VM (Dalvik)

ContentLicense: CC BY-SA 2.5


问:
Double quotes in c# doesn't allow multiline
e.g.

```<code>string str = "{\"aps\":{\"alert\":\"" + title + "" + message + "\"}}";
</code>```

I need to make it as for readability:

```<code> string str = "
 {
   \"aps\":
         {
             \"alert\":\"" + title + "" + message + "\"
         }
 }";
</code>```

How to achieve this, please suggest.

答:
You could use what X-Tech has said, use additional concatenation operators ('+') on every line, or use the symbol '@':

```<code> string str = @"
         {
           'aps':
                 {
                     'alert':'" + title + "" + message + @"'
                 }
         }";
</code>```

Since its a JSON, you can use single quotes instead of double quotes.

About '@': Multiline String Literal in C#

Body:
e.g.

string str = "{\"aps\":{\"alert\":\"" + title + "" + message + "\"}}";

I need to make it as for readability:

 string str = "
 {
   \"aps\":
         {
             \"alert\":\"" + title + "" + message + "\"
         }
 }";

How to achieve this, please suggest.

Body:
You could use what X-Tech has said, use additional concatenation operators ('+') on every line, or use the symbol '@':

 string str = @"
         {
           'aps':
                 {
                     'alert':'" + title + "" + message + @"'
                 }
         }";

Since its a JSON, you can use single quotes instead of double quotes.

About '@': Multiline String Literal in C#


问:
Passing an additional parameter with an onChange event
What I'm trying to do:

I am trying to pass a string from a child component to the handleChange function of a parent component.

What currently works:

I have a parent React JS class with the following method:

```<code>handleChange(event) {

    console.log(event.target.value);
}
</code>```

In the render function I have the following:

```<code><Child handleChange={this.handleChange.bind(this)} />
</code>```

In the Child class I have:

```<code><fieldset onChange={this.props.handleChange}>
    <div>Tag 1: <input id="tag1" value={tags[0]} /></div>
    <div>Tag 2: <input id="tag2" value={tags[1]} /></div>
    <div>Tag 3: <input id="tag3" value={tags[2]} /></div>
</fieldset>
</code>```

This works fine.

What I am trying to do instead:

I am attempting to add a section parameter to the handleChange function as follows:

```<code>handleChange(section, event) {
    console.log(section);
    console.log(event.target.value);
}
</code>```

And in the Child class I have:

```<code><fieldset onChange={this.props.handleChange("tags")}>
    <div>Tag 1: <input id="tag1" value={tags[0]} /></div>
    <div>Tag 2: <input id="tag2" value={tags[1]} /></div>
    <div>Tag 3: <input id="tag3" value={tags[2]} /></div>
</fieldset>
</code>```

I now get the error:

```<code>Uncaught TypeError: Cannot read property 'target' of undefined
</code>```

This error is being thrown in my second console.log statement.

What am I doing wrong?

Also, I am considering making the section parameter optional. If so, is there an easy way to do this? It seems like it might not be possible if the event parameter needs to be last.

答:
In order to pass a param from the child component to the parent you can take an argument to the arrow function.

```<code>handleChange(event, section) {
    console.log(section);
    console.log(event.target.value);
}
<Child handleChange={(e, val) => this.handleChange(e, val)} />

<fieldset onChange={(e) => this.props.handleChange(e, "tags")}>
    <div>Tag 1: <input id="tag1" value={tags[0]} /></div>
    <div>Tag 2: <input id="tag2" value={tags[1]} /></div>
    <div>Tag 3: <input id="tag3" value={tags[2]} /></div>
</fieldset>
</code>```

Sample snippet

class App extends React.Component {
  handleChange(e, val) {
    console.log(e.target.value, val);
  }
  render() {
    return(
      <Child handleChange={(e,val) => this.handleChange(e, val)}/>
    )
  }
}

class Child extends React.Component {

  render() {
    return(
      <input type="text" onChange={(e) => this.props.handleChange(e, 'tab')}/>
    )
  }
}

ReactDOM.render(<App/>, document.getElementById('app'));```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app"></div></code>```

Body:
What I'm trying to do:

I am trying to pass a string from a child component to the handleChange function of a parent component.

What currently works:

I have a parent React JS class with the following method:

handleChange(event) {

    console.log(event.target.value);
}

In the render function I have the following:

<Child handleChange={this.handleChange.bind(this)} />

In the Child class I have:

<fieldset onChange={this.props.handleChange}>

Tag 1: <input id="tag1" value={tags[0]} />

Tag 2: <input id="tag2" value={tags[1]} />

Tag 3: <input id="tag3" value={tags[2]} />

</fieldset>

This works fine.

What I am trying to do instead:

I am attempting to add a section parameter to the handleChange function as follows:

handleChange(section, event) {
    console.log(section);
    console.log(event.target.value);
}

And in the Child class I have:

<fieldset onChange={this.props.handleChange("tags")}>

Tag 1: <input id="tag1" value={tags[0]} />

Tag 2: <input id="tag2" value={tags[1]} />

Tag 3: <input id="tag3" value={tags[2]} />

</fieldset>

I now get the error:

Uncaught TypeError: Cannot read property 'target' of undefined

This error is being thrown in my second console.log statement.

What am I doing wrong?

Also, I am considering making the section parameter optional. If so, is there an easy way to do this? It seems like it might not be possible if the event parameter needs to be last.

Body:
In order to pass a param from the child component to the parent you can take an argument to the arrow function.

handleChange(event, section) {
    console.log(section);
    console.log(event.target.value);
}
<Child handleChange={(e, val) => this.handleChange(e, val)} />

<fieldset onChange={(e) => this.props.handleChange(e, "tags")}>
    <div>Tag 1: <input id="tag1" value={tags[0]} /></div>
    <div>Tag 2: <input id="tag2" value={tags[1]} /></div>
    <div>Tag 3: <input id="tag3" value={tags[2]} /></div>
</fieldset>

Sample snippet

class App extends React.Component {
  handleChange(e, val) {
    console.log(e.target.value, val);
  }
  render() {
    return(
      <Child handleChange={(e,val) => this.handleChange(e, val)}/>
    )
  }
}

class Child extends React.Component {

  render() {
    return(
      <input type="text" onChange={(e) => this.props.handleChange(e, 'tab')}/>
    )
  }
}

ReactDOM.render(<App/>, document.getElementById('app'));

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app"></div>


问:
Is there a difference when converting an enum to a string between Convert.ToString() vs .ToString()?
Something amazed me with Enum String Conversion

If I do:

(Edit: This assertion is contested - it is true only if an enum variable instance has an invalid value)

```<code>Convert.ToString(MyEnum.MyEnumValue); // Returns Integer Representation
</code>```

Whereas if I do

```<code>MyEnum.MyEnumValue.ToString(); // Returns `MyEnumValue`
</code>```

Why is this behaviour or am I missing something?

答:
As per Anton's answer, the behaviour of Convert.ToString and .ToString() are on an enum is identical.

I believe what may have happened is that you assigned the enum variable an integral value which is out of range of the enumeration. Since enums are internally represented as integral types, the backing type will generally have a much wider range than the enum states that have been defined for it.

Corruption of enum values can occur quite easily, for example during casting, during a deserialization step, or when using enum parsing methods.

As a result, you should always validate that the enum is valid before trusting it in the rest of your system, e.g. through Enum.IsDefined, although you'll need to do further work if you are using FlagsAttribute

```<code>enum MyEnum
{
   Value1 = 1,
   Value2 = 2
};

void Main()
{
    // Literal
    Console.WriteLine(Convert.ToString(MyEnum.Value1)); // Value1
    Console.WriteLine(MyEnum.Value1.ToString()); // Value1

    // Variable
    MyEnum myEnum = MyEnum.Value2;
    Console.WriteLine(Convert.ToString(myEnum)); // Value2
    Console.WriteLine(myEnum.ToString());  // Value2

    // Invalid
    MyEnum badEnum = (MyEnum)123;
    Console.WriteLine(Convert.ToString(badEnum)); // 123
    Console.WriteLine(badEnum.ToString()); // 123
}
</code>```

Body:
Something amazed me with Enum String Conversion

If I do:

(Edit: This assertion is contested - it is true only if an enum variable instance has an invalid value)

Convert.ToString(MyEnum.MyEnumValue); // Returns Integer Representation

Whereas if I do

MyEnum.MyEnumValue.ToString(); // Returns `MyEnumValue`

Why is this behaviour or am I missing something?

Body:
As per Anton's answer, the behaviour of Convert.ToString and .ToString() are on an enum is identical.

I believe what may have happened is that you assigned the enum variable an integral value which is out of range of the enumeration. Since enums are internally represented as integral types, the backing type will generally have a much wider range than the enum states that have been defined for it.

Corruption of enum values can occur quite easily, for example during casting, during a deserialization step, or when using enum parsing methods.

As a result, you should always validate that the enum is valid before trusting it in the rest of your system, e.g. through Enum.IsDefined, although you'll need to do further work if you are using FlagsAttribute

enum MyEnum
{
   Value1 = 1,
   Value2 = 2
};

void Main()
{
    // Literal
    Console.WriteLine(Convert.ToString(MyEnum.Value1)); // Value1
    Console.WriteLine(MyEnum.Value1.ToString()); // Value1

    // Variable
    MyEnum myEnum = MyEnum.Value2;
    Console.WriteLine(Convert.ToString(myEnum)); // Value2
    Console.WriteLine(myEnum.ToString());  // Value2

    // Invalid
    MyEnum badEnum = (MyEnum)123;
    Console.WriteLine(Convert.ToString(badEnum)); // 123
    Console.WriteLine(badEnum.ToString()); // 123
}


问:
Polymer 1.x: call functions between iron-pages and pass data when role="main"
I have project structure like

```<code><my-app></my-app> //in index.html
</code>```

and in my-app.html I have iron-page, inside I have 3 components

```<code><iron-pages selected="0" role="main">
  <my-page1></my-page1>
  <my-page2></my-page2>
  <my-page3></my-page3>
</iron-pages>
</code>```

How to call a function along with parameter in my-page2.html from my-page1.html?

The method which I'm using now is I'll have an attribute to both the pages with notify:true for upward data flow in my-page1.html and adding an observer to that attribute in the second component, so when I assign the observer will call!

```<code><iron-pages selected="0">
  <my-page1 data-prop1={{dataProp1}}></my-page1>
  <my-page2 data-prop2=[[dataProp1]]></my-page2>
  <my-page3></my-page3>
</iron-pages>
</code>```

here for data-prop2, I'll add an observer so when I assign data for data-prop1 in my-page1.html observer get called in my-page2.html

In my opinion, this is not the right method! so this.fire can only be used to trigger a function from child to parent, so if I need to communicate specific function between the components or child siblings what I should do?

答:
What i am doing is, using querySelector to get an instance of the page and call the method in that.

as follows:

```<code>var myPage2 = null;
myPage2 = document.querySeletor('my-page2');
// Now call your function from here
myPage2.yourFunction(param1, param2);
</code>```

`

and your my-page2 will have the yourFunction function.

Body:
I have project structure like

<my-app></my-app> //in index.html

and in my-app.html I have iron-page, inside I have 3 components

<iron-pages selected="0" role="main">
  <my-page1></my-page1>
  <my-page2></my-page2>
  <my-page3></my-page3>
</iron-pages>

How to call a function along with parameter in my-page2.html from my-page1.html?

The method which I'm using now is I'll have an attribute to both the pages with notify:true for upward data flow in my-page1.html and adding an observer to that attribute in the second component, so when I assign the observer will call!

<iron-pages selected="0">
  <my-page1 data-prop1={{dataProp1}}></my-page1>
  <my-page2 data-prop2=[[dataProp1]]></my-page2>
  <my-page3></my-page3>
</iron-pages>

here for data-prop2, I'll add an observer so when I assign data for data-prop1 in my-page1.html observer get called in my-page2.html

In my opinion, this is not the right method! so this.fire can only be used to trigger a function from child to parent, so if I need to communicate specific function between the components or child siblings what I should do?

Body:
What i am doing is, using querySelector to get an instance of the page and call the method in that.

as follows:

var myPage2 = null;
myPage2 = document.querySeletor('my-page2');
// Now call your function from here
myPage2.yourFunction(param1, param2);

`

and your my-page2 will have the yourFunction function.


问:
Deconvolution (conv2d_transpose) in tensor flow
I have a trained network (AlexNet) for image classification; currently, I am trying to visualize the feature activation of different convolutional layers using deconvolution technique proposed by Zeiler. I am getting the following in results:

Input shape: (1,227,227,3)

Filter shape: (11,11,3,96)

stride = (4,4)

For getting the convolution output I used the following code:

```<code>wts = model.layers[1].get_weights()
inp = tf.constant(x_test)
ftr = tf.constant(wts[0])
b = tf.constant(wts[1])
c = tf.nn.conv2d(inp, ftr, strides = [1,4,4,1], padding='VALID')
c = c + b

sess = tf.Session()
res = sess.run(c)
print(res.shape)
sess.close()

fig=plt.figure(figsize=(12,12))
for i in range(96):
    plt.subplot(10, 10, i+1)
    img = res[0,:,:,i]
    plt.imshow(img, cmap='gray')
    plt.xticks(np.array([]))
    plt.yticks(np.array([]))
    plt.tight_layout()
plt.show()
</code>```

Following is the result which appears to be correct

But when I am trying the inverse operation I was expecting to get the original image but I am getting something else. Please help me understand why I didn't get anything close to the original image.

```<code>inp = tf.constant(res)
ftr = tf.constant(wts[0])
b   = tf.constant(wts[1])
c = inp - b
c = tf.nn.conv2d_transpose(c, ftr, output_shape = [1,227,227,3], strides = [1,4,4,1], padding='VALID')

sess = tf.Session()
res = sess.run(c)
print(res.shape)
sess.close()

plt.imshow(res[0,:,:,:])
plt.show()
</code>```

答:
Not sure if you fixed the issue. Try using:

```<code>c = tf.layers.conv2d_transpose(c, filters = 3, kernel_size = (11,11))
</code>```

And see where it gets you instead of initial tf.nn.conv2d_transpose.
I would love your feedback even if you already solved the issue.

Body:
I have a trained network (AlexNet) for image classification; currently, I am trying to visualize the feature activation of different convolutional layers using deconvolution technique proposed by Zeiler. I am getting the following in results:

Input shape: (1,227,227,3)

Filter shape: (11,11,3,96)

stride = (4,4)

For getting the convolution output I used the following code:

wts = model.layers[1].get_weights()
inp = tf.constant(x_test)
ftr = tf.constant(wts[0])
b = tf.constant(wts[1])
c = tf.nn.conv2d(inp, ftr, strides = [1,4,4,1], padding='VALID')
c = c + b

sess = tf.Session()
res = sess.run(c)
print(res.shape)
sess.close()

fig=plt.figure(figsize=(12,12))
for i in range(96):
    plt.subplot(10, 10, i+1)
    img = res[0,:,:,i]
    plt.imshow(img, cmap='gray')
    plt.xticks(np.array([]))
    plt.yticks(np.array([]))
    plt.tight_layout()
plt.show()

Following is the result which appears to be correct

But when I am trying the inverse operation I was expecting to get the original image but I am getting something else. Please help me understand why I didn't get anything close to the original image.

inp = tf.constant(res)
ftr = tf.constant(wts[0])
b   = tf.constant(wts[1])
c = inp - b
c = tf.nn.conv2d_transpose(c, ftr, output_shape = [1,227,227,3], strides = [1,4,4,1], padding='VALID')

sess = tf.Session()
res = sess.run(c)
print(res.shape)
sess.close()

plt.imshow(res[0,:,:,:])
plt.show()

Body:
Not sure if you fixed the issue. Try using:

c = tf.layers.conv2d_transpose(c, filters = 3, kernel_size = (11,11))

And see where it gets you instead of initial tf.nn.conv2d_transpose.
I would love your feedback even if you already solved the issue.


问:
Json data bind div in angularjs
Please help. I am new at angularjs, I want to bind json data into div as list using angularjs

Sample Data

```<code>"[{"T_FORM_CODE":"T12040"},{"T_FORM_CODE":"T18025"},{"T_FORM_CODE":"Q12014"},{"T_FORM_CODE":"R12039"}]"
</code>```

答:
Json Data : </p>

```<code>    const HEROES = [
    {"T_FORM_CODE":"T12040"},{"T_FORM_CODE":"T18025"},{"T_FORM_CODE":"Q12014"},{"T_FORM_CODE":"R12039"}
];
</code>```

<p>Template : </p>

```<code>  <tr *ngFor="let hero of heroes">
                    <td>{{hero.T_FORM_CODE}}</td>
                </tr>
</code>```

Title: Json data bind div in angularjs

Body:
Please help. I am new at angularjs, I want to bind json data into div as list using angularjs

Sample Data

"[{"T_FORM_CODE":"T12040"},{"T_FORM_CODE":"T18025"},{"T_FORM_CODE":"Q12014"},{"T_FORM_CODE":"R12039"}]"

Body:
Json Data :

    const HEROES = [
    {"T_FORM_CODE":"T12040"},{"T_FORM_CODE":"T18025"},{"T_FORM_CODE":"Q12014"},{"T_FORM_CODE":"R12039"}
];

Template :

  <tr *ngFor="let hero of heroes">
                    <td>{{hero.T_FORM_CODE}}</td>
                </tr>


问:
Cannot import com.google.cloud.speech.v1.SpeechGrpc in Android
I'm trying to use Google's Speech API in Android project. The example project works. I'm having trouble to use it in my own android app.

build.gradle(Module:app) :

```<code>apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'

ext {
    supportLibraryVersion = '25.4.0'
    grpcVersion = '1.4.0'
}
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "ApplicationID"
        minSdkVersion 16
        targetSdkVersion 24
//        compileOptions {
//            sourceCompatibility JavaVersion.VERSION_1_5
//            targetCompatibility JavaVersion.VERSION_1_5
//        }
    }
    signingConfigs {
        release {
            storeFile file(project.properties.storeFile)
            storePassword project.properties.storePassword
            keyAlias project.properties.keyAlias
            keyPassword project.properties.keyPassword
        }
    }
    productFlavors {
        dev {
            // Minimum version with platform multi-dex support
            minSdkVersion 21
        }
        prod {
            // Minimum version that can run gRPC (TLS extension)
            minSdkVersion 16
        }
    }
    buildTypes {
        debug {
            minifyEnabled false
            multiDexEnabled true
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
        resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion"
    }
}

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.3.0'
    }
    plugins {
        javalite {
            artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
        }
        grpc {
            artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                javalite {}
                grpc {
                    // Options added to --grpc_out
                    option 'lite'
                }
            }
        }
    }
}

//
//        buildTypes {
//        release {
//            minifyEnabled false
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
//        }
//    }
//    compileOptions {
//        targetCompatibility 1.6
//        sourceCompatibility 1.6
//    }
//}

dependencies {
    //    compile 'com.android.support:support-v4:18.0.0'
    //    compile 'com.android.support:appcompat-v7:24.2.1'
//    compile 'com.google.apis:google-api-services-speech:v1-rev8-1.22.0'
    compile group: 'com.google.cloud', name: 'google-cloud-speech', version: '0.17.1-alpha'
//    compile 'com.google.android.gms:play-services:11.0.2'
    compile project(':lib')    //This is someother library I'm using
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'io.grpc:grpc-core:1.4.0'

    // Support libraries
    compile "com.android.support:design:$supportLibraryVersion"
    compile "com.android.support:cardview-v7:$supportLibraryVersion"
    compile "com.android.support:recyclerview-v7:$supportLibraryVersion"

    // gRPC
    compile "io.grpc:grpc-okhttp:$grpcVersion"
    compile "io.grpc:grpc-protobuf-lite:$grpcVersion"
    compile "io.grpc:grpc-stub:$grpcVersion"
    compile 'javax.annotation:javax.annotation-api:1.2'
    protobuf 'com.google.protobuf:protobuf-java:3.3.1'

    // OAuth2 for Google API
    compile('com.google.auth:google-auth-library-oauth2-http:0.7.0') {
        exclude module: 'httpclient'
    }

    // Tests
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}
</code>```

build.gradle(Project: ProjectNAME):

```<code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        // for gRPC
        classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
//        compile 'com.github.adrielcafe:AndroidAudioConverter:0.0.8'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url "https://jitpack.io"
        }
    }
}
</code>```

Now, When I try to import com.google.cloud.speech.v1.SpeechGrpc; I'm getting an error Cannot resolve symbol 'SpeechGrpc'. But import com.google.cloud.speech.v1.RecognitionAudio or RecognizeRequest etcetera works fine.

I've tried adding the expample project's app module as module which didn't allow me to use even import com.google.cloud. So, I either need solution to import Grpc or correct gradle settings to use google's speech API

答: If you add the proto directory on GoogleCloudPlatform/android-docs-samples to your android application source(app/src/main/), it will work fine even though you don't write [compile group: 'com.google.cloud', name: 'google-cloud-speech', version: '0.17.1-alpha'] on your build.gradle(Module:app).

Body:
I'm trying to use Google's Speech API in Android project. The example project works. I'm having trouble to use it in my own android app.

build.gradle(Module:app) :

apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'

ext {
    supportLibraryVersion = '25.4.0'
    grpcVersion = '1.4.0'
}
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "ApplicationID"
        minSdkVersion 16
        targetSdkVersion 24
//        compileOptions {
//            sourceCompatibility JavaVersion.VERSION_1_5
//            targetCompatibility JavaVersion.VERSION_1_5
//        }
    }
    signingConfigs {
        release {
            storeFile file(project.properties.storeFile)
            storePassword project.properties.storePassword
            keyAlias project.properties.keyAlias
            keyPassword project.properties.keyPassword
        }
    }
    productFlavors {
        dev {
            // Minimum version with platform multi-dex support
            minSdkVersion 21
        }
        prod {
            // Minimum version that can run gRPC (TLS extension)
            minSdkVersion 16
        }
    }
    buildTypes {
        debug {
            minifyEnabled false
            multiDexEnabled true
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
        resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion"
    }
}

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.3.0'
    }
    plugins {
        javalite {
            artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
        }
        grpc {
            artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                javalite {}
                grpc {
                    // Options added to --grpc_out
                    option 'lite'
                }
            }
        }
    }
}

//
//        buildTypes {
//        release {
//            minifyEnabled false
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
//        }
//    }
//    compileOptions {
//        targetCompatibility 1.6
//        sourceCompatibility 1.6
//    }
//}

dependencies {
    //    compile 'com.android.support:support-v4:18.0.0'
    //    compile 'com.android.support:appcompat-v7:24.2.1'
//    compile 'com.google.apis:google-api-services-speech:v1-rev8-1.22.0'
    compile group: 'com.google.cloud', name: 'google-cloud-speech', version: '0.17.1-alpha'
//    compile 'com.google.android.gms:play-services:11.0.2'
    compile project(':lib')    //This is someother library I'm using
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'io.grpc:grpc-core:1.4.0'

    // Support libraries
    compile "com.android.support:design:$supportLibraryVersion"
    compile "com.android.support:cardview-v7:$supportLibraryVersion"
    compile "com.android.support:recyclerview-v7:$supportLibraryVersion"

    // gRPC
    compile "io.grpc:grpc-okhttp:$grpcVersion"
    compile "io.grpc:grpc-protobuf-lite:$grpcVersion"
    compile "io.grpc:grpc-stub:$grpcVersion"
    compile 'javax.annotation:javax.annotation-api:1.2'
    protobuf 'com.google.protobuf:protobuf-java:3.3.1'

    // OAuth2 for Google API
    compile('com.google.auth:google-auth-library-oauth2-http:0.7.0') {
        exclude module: 'httpclient'
    }

    // Tests
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}

build.gradle(Project: ProjectNAME):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        // for gRPC
        classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
//        compile 'com.github.adrielcafe:AndroidAudioConverter:0.0.8'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url "https://jitpack.io"
        }
    }
}

Now, When I try to import com.google.cloud.speech.v1.SpeechGrpc; I'm getting an error Cannot resolve symbol 'SpeechGrpc'. But import com.google.cloud.speech.v1.RecognitionAudio or RecognizeRequest etcetera works fine.

I've tried adding the expample project's app module as module which didn't allow me to use even import com.google.cloud. So, I either need solution to import Grpc or correct gradle settings to use google's speech API


问:
Data type of time in Spring-Data-Rest
I want to store the time what data type should I used in spring framework ?
Database which I used is MySQL </p>

```<code>@Entity
public class ShopDetail {

@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    private String address;

    private Double latitude;

    private Double longitude;

    private float  rating;

    private Time openingTime;

    private Time closingTime;
    }
</code>```

答:
You can use Java 8 time types in your entities. Just add this dependencies to your projects:

```<code><dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-java8</artifactId>
</dependency>
</code>```

According to this article The 5 laws of API dates and times I'd recommend to use ZonedDateTime in REST projects.

Also pay attention to this topic...

Title: Data type of time in Spring-Data-Rest

Body:
I want to store the time what data type should I used in spring framework ?
Database which I used is MySQL

@Entity
public class ShopDetail {

@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    private String address;

    private Double latitude;

    private Double longitude;

    private float  rating;

    private Time openingTime;

    private Time closingTime;
    }

Body:
You can use Java 8 time types in your entities. Just add this dependencies to your projects:

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-java8</artifactId>
</dependency>

According to this article The 5 laws of API dates and times I'd recommend to use ZonedDateTime in REST projects.

Also pay attention to this topic...


问:
Node Debug From Vagrant
Unable to remote debug a node server running on a Vagrant box in Chrome from my host machine. The server is configured to run on port 8123.

Node Version: 7.10.0

In Vagrantfile:

```<code>config.vm.network :forwarded_port, host: 9229, guest: 9229
config.vm.network :forwarded_port, host: 8123, guest: 8123
</code>```

From my vagrant box I run:

```<code>$ node --inspect index.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/84085f07-dc42-4e1e-bdd8-532e6dc5c4c6
--- Customer Service---
Connecting to customer repository...
Connected. Starting server...
Server started successfully, running on port 8123.
</code>```

When I try to access the url in Chrome from my host machine while I don't get an error the sources tab is empty.

Screenshot of devTools

答:
Based on NodeJS 11591 issue. You can't access the Vagrant stuff via localhost (127.0.0.1), so you need to to specify host explicitly:

$ node --inspect=0.0.0.0:9229 index.js

Then you need to set up Target discovery settings in the Chrome. Note that 192.168.33.11 from my sample is the static IP address providing an access to the Vargant host from the local host:

Title: Node Debug From Vagrant

Body:
Unable to remote debug a node server running on a Vagrant box in Chrome from my host machine. The server is configured to run on port 8123.

Node Version: 7.10.0

In Vagrantfile:

config.vm.network :forwarded_port, host: 9229, guest: 9229
config.vm.network :forwarded_port, host: 8123, guest: 8123

From my vagrant box I run:

$ node --inspect index.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/84085f07-dc42-4e1e-bdd8-532e6dc5c4c6
--- Customer Service---
Connecting to customer repository...
Connected. Starting server...
Server started successfully, running on port 8123.

When I try to access the url in Chrome from my host machine while I don't get an error the sources tab is empty.

Screenshot of devTools


问:
How to shrink a ScrollView's height keeping the other view(Button) fixed in place?
I have a ScrollView and a Button side by side in a vertical orientation(both children of ConstraintLayout's weighted chain with weight 1 and 0 respectively for ScrollView and the Button. BTW, you can optionally assume them to be children of a LinearLayout instead of a ConstraintLayout because a weighted ConstraintLayout chain works almost the same as a LinearLayout).

This is one of those typical use cases where you create the ScrollView with a list of certain items(children) and at the bottom have a big Button that searches your database based on the values filled in the ScollView children. Something like below:

The red-color encircled portion is where the Button is supposed to be(it is there but not visible).

Now the problem.

I want the button to be visible at all times irrespective of the ScrollView(if that implies shrinking of ScrollView's height, so be it because it is scrollable after all) but since the contents of ScrollView take enough space to hide the Button, by default it gets hidden. The solution(I think) would entail having to shrink the ScrollView's height just the amount that the Button is visible in the remaining space below.

Note that, I don't want the arrangement to end up like having the Button overlay the ScrollView's area. This is the case where no shrinkage of height would be required to ScrollView but rather the Button is made to float above it at the bottom, hiding some of its area. I want to force the ScrollView to adjust to the Button. Also, having weights of 1 and 0 respectively didn't help.

EDIT: Code for layout. (The Button is with id search_button)

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="8dp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    >

    <ScrollView
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        android:id="@+id/scrollView2"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_constraintRight_creator="1"
        tools:layout_constraintLeft_creator="1"
        app:layout_constraintVertical_weight="1"
        app:layout_constraintBottom_toTopOf="@+id/search_button"
        app:layout_constraintVertical_chainStyle="spread_inside">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="8dp"
            android:background="@android:drawable/dialog_holo_light_frame"
            android:paddingEnd="8dp"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:paddingStart="8dp"
            android:paddingTop="8dp">

            <LinearLayout
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_marginTop="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginRight="8dp"
                android:layout_marginEnd="8dp"
                android:orientation="vertical"
                app:layout_constraintRight_toRightOf="parent"
                android:id="@+id/frameLayout">

                <include layout="@layout/layout_subject_search" />

            </LinearLayout>

            <View
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:background="?android:attr/listDivider"
                android:layout_marginLeft="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginRight="8dp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/frameLayout"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginTop="8dp"
                android:id="@+id/view" />

            <LinearLayout
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                android:layout_marginTop="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginRight="8dp"
                android:layout_marginEnd="8dp"
                android:orientation="vertical"
                app:layout_constraintRight_toRightOf="parent"
                android:id="@+id/frameLayout1"
                app:layout_constraintTop_toBottomOf="@+id/view">

                <include layout="@layout/layout_qualification_search" />

            </LinearLayout>

            <View
                android:layout_width="0dp"
                android:layout_height="2dp"
                android:background="?android:attr/listDivider"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginTop="8dp"
                app:layout_constraintTop_toBottomOf="@+id/frameLayout1"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:id="@+id/view2" />

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/search_by_location_label"
                android:textSize="15sp"
                android:textStyle="bold"
                android:layout_marginLeft="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginTop="8dp"
                app:layout_constraintTop_toBottomOf="@+id/view2"
                android:layout_marginStart="8dp" />

            <Switch
                android:id="@+id/location_toggle_switch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:text=""
                android:layout_marginTop="16dp"
                app:layout_constraintTop_toBottomOf="@+id/view2"
                android:layout_marginRight="16dp"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginEnd="16dp" />

            <FrameLayout
                android:id="@+id/map_search_fragment"
                android:layout_width="0dp"
                android:layout_height="240dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/textView"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="@android:drawable/dialog_holo_light_frame"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/location_toggle_switch"
                app:layout_constraintVertical_bias="0.0">

            </FrameLayout>

        </android.support.constraint.ConstraintLayout>

    </ScrollView>

    <Button
        android:id="@+id/search_button"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:text="@string/search_tutors_string"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="4dp"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintVertical_weight="0"
        app:layout_constraintTop_toBottomOf="@+id/scrollView2" />

    <ProgressBar
        android:id="@+id/search_tutors_progress_bar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:visibility="gone"/>

</android.support.constraint.ConstraintLayout>
</code>```

EDIT 2: As asked by @marshmallow 's,

// include layout="@layout/layout_subject_search"

```<code><merge xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/search_by_subject_label"
        android:textStyle="bold"
        android:textSize="15sp"/>

    <com.learncity.learner.search.SubjectMultiAutoCompleteTextView
        android:id="@+id/subject_multi_auto_complete_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:completionThreshold="1"
        android:ems="10"/>

</merge>
</code>```

// include layout="@layout/layout_qualification_search"

```<code><merge xmlns:android="http://schemas.android.com/apk/res/android" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/search_by_qualification_label"
        android:textStyle="bold"
        android:textSize="15sp"/>

    <com.learncity.learner.search.QualificationMultiAutoCompleteTextView
        android:id="@+id/qualification_multi_auto_complete_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:completionThreshold="1"
        android:ems="10"/>

</merge>
</code>```

答:
Change ScrollView height to wrap_content

```<code><ScrollView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    android:id="@+id/scrollView2"
    ...>
</ScrollView>
</code>```

Also change constraintVertical_bias to 0.0 in ScrollView

```<code>app:layout_constraintVertical_bias="0.0"
</code>```

Update:

Change height to Button to wrap_content and it will be displayed properly.

Body:
I have a ScrollView and a Button side by side in a vertical orientation(both children of ConstraintLayout's weighted chain with weight 1 and 0 respectively for ScrollView and the Button. BTW, you can optionally assume them to be children of a LinearLayout instead of a ConstraintLayout because a weighted ConstraintLayout chain works almost the same as a LinearLayout).

This is one of those typical use cases where you create the ScrollView with a list of certain items(children) and at the bottom have a big Button that searches your database based on the values filled in the ScollView children. Something like below:

The red-color encircled portion is where the Button is supposed to be(it is there but not visible).

Now the problem.

I want the button to be visible at all times irrespective of the ScrollView(if that implies shrinking of ScrollView's height, so be it because it is scrollable after all) but since the contents of ScrollView take enough space to hide the Button, by default it gets hidden. The solution(I think) would entail having to shrink the ScrollView's height just the amount that the Button is visible in the remaining space below.

Note that, I don't want the arrangement to end up like having the Button overlay the ScrollView's area. This is the case where no shrinkage of height would be required to ScrollView but rather the Button is made to float above it at the bottom, hiding some of its area. I want to force the ScrollView to adjust to the Button. Also, having weights of 1 and 0 respectively didn't help.

EDIT: Code for layout. (The Button is with id search_button)

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="8dp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    >

    <ScrollView
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        android:id="@+id/scrollView2"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_constraintRight_creator="1"
        tools:layout_constraintLeft_creator="1"
        app:layout_constraintVertical_weight="1"
        app:layout_constraintBottom_toTopOf="@+id/search_button"
        app:layout_constraintVertical_chainStyle="spread_inside">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="8dp"
            android:background="@android:drawable/dialog_holo_light_frame"
            android:paddingEnd="8dp"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:paddingStart="8dp"
            android:paddingTop="8dp">

            <LinearLayout
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_marginTop="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginRight="8dp"
                android:layout_marginEnd="8dp"
                android:orientation="vertical"
                app:layout_constraintRight_toRightOf="parent"
                android:id="@+id/frameLayout">

                <include layout="@layout/layout_subject_search" />

            </LinearLayout>

            <View
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:background="?android:attr/listDivider"
                android:layout_marginLeft="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginRight="8dp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/frameLayout"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginTop="8dp"
                android:id="@+id/view" />

            <LinearLayout
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                android:layout_marginTop="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginRight="8dp"
                android:layout_marginEnd="8dp"
                android:orientation="vertical"
                app:layout_constraintRight_toRightOf="parent"
                android:id="@+id/frameLayout1"
                app:layout_constraintTop_toBottomOf="@+id/view">

                <include layout="@layout/layout_qualification_search" />

            </LinearLayout>

            <View
                android:layout_width="0dp"
                android:layout_height="2dp"
                android:background="?android:attr/listDivider"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginTop="8dp"
                app:layout_constraintTop_toBottomOf="@+id/frameLayout1"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:id="@+id/view2" />

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/search_by_location_label"
                android:textSize="15sp"
                android:textStyle="bold"
                android:layout_marginLeft="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginTop="8dp"
                app:layout_constraintTop_toBottomOf="@+id/view2"
                android:layout_marginStart="8dp" />

            <Switch
                android:id="@+id/location_toggle_switch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:text=""
                android:layout_marginTop="16dp"
                app:layout_constraintTop_toBottomOf="@+id/view2"
                android:layout_marginRight="16dp"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginEnd="16dp" />

            <FrameLayout
                android:id="@+id/map_search_fragment"
                android:layout_width="0dp"
                android:layout_height="240dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/textView"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="@android:drawable/dialog_holo_light_frame"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/location_toggle_switch"
                app:layout_constraintVertical_bias="0.0">

            </FrameLayout>

        </android.support.constraint.ConstraintLayout>

    </ScrollView>

    <Button
        android:id="@+id/search_button"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:text="@string/search_tutors_string"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="4dp"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintVertical_weight="0"
        app:layout_constraintTop_toBottomOf="@+id/scrollView2" />

    <ProgressBar
        android:id="@+id/search_tutors_progress_bar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:visibility="gone"/>

</android.support.constraint.ConstraintLayout>

EDIT 2: As asked by @marshmallow 's,

// include layout="@layout/layout_subject_search"

<merge xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/search_by_subject_label"
        android:textStyle="bold"
        android:textSize="15sp"/>

    <com.learncity.learner.search.SubjectMultiAutoCompleteTextView
        android:id="@+id/subject_multi_auto_complete_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:completionThreshold="1"
        android:ems="10"/>

</merge>

// include layout="@layout/layout_qualification_search"

<merge xmlns:android="http://schemas.android.com/apk/res/android" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/search_by_qualification_label"
        android:textStyle="bold"
        android:textSize="15sp"/>

    <com.learncity.learner.search.QualificationMultiAutoCompleteTextView
        android:id="@+id/qualification_multi_auto_complete_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:completionThreshold="1"
        android:ems="10"/>

</merge>

Body:
Change ScrollView height to wrap_content

<ScrollView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    android:id="@+id/scrollView2"
    ...>
</ScrollView>

Also change constraintVertical_bias to 0.0 in ScrollView

app:layout_constraintVertical_bias="0.0"

Update:

Change height to Button to wrap_content and it will be displayed properly.


问:
Can't change attribute of input tag using Javascript
I have an <input> tag which I would like to change programmatically. The input don't have inner text, it save its values on aria attributes.

So, here is the <input>:

```<code><input type="text" id="foo" aria-valuemin="1" aria-valuemax="10" autocomplete="off" role="spinbutton" aria-valuenow="1">
</code>```

Consider that we save the tag to the following bla variable:

```<code>var bla = document.getElementById("foo");
</code>```

Below is a list of commands I tried using. But none of them worked.

bla.value = 2;

bla.value = "2";

bla.setAttribute("aria-valuenow",2);

bla.setAttribute("aria-valuenow","2");

Any ideas why? The id of the element is unique, I checked it.
I am working on somebody's else code. Could it be possible that other developers changed the behavior of the <input>?

答:
You can use,</p>

```<code>document.getElementById("mytext").value = "My value";
</code>```

Body:
I have an <input> tag which I would like to change programmatically. The input don't have inner text, it save its values on aria attributes.

So, here is the <input>:

<input type="text" id="foo" aria-valuemin="1" aria-valuemax="10" autocomplete="off" role="spinbutton" aria-valuenow="1">

Consider that we save the tag to the following bla variable:

var bla = document.getElementById("foo");

Below is a list of commands I tried using. But none of them worked.

bla.value = 2;

bla.value = "2";

bla.setAttribute("aria-valuenow",2);

bla.setAttribute("aria-valuenow","2");

Any ideas why? The id of the element is unique, I checked it.
I am working on somebody's else code. Could it be possible that other developers changed the behavior of the <input>?

Body:
You can use,

document.getElementById("mytext").value = "My value";


问:
Issue creating a Xamarin.Forms app on a Windows Server OS
I wanted to use a windows server OS for reasons in my development of a Xamarin.Forms application but am getting an error as it gets to the stage of the creation that it makes the *.UWP project. Does anyone know a way to do this with out using a "client windows OS"? Im using "Microsoft Windows Server 2016 Datacenter" OS. The error is below.

答: Realised I don't need the server OS exactly, I can use a VM on it with windows 10, thanks for the comment magicandre1981.</p>


问:
hide only this part of datatable (filtered from x total entries)
i want to show only this content of data table Showing 0 to 0 of 0 entries but want to hide later part of it (filtered from x total entries)how is it possible help me</p>

答: In the core file (jquery.dataTables.js), search for a string "(filtered from MAX total entries)" and make it empty.


问:
App Engine Deploy: credentials file not writable. ... Opening in read-only mode. ... Any refreshed credentials will only be valid for this run
I recently upgraded my cloud SDK, and now I can no longer deploy to app engine flexible. I deploy my app with the following command:

C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd preview app deploy --promote vm.yaml

I am getting get the following output and crash (abridged):

```<code>WARNING: Could not acquire lock C:\Users\Michael\AppData\Roaming\gcloud\credentials.lock in 0 seconds
WARNING: The credentials file (C:\Users\Michael\AppData\Roaming\gcloud\credentials) is not writable. Opening in read-only mode. Any refreshed credentials will only be valid for this run.
WARNING: Could not acquire lock C:\Users\Michael\AppData\Roaming\gcloud\credentials.lock in 0 seconds
WARNING: The credentials file (C:\Users\Michael\AppData\Roaming\gcloud\credentials) is not writable. Opening in read-only mode. Any refreshed credentials will only be valid for this run.
WARNING: Could not acquire lock C:\Users\Michael\AppData\Roaming\gcloud\credentials.lock in 0 seconds
WARNING: The credentials file (C:\Users\Michael\AppData\Roaming\gcloud\credentials) is not writable. Opening in read-only mode. Any refreshed credentials will only be valid for this run.
...
ERROR: gcloud crashed (OSError): [Errno 13] Permission denied: 'C:\\Users\\Michael\\AppData\\Roaming\\gcloud\\credentials.lock'

If you would like to report this issue, please run the following command:
  gcloud feedback
</code>```

Below is some of the output from gcloud feedback

```<code>Trace:
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\gcloud_main.py:171
 gcloud_cli.Execute()
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\calliope\cli.py:719
 result = args.calliope_command.Run(cli=s...
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\calliope\backend.py:1404
 resources = command_instance.Run(args)
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py:91
 return deploy_util.RunDeploy(self, args,...
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\command_lib\app\deploy_util.py:206
 service, code_bucket_ref)
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\api_lib\app\deploy_app_command_util.py:233
 _UploadFiles(files_to_upload, bucket_ref...
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\api_lib\app\deploy_app_command_util.py:175
 results = pool.map(_UploadFile, tasks)
c:\Python27\lib\multiprocessing\pool.py:251
 return self.map_async(func, iterable, ch...
c:\Python27\lib\multiprocessing\pool.py:567
 raise self._value
OSError: [Errno 13] Permission denied: 'C:\\Users\\Michael\\AppData\\Roaming\\gcloud\\credentials.lock'

Installation information:

Google Cloud SDK [120.0.0]

Platform: [Windows, x86_64]
Python Version: [2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]]
Python Location: [c:\Python27\python.exe]
[output truncated]
</code>```

Any ideas?

答: The better way is to solve this error is to reinstall after deleting the root directory where lock file is.</p>

Body:
I recently upgraded my cloud SDK, and now I can no longer deploy to app engine flexible. I deploy my app with the following command:

C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd preview app deploy --promote vm.yaml

I am getting get the following output and crash (abridged):

WARNING: Could not acquire lock C:\Users\Michael\AppData\Roaming\gcloud\credentials.lock in 0 seconds
WARNING: The credentials file (C:\Users\Michael\AppData\Roaming\gcloud\credentials) is not writable. Opening in read-only mode. Any refreshed credentials will only be valid for this run.
WARNING: Could not acquire lock C:\Users\Michael\AppData\Roaming\gcloud\credentials.lock in 0 seconds
WARNING: The credentials file (C:\Users\Michael\AppData\Roaming\gcloud\credentials) is not writable. Opening in read-only mode. Any refreshed credentials will only be valid for this run.
WARNING: Could not acquire lock C:\Users\Michael\AppData\Roaming\gcloud\credentials.lock in 0 seconds
WARNING: The credentials file (C:\Users\Michael\AppData\Roaming\gcloud\credentials) is not writable. Opening in read-only mode. Any refreshed credentials will only be valid for this run.
...
ERROR: gcloud crashed (OSError): [Errno 13] Permission denied: 'C:\\Users\\Michael\\AppData\\Roaming\\gcloud\\credentials.lock'

If you would like to report this issue, please run the following command:
  gcloud feedback

Below is some of the output from gcloud feedback

Trace:
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\gcloud_main.py:171
 gcloud_cli.Execute()
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\calliope\cli.py:719
 result = args.calliope_command.Run(cli=s...
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\calliope\backend.py:1404
 resources = command_instance.Run(args)
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py:91
 return deploy_util.RunDeploy(self, args,...
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\command_lib\app\deploy_util.py:206
 service, code_bucket_ref)
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\api_lib\app\deploy_app_command_util.py:233
 _UploadFiles(files_to_upload, bucket_ref...
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\api_lib\app\deploy_app_command_util.py:175
 results = pool.map(_UploadFile, tasks)
c:\Python27\lib\multiprocessing\pool.py:251
 return self.map_async(func, iterable, ch...
c:\Python27\lib\multiprocessing\pool.py:567
 raise self._value
OSError: [Errno 13] Permission denied: 'C:\\Users\\Michael\\AppData\\Roaming\\gcloud\\credentials.lock'

Installation information:

Google Cloud SDK [120.0.0]

Platform: [Windows, x86_64]
Python Version: [2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]]
Python Location: [c:\Python27\python.exe]
[output truncated]

Any ideas?


问:
IE8 ul menu styling problem
I have a menu using an UL, as usual it works finr in FFX but not in IE. I've tried a few things but can't get any good results. Anyone have any ideas or pointers?

please see the attached code and image. If you look closely you can see the bullet points(black) on the left hand side. Where as in firefox a lovely menu is displayed....correctly! :)

Merry Xmas!!!

L

答:
Give this a shot:</p>

```<code>ul
{
    list-style-type: none;
}
</code>```

Title: IE8 ul menu styling problem

Body:
Give this a shot:

ul
{
    list-style-type: none;
}


问:
Dataprovider anotation - Testng Selenium Java
Query - The last set of values keep failing, the error that i am getting is that its unable to fine the xpath, but its working fine for other two cases. So a bit confused. I have pasted the error code as well. Would appreciate any help I can get. Thanks in advance.

Test Code -

```<code>@Test(priority = 4, dataProvider = "getData")
            public void loginScenario(String Username, String Password) throws InterruptedException {

WebElement user =  driver.findElement(By.xpath(".//*[@id='LoginForm_username']"));
                 if(null != user) {
                     user.clear();
                 }

                 WebElement pass =  driver.findElement(By.xpath(".//*[@id='LoginForm_password']"));
                 if(null != pass) {
                     pass.clear();
                 }

                // driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).click();
                // driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).click();
                driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).sendKeys(Username);
                driver.findElement(By.xpath(".//*[@id='LoginForm_password']")).sendKeys(Password);
                driver.findElement(By.xpath(".//*[@id='login-form']/button")).click();
                driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).clear();
                driver.findElement(By.xpath(".//*[@id='LoginForm_password']")).clear();

            }

            @DataProvider
            public Object[][] getData() {

                Object[][] data = new Object[3][2];
                data[0][0] = "abcd";
                data[0][1] = "xyz";
                data[1][0] = "...";
                data[1][1] = ".";
                data[2][0] = "blah@blah.com";
                data[2][1] = "kingkongkijai";

                return data;

            }
        }

Error -

FAILED: loginScenario("blah@blah.com", "kingkongkijai")
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='LoginForm_username']"}
Command duration or timeout: 51 milliseconds
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:410)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:509)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402)
    at pages.LoginPage.loginScenario(LoginPage.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:744)
    at org.testng.TestRunner.run(TestRunner.java:602)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
    at org.testng.SuiteRunner.run(SuiteRunner.java:289)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
    at org.testng.TestNG.runSuites(TestNG.java:1144)
    at org.testng.TestNG.run(TestNG.java:1115)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='LoginForm_username']"}
For documentation on this error, please visit:
</code>```

http://seleniumhq.org/exceptions/no_such_element.html

答:
@Madis Kangro

I just added the below code after you inputs and you were bang on ! Thanks so much

```<code>WebElement user = driver.findElement(By.xpath(".//*[@id='LoginForm_username']")); if(null != user) { user.clear(); } WebElement pass = driver.findElement(By.xpath(".//*[@id='LoginForm_password']")); if(null != pass) { pass.clear(); }
</code>```

Body:
Query - The last set of values keep failing, the error that i am getting is that its unable to fine the xpath, but its working fine for other two cases. So a bit confused. I have pasted the error code as well. Would appreciate any help I can get. Thanks in advance.

Test Code -

@Test(priority = 4, dataProvider = "getData")
            public void loginScenario(String Username, String Password) throws InterruptedException {

WebElement user =  driver.findElement(By.xpath(".//*[@id='LoginForm_username']"));
                 if(null != user) {
                     user.clear();
                 }

                 WebElement pass =  driver.findElement(By.xpath(".//*[@id='LoginForm_password']"));
                 if(null != pass) {
                     pass.clear();
                 }

                // driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).click();
                // driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).click();
                driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).sendKeys(Username);
                driver.findElement(By.xpath(".//*[@id='LoginForm_password']")).sendKeys(Password);
                driver.findElement(By.xpath(".//*[@id='login-form']/button")).click();
                driver.findElement(By.xpath(".//*[@id='LoginForm_username']")).clear();
                driver.findElement(By.xpath(".//*[@id='LoginForm_password']")).clear();

            }

            @DataProvider
            public Object[][] getData() {

                Object[][] data = new Object[3][2];
                data[0][0] = "abcd";
                data[0][1] = "xyz";
                data[1][0] = "...";
                data[1][1] = ".";
                data[2][0] = "blah@blah.com";
                data[2][1] = "kingkongkijai";

                return data;

            }
        }

Error -

FAILED: loginScenario("blah@blah.com", "kingkongkijai")
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='LoginForm_username']"}
Command duration or timeout: 51 milliseconds
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:410)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:509)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402)
    at pages.LoginPage.loginScenario(LoginPage.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:744)
    at org.testng.TestRunner.run(TestRunner.java:602)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
    at org.testng.SuiteRunner.run(SuiteRunner.java:289)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
    at org.testng.TestNG.runSuites(TestNG.java:1144)
    at org.testng.TestNG.run(TestNG.java:1115)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='LoginForm_username']"}
For documentation on this error, please visit:

http://seleniumhq.org/exceptions/no_such_element.html

Body:
@Madis Kangro

I just added the below code after you inputs and you were bang on ! Thanks so much

WebElement user = driver.findElement(By.xpath(".//*[@id='LoginForm_username']")); if(null != user) { user.clear(); } WebElement pass = driver.findElement(By.xpath(".//*[@id='LoginForm_password']")); if(null != pass) { pass.clear(); }


问:
'data-target' property becomes 'target' when compiling
I want to use an anchor for calling a modal from a multiple times used angular-directive for each instance.
This is the anchor:

```<code><li>
   <a role="button"
      data-toggle="modal"
      data-target="#editModal{{tweet.id}}"
    >Edit</a>
</li>
</code>```

But when I use the {{ }}, the compiled html code shows only a

```<code>target="#editModal24"
</code>```

and therefor the call doesn't work.

When I manually change to the data-target property in the browser, everything works.

Any ideas how to prevent that?

Best regards

答:
Angular normalizes attribute name

```<code>private _normalizeAttributeName(attrName: string): string {
  return /^data-/i.test(attrName) ? attrName.substring(5) : attrName;
}
</code>```

Note: even
Hello
 will work without problem.

And as you use interpolation inside attribute then it will be treated as property binding

So angular sets target property to a element.

HTMLAnchorElement.target

Is a DOMString that reflects the target HTML attribute, indicating
  where to display the linked resource.

That's why you can see the target attribute after setting target property to anchor element.

If you want to keep data-target attribute then use attribute binding like:

Option 1

```<code>attr.data-target="#editModal{{tweet.id}}"
</code>```

Option 2

```<code>[attr.data-target]="'#editModal' + tweet.id"
</code>```

Body:
I want to use an anchor for calling a modal from a multiple times used angular-directive for each instance.
This is the anchor:

   Edit

But when I use the {{ }}, the compiled html code shows only a

target="#editModal24"

and therefor the call doesn't work.

When I manually change to the data-target property in the browser, everything works.

Any ideas how to prevent that?

Best regards

Body:
Angular normalizes attribute name

private _normalizeAttributeName(attrName: string): string {
  return /^data-/i.test(attrName) ? attrName.substring(5) : attrName;
}

Note: even <div data-*ngIf="3">Hello</div> will work without problem.

And as you use interpolation inside attribute then it will be treated as property binding

So angular sets target property to a element.

HTMLAnchorElement.target

Is a DOMString that reflects the target HTML attribute, indicating
  where to display the linked resource.

That's why you can see the target attribute after setting target property to anchor element.

If you want to keep data-target attribute then use attribute binding like:

Option 1

attr.data-target="#editModal{{tweet.id}}"

Option 2

[attr.data-target]="'#editModal' + tweet.id"


问:
window.open("url","_self") works well on localhost url, but not when I put it on a server
I have an angularJS frontend that I redirect to a third party payment gateway when a customer clicks on the Pay button.

I am currently using the following function to redirect to the payment gateway:

```<code>if(status.data.result == "true"){
var ref = window.open(url,'_self');
}
};
</code>```

This code works well when I try it on localhost. But does not work when I put it on the ubuntu server.

Any ideas on why?

Regards,
Galeej

答: The solution that worked for us was using window.location = url</p>

Body:
I have an angularJS frontend that I redirect to a third party payment gateway when a customer clicks on the Pay button.

I am currently using the following function to redirect to the payment gateway:

if(status.data.result == "true"){
var ref = window.open(url,'_self');
}
};

This code works well when I try it on localhost. But does not work when I put it on the ubuntu server.

Any ideas on why?

Regards,
Galeej


问:
how do I show 'Do you want to delete' message box as simply way?
I am working on MVC 5 project. There I want to show delete message box by simple way depends on many purpose by click on a delete buttons. How can I do as below showing ?</p>

答:
If you use jQuery:

```<code>$(".delete").on('click touchstart',function(e){
    e.preventDefault();
    var c = confirm("Are you shure you want to delete this?");
    if(c)
    {
        /* DO WHAT YOU WANT */
    }
});
</code>```

Or pure JavaScript

```<code>var classname = document.getElementsByClassName("delete");

var myFunction = function() {
    var c = confirm("Are you shure you want to delete this?");
    if(c)
    {
        /* DO WHAT YOU WANT */
    }
};

for (var i = 0; i < classname.length; i++) {
    classname[i].addEventListener('click', myFunction, false);
}
</code>```

Or JavaScript inside HTML attribute onClick with some URL redirection to delete page:

```<code><button type="button" class="delete" onClick="var c = confirm('Are you shure you want to delete this?'); if(c) window.location.href='http://yourdomain/delete.php?id=1'">Delete</button>
</code>```

For some custom alerts, I will suggest SweetAlert.

Body:
If you use jQuery:

$(".delete").on('click touchstart',function(e){
    e.preventDefault();
    var c = confirm("Are you shure you want to delete this?");
    if(c)
    {
        /* DO WHAT YOU WANT */
    }
});

Or pure JavaScript

var classname = document.getElementsByClassName("delete");

var myFunction = function() {
    var c = confirm("Are you shure you want to delete this?");
    if(c)
    {
        /* DO WHAT YOU WANT */
    }
};

for (var i = 0; i < classname.length; i++) {
    classname[i].addEventListener('click', myFunction, false);
}

Or JavaScript inside HTML attribute onClick with some URL redirection to delete page:

<button type="button" class="delete" onClick="var c = confirm('Are you shure you want to delete this?'); if(c) window.location.href='http://yourdomain/delete.php?id=1'">Delete</button>

For some custom alerts, I will suggest SweetAlert.