问:
javascript execution order
I am starting to learn Javascript and jQuery.
I wanted to make a simple slide show with jQuery which displays list unordered list items one by one.

My code is here: on jsfiddle

I thought that I'd make the slideshow by iterating over list items in a for loop and display them with fadeIn and fadeOut effects like below:

```<code>for(var i = 0; i < 3; i++)
{
    $('#slider li:nth-child('+ i +')')
        .fadeIn()
        .delay(1000)
        .fadeOut();
}
</code>```

But it only shows the last item in the list.

I read that I need to close the value of i variable in a separate function because of the Javascript scope that it sees the value of i is being increased to 2 in the loop. So, I made a separate function which closes the value of i and called the function. But it was still same, displaying the last item of the list.

So, I just wanted to try without the loop by making two separate effects on list items like below:

```<code>$('#slider li:first-child')
    .fadeIn()
    .delay(1000)
    .fadeOut();
$('#slider li:nth-child(2)')
    .fadeIn()
    .delay(1000)
    .fadeOut();
</code>```

But it doesn't display the list items sequentially like written above. When you run the code, it seems like the first item is shown really fast and the last item is displayed as intended.

I have written it like a C or Java code, thinking that it would execute from top to bottom. But it seems like Javascript is different and I didn't understand a key concept of Javascript.

So, my question is why it is not displaying the list items in order and only displaying the last item, and what should I need to know to make it work as intented.

Thank you.

答:
Animations are implemented behind the scenes by using many incremental calls to setTimeout()/setInterval(), which basically just queues up future tasks. So, the actual function calls you made in your code are not synchronous operations, it all finished within a microsecond, and many future tasks were enqueued.

This shows it a bit better, the second animation being scheduled to start far enough into the future so as not to interfere.

```<code>for(var i = 0; i < 3; i++)
{
    $('#slider li:nth-child('+ i +')')
        .delay(2000 * i)
        .fadeIn()
        .delay(1000)
        .fadeOut();
}
</code>```

I don't do much animation in jquery, but I do know that some animation functions accept a function as an argument, which will be called once it's animation finishes. This makes it easier to do serial animations because you dont need to do time/math calculation trickery.

As for why it's done like this- javascript is single threaded, and synchronous operations that don't complete quickly can easily block the ui. SO you gotta fudge it and queue stuff up, which the browser does at its liesure.

Title: javascript execution order

Body:
I am starting to learn Javascript and jQuery.
I wanted to make a simple slide show with jQuery which displays list unordered list items one by one.

My code is here: on jsfiddle

I thought that I'd make the slideshow by iterating over list items in a for loop and display them with fadeIn and fadeOut effects like below:

for(var i = 0; i < 3; i++)
{
    $('#slider li:nth-child('+ i +')')
        .fadeIn()
        .delay(1000)
        .fadeOut();
}

But it only shows the last item in the list.

I read that I need to close the value of i variable in a separate function because of the Javascript scope that it sees the value of i is being increased to 2 in the loop. So, I made a separate function which closes the value of i and called the function. But it was still same, displaying the last item of the list.

So, I just wanted to try without the loop by making two separate effects on list items like below:

$('#slider li:first-child')
    .fadeIn()
    .delay(1000)
    .fadeOut();
$('#slider li:nth-child(2)')
    .fadeIn()
    .delay(1000)
    .fadeOut();

But it doesn't display the list items sequentially like written above. When you run the code, it seems like the first item is shown really fast and the last item is displayed as intended.

I have written it like a C or Java code, thinking that it would execute from top to bottom. But it seems like Javascript is different and I didn't understand a key concept of Javascript.

So, my question is why it is not displaying the list items in order and only displaying the last item, and what should I need to know to make it work as intented.

Thank you.

Body:
Animations are implemented behind the scenes by using many incremental calls to setTimeout()/setInterval(), which basically just queues up future tasks. So, the actual function calls you made in your code are not synchronous operations, it all finished within a microsecond, and many future tasks were enqueued.

This shows it a bit better, the second animation being scheduled to start far enough into the future so as not to interfere.

for(var i = 0; i < 3; i++)
{
    $('#slider li:nth-child('+ i +')')
        .delay(2000 * i)
        .fadeIn()
        .delay(1000)
        .fadeOut();
}

I don't do much animation in jquery, but I do know that some animation functions accept a function as an argument, which will be called once it's animation finishes. This makes it easier to do serial animations because you dont need to do time/math calculation trickery.

As for why it's done like this- javascript is single threaded, and synchronous operations that don't complete quickly can easily block the ui. SO you gotta fudge it and queue stuff up, which the browser does at its liesure.


来源: stackexchange

问:
Dropdown menu in HTML/CSS doesn't actually "drop down"
I'm trying to add a drop-down menu for one of the options in my nav menu for a simple html page. However, when I hover over the nav menu option, the menu doesn't actually drop down. It just replaces the nav menu option with the first option in the drop-down whenever I hover over it. I'm not exactly sure why it isn't "dropping down".

Any help would be really appreciated... Here's the HTML for the nav and attempted drop-down.

```<code><nav>
    <ul>
        <li><a href="eiffel.shtml">Eiffel Tower</a></li>
        <li><a href="fashion.shtml">Fashion</a></li>
        <li><a href="food.shtml">Food</a></li>
        <li><a href="museums.shtml">Museums</a></li>
        <div class="dropDiv">
            <li class="dropdown"><a href="history.shtml">History</a></li>
                <div class="dropdownContent">
                    <a href=leaders.shtml>Leaders of Paris</a>
                    <a href=future.shtml>Future of Paris</a>
                </div>
        </div>
        <li><a href="language.shtml">Language</a></li>
        <li><a href="works.shtml">Works Cited</a></li>
    </ul>
</nav>
</code>```

and here is the CSS snippet for the Dropdown menu:

```<code>.dropdown {
    float: left;
    background-color: #FFF0F5;
    width: 100%;
}

.dropDiv {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dropdownContent {
    display: none;
    position: absolute;
    background-color: #FFF0F5;
    height: 200px;
    width: 100%;
    z-index: 1;
}

.dropdownContent a {
    display: block;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

.dropdownContent a:hover {background-color: #fff8dc;}

.dropDiv:hover .dropdownContent {
    display: block;
    z-index: 1;
    height: 200px;
}

.dropDiv:hover .dropdown {
    background-color: #fff8dc;
}
</code>```

I'm not really sure why the drop-down part isn't displaying, i'm sure it's some stupid mistake but it's eluded me for an hour and a half...

答:
You have a lot of unwanted css and markup. Just fix it. I have created a basic one for you. May be you can try,

.dropdownContent {
        display: none;
        background-color: #FFF0F5;
    }

    .dropdownContent a:hover {
        background-color: #fff8dc;
    }
    .dropdownContent a{
        display: block;
    }

    .dropdown:hover .dropdownContent {
        display: block;
        z-index: 1;
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav>
        <ul>
            <li>Eiffel Tower</li>
            <li>Fashion</li>
            <li>Food</li>
            <li>Museums</li>
            <li class="dropdown">
                History
                <div class="dropdownContent">
                    Leaders of Paris
                    Future of Paris
                </div>
            </li>
            <li>Language</li>
            <li>Works Cited</li>
        </ul>
    </nav></code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to add a drop-down menu for one of the options in my nav menu for a simple html page. However, when I hover over the nav menu option, the menu doesn't actually drop down. It just replaces the nav menu option with the first option in the drop-down whenever I hover over it. I'm not exactly sure why it isn't "dropping down".

Any help would be really appreciated... Here's the HTML for the nav and attempted drop-down.

Eiffel Tower

Fashion

Food

Museums

History

                    Leaders of Paris
                    Future of Paris

Language

Works Cited

and here is the CSS snippet for the Dropdown menu:

.dropdown {
    float: left;
    background-color: #FFF0F5;
    width: 100%;
}

.dropDiv {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dropdownContent {
    display: none;
    position: absolute;
    background-color: #FFF0F5;
    height: 200px;
    width: 100%;
    z-index: 1;
}

.dropdownContent a {
    display: block;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

.dropdownContent a:hover {background-color: #fff8dc;}

.dropDiv:hover .dropdownContent {
    display: block;
    z-index: 1;
    height: 200px;
}

.dropDiv:hover .dropdown {
    background-color: #fff8dc;
}

I'm not really sure why the drop-down part isn't displaying, i'm sure it's some stupid mistake but it's eluded me for an hour and a half...

Body:
You have a lot of unwanted css and markup. Just fix it. I have created a basic one for you. May be you can try,

.dropdownContent {
        display: none;
        background-color: #FFF0F5;
    }

    .dropdownContent a:hover {
        background-color: #fff8dc;
    }
    .dropdownContent a{
        display: block;
    }

    .dropdown:hover .dropdownContent {
        display: block;
        z-index: 1;
    }

<nav>
        <ul>
            <li><a href="eiffel.shtml">Eiffel Tower</a></li>
            <li><a href="fashion.shtml">Fashion</a></li>
            <li><a href="food.shtml">Food</a></li>
            <li><a href="museums.shtml">Museums</a></li>
            <li class="dropdown">
                <a href="history.shtml">History</a>
                <div class="dropdownContent">
                    <a href=leaders.shtml>Leaders of Paris</a>
                    <a href=future.shtml>Future of Paris</a>
                </div>
            </li>
            <li><a href="language.shtml">Language</a></li>
            <li><a href="works.shtml">Works Cited</a></li>
        </ul>
    </nav>


问:
How do I capture a text through dynamic xpath in selenium webdriver?
I am new to Selenium and this is my first post here. Please bear my ignorance and I tried searching to the best of my knowledge.
Below is the html from which I need to capture the xpath on the screen if 'btn-success' is available. Please help me.</p>

```<code><div class="col-lg-10 col-xs-10 ng-scope">
<div id="dashboard" class="container-fluid" ng-init="populateDropDown()"
style="margin-right: 0px; margin-left: 0px;">
<div class="row">
<div class="col-lg-12 col-xs-12">
<div class="panel panel-primary">
<div class="panel-heading">
<div style="color: white;">
<!-- ngRepeat: n in tapplications track by $index -->
<span class="ng-scope" ng-repeat="n in tapplications track by $index">
<!-- end ngRepeat: n in tapplications track by $index -->
<span class="ng-scope" ng-repeat="n in tapplications track by $index">
<!-- end ngRepeat: n in tapplications track by $index -->
<span class="ng-scope" ng-repeat="n in tapplications track by $index">
<button class="btn ng-binding **btn-success**" ng-click="reload(n.app_seq)"
ng-hide="n.app_name == 'GCP'" ng-class="{'btn-default':!CSI, 'btn-
success':CSI}" type="button" style="">
</code>```

答:
You can simply use class name to locate the element like this

```<code>WebElement btn_success = driver.findElement(By.class("btn ng-binding **btn-success**"));
</code>```

For the attribute value use getAttribute() method

```<code>String text_success=btn_success.getAttribute("class");
System.out.println(text_success);
</code>```

Body:
I am new to Selenium and this is my first post here. Please bear my ignorance and I tried searching to the best of my knowledge.
Below is the html from which I need to capture the xpath on the screen if 'btn-success' is available. Please help me.

<button class="btn ng-binding **btn-success**" ng-click="reload(n.app_seq)"
ng-hide="n.app_name == 'GCP'" ng-class="{'btn-default':!CSI, 'btn-
success':CSI}" type="button" style="">

Body:
You can simply use class name to locate the element like this

WebElement btn_success = driver.findElement(By.class("btn ng-binding **btn-success**"));

For the attribute value use getAttribute() method

String text_success=btn_success.getAttribute("class");
System.out.println(text_success);


问:
What is the angle brackets part is called in C# e.g. SomeMethodName<ISomething>()
Given the following in C#:

```<code>public Complex SomeMethodName<ISomething>(int x, int y, ....)
</code>```

we can describe each part as follows :

```<code>public : accessor specifier
Complex : the resut of the function
SomeMethodName : Method Name
<ISomething> : ???
(int x, int y, ....) : parameter list
</code>```

My question is what is the name for <ISomething> Part?

PS : I know the name for angle brackets, but what does that part signify? the generiticisim of the method?

Update : for example
we would read

```<code>public Complex SomeMethodName(int x, int y, ....)
</code>```

as public method SomeMethodName returning Complex as result and taking parameters int x, int y, ...

Should we read

```<code>public Complex SomeMethodName<ISomething>(int x, int y, ....)
</code>```

as public method SomeMethodName of generic type ISomething returning Complex as result and taking parameters int x, int y, ... ?

答:
My question is what is the name for  Part?

 is type parameter for generic method.

For example:

```<code>static void Swap<T>(ref T lhs, ref T rhs)
{
    T temp;
    temp = lhs;
    lhs = rhs;
    rhs = temp;
}
</code>```

The above defined method is called with  replaced with desired type:

```<code>public static void TestSwap()
{
    int a = 1;
    int b = 2;

    Swap<int>(ref a, ref b);
    System.Console.WriteLine(a + " " + b);
}
</code>```

So in the above Swap<int> here we are passing type parameter int

This Link explains about generic methods.

Body:
Given the following in C#:

public Complex SomeMethodName<ISomething>(int x, int y, ....)

we can describe each part as follows :

public : accessor specifier
Complex : the resut of the function
SomeMethodName : Method Name
<ISomething> : ???
(int x, int y, ....) : parameter list

My question is what is the name for <ISomething> Part?

PS : I know the name for angle brackets, but what does that part signify? the generiticisim of the method?

Update : for example
we would read

public Complex SomeMethodName(int x, int y, ....)

as public method SomeMethodName returning Complex as result and taking parameters int x, int y, ...

Should we read

public Complex SomeMethodName<ISomething>(int x, int y, ....)

as public method SomeMethodName of generic type ISomething returning Complex as result and taking parameters int x, int y, ... ?

Body:
My question is what is the name for  Part?

 is type parameter for generic method.

For example:

static void Swap<T>(ref T lhs, ref T rhs)
{
    T temp;
    temp = lhs;
    lhs = rhs;
    rhs = temp;
}

The above defined method is called with  replaced with desired type:

public static void TestSwap()
{
    int a = 1;
    int b = 2;

    Swap<int>(ref a, ref b);
    System.Console.WriteLine(a + " " + b);
}

So in the above Swap<int> here we are passing type parameter int

This Link explains about generic methods.


问:
nohup in "bash script -s ..." do NOT return prompt
I'm using bash to upload springboot package and restart it, but commands do NOT return prompt.

restart.sh:

```<code>kill -9 $(lsof -t -i:10001) \
&& nohup java -jar /path/to/app-0.0.1-SNAPSHOT.jar --server.port=10001 >/dev/null 2>&1 </dev/null &
</code>```

then I run the command:

```<code>ssh root@ip "bash -s" < restart.sh
</code>```

it does NOT return prompt.

答: Adding & at the end of restart.sh worked. Comments above </p>

Body:
I'm using bash to upload springboot package and restart it, but commands do NOT return prompt.

restart.sh:

kill -9 $(lsof -t -i:10001) \
&& nohup java -jar /path/to/app-0.0.1-SNAPSHOT.jar --server.port=10001 >/dev/null 2>&1 </dev/null &

then I run the command:

ssh root@ip "bash -s" < restart.sh

it does NOT return prompt.


问:
Plesk managed server is spamming - how to detect the causing source?
I am running a Debian 8.9 root server for me and some clients which is managed by Plesk Onyx Version 17.5.3 Update #28.

Maybe 2 weeks ago I noticed the first "Undelivered Mail Returned to Sender" when I sent mails to a known recipient. In the meantime the problem spread and my IP is now flagged as spam from at least 1 public spam directory (CBL).

So it's obvious that the server is sending spam. But how can I detect the causing source? Could be an old WordPress installation from one of the clients, maybe a weak password from on of the clients mailboxes.

I took a look in the maillog file, but it's too many information to see a suspicious action.

What can I do now?

答:
Spam may be sent by some mailbox on a domain, or by PHP script.

To find out what domain is causing the issue, install Outgoing Mail Control in Plesk.. More details about this are available here.

If it's a PHP script, there is a way to track it down using details here for Postfix mail server and here for Qmail.


问:
HTTP2 push after serving content
Is it possible to push content to the client after the requested content has already been served?

This Wikipedia article explains the sequence of frames as follows:

Server receives HEADERS frame asking for index.html in stream 3...

Server sends a PUSH_PROMISE for styles.css and a PUSH_PROMISE for script.js, again in stream 3...

Server sends a HEADERS frame in stream 3 for responding to the request for index.html.

Server sends DATA frame(s) with the contents of index.html, still in stream 3.

Server sends HEADERS frame for the response to styles.css in stream 4

Server sends HEADERS frame for the response to script.js in stream 6.

Server sends DATA frames for the contents of styles.css and script.js, using their respective stream numbers.

I was wondering if, for example, I could keep open stream 3 and after I sent the DATA frame(s) for index.html and afterwards send PUSH_PROMISE frames.

Thanks for any responses :)

答:
Is it possible to push content to the client after the requested content has already been served?

I believe the answer is 'no', based on 6.6. PUSH_PROMISE in RFC 7540. Here's the relevant quote (emphasis mine):

PUSH_PROMISE frames MUST only be sent on a peer-initiated stream
  that    is in either the "open" or "half-closed (remote)" state.  The
  stream    identifier of a PUSH_PROMISE frame indicates the stream it
  is    associated with.  If the stream identifier field specifies the
  value    0x0, a recipient MUST respond with a connection error
  (Section 5.4.1)    of type PROTOCOL_ERROR.

Back to your question:

I was wondering if, for example, I could keep open stream 3 and after I sent the DATA frame(s) for index.html and afterwards send PUSH_PROMISE frames.

Here's something that I believe you could do, along those lines: you could send all DATA frames for stream 3 but withhold the END_STREAM flag thus keeping the (which means that the client would still be waiting for content). Then send the PUSH_PROMISE, then send an empty (zero length) DATA frame with END_STREAM set on stream 3. I can't think of a scenario where that would be useful, however.

Title: HTTP2 push after serving content


问:
Can't debug android application
I'm developing android application in android platform 2.2,. I am not able to debug applications. I'm facing a problem wherein there are no errors in the program, but whenever I run the application on emulator, it gets launched but stops unexpectedly and I'm forced to close the application.</p>

答:
hey Supriya!!!!!!!!!!!!!

this means your application is crashing somewhere. see log  for crash or exception details.

and for debug add following attribute in android  manifest file under application tag
android:debuggable="true"

Thanks.

Title: Can't debug android application

ContentLicense: CC BY-SA 2.5


问:
C# Console Loop Proceed On KeyUp
I need to make it to where my code will only exit the loop when the key that is pressed, is released. I am doing this is console and will need to stay in console.

Here is an example of the code.

```<code>ConsoleKeyInfo = ki;

while (true)
{
    ki = Console.ReadKey();

    if (ki.Key == ConsoleKey.A)
    {
        Console.Write("A");
    }
}
</code>```

As you can see above, when the A key is pressed, it will write A in the console. If you hold down the A key, it will continuously write A.

What I'm wanting is for the console to write A ONCE until the A key is released. Then, if you press A again, it will print again.

I've thought about using "KeyUp" but I'm not able to use it on a console application. But something that would accomplish the following...

```<code>ConsoleKeyInfo = ki;

while (true)
{
    ki = Console.ReadKey();

    if (ki.Key == ConsoleKey.A)
    {
        //I know the following isn't actually code, but it's explaining what I want to happen.
        do (onKeyRelease)
        {
            Console.Write("A");
        }
    }
}
</code>```

Basically, I'm wanting only one thing to happen when the loop when a key is pressed until the key is released. When the key is released, the loop will start again.

Please note that I am using this idea for a Text-Based RPG game. So waiting until another key is pressed (including adding another Console.ReadKey() to the end) would not be ideal.

答:
1st Suggestion - Have you tried "break" the loop when the console has displayed the "A"?

2nd Suggestion -

```<code>ConsoleKeyInfo = ki;
var alreadyPressed = false
while (true)
{
ki = Console.ReadKey();

if (ki.Key == ConsoleKey.A && !alreadyPressed)
{
        Console.Write("A");
        alreadyPressed = true;
}}`
</code>```

Title: C# Console Loop Proceed On KeyUp

Body:
I need to make it to where my code will only exit the loop when the key that is pressed, is released. I am doing this is console and will need to stay in console.

Here is an example of the code.

ConsoleKeyInfo = ki;

while (true)
{
    ki = Console.ReadKey();

    if (ki.Key == ConsoleKey.A)
    {
        Console.Write("A");
    }
}

As you can see above, when the A key is pressed, it will write A in the console. If you hold down the A key, it will continuously write A.

What I'm wanting is for the console to write A ONCE until the A key is released. Then, if you press A again, it will print again.

I've thought about using "KeyUp" but I'm not able to use it on a console application. But something that would accomplish the following...

ConsoleKeyInfo = ki;

while (true)
{
    ki = Console.ReadKey();

    if (ki.Key == ConsoleKey.A)
    {
        //I know the following isn't actually code, but it's explaining what I want to happen.
        do (onKeyRelease)
        {
            Console.Write("A");
        }
    }
}

Basically, I'm wanting only one thing to happen when the loop when a key is pressed until the key is released. When the key is released, the loop will start again.

Please note that I am using this idea for a Text-Based RPG game. So waiting until another key is pressed (including adding another Console.ReadKey() to the end) would not be ideal.

Body:
1st Suggestion - Have you tried "break" the loop when the console has displayed the "A"?

2nd Suggestion -

ConsoleKeyInfo = ki;
var alreadyPressed = false
while (true)
{
ki = Console.ReadKey();

if (ki.Key == ConsoleKey.A && !alreadyPressed)
{
        Console.Write("A");
        alreadyPressed = true;
}}`


问:
Spring MVC/Hibernate/MySQL 400 Bad Request Error
I'm building a blog in Java using Spring and Hibernate. I can't seem to figure out what is going on but I keep running into a Bad Request error when I try to add (save) a post and I can't figure out where I am wrong in my mapping.

Error message:

Controller:

```<code>@Controller
@RequestMapping("/blog")
public class IndexController {

@Autowired
private PostService postService;

@RequestMapping("/list")
public String showPage (Model theModel) {

    // get posts from DAO

    List<Post> thePosts = postService.getAllPosts();

    // add the posts to the model

    theModel.addAttribute("allPosts", thePosts);
    return "allPosts";
}

@GetMapping("/showFormForAdd")
public String showFormForAdd(Model theModel) {

    //create model attribute to bind form data
    Post thePost = new Post();

    theModel.addAttribute("post", thePost);

    return "postSuccess";
}

@PostMapping("/savePost")
public String savePost(@ModelAttribute("post") Post thePost) {
    // save the post using our service

    postService.savePost(thePost);
    return "allPosts";
}
</code>```

Form snippet:

```<code> <div class="table" id="container">

            <form:form action="savePost" modelAttribute="post"
 method="POST">

                <table>
                    <tbody>
                    <tr>
                        <td><label>Title:</label></td>
                        <td><form:input path="title" /></td>
                    </tr>

                    <tr>
                        <td><label>Author:</label></td>
                        <td><form:input path="author" /></td>
                    </tr>

                    <tr>
                        <td><label>Date:</label></td>
                        <td><form:input path="date" /></td>
                    </tr>

                    <tr>
                        <td><label>Post:</label></td>
                        <td><form:input path="post" /></td>
                    </tr>

                    <tr>
                        <td><label></label></td>
                        <td><input type="submit" value="Save"></td>
                    </tr>

                    </tbody>
                </table>
            </form:form>
            <div style="clear: both;"></div>
            <p>
                <a href="${pageContext.request.contextPath}/">Back to Home Page</a>
            </p>
    </div>
</code>```

All other pages are working correctly so far, just can't add an actual blog post. Any help is greatly appreciated.

答:
I figured this out and it is similar to another spring issue I had in the past.

I don't think this really follows a lot of conventional function/design theory, but I added some code into the controller and it now works. I can add a post easily.

First thing was, I removed the @ModelAttribute tag from my "savePost" method. Then I added @RequestParam to my method parameters. Added a little bit of logic and now it saves to the database and then appears on the blog. Good stuff.

Code:

```<code>@PostMapping("/savePost")
public String savePost(@RequestParam("author") String author,
                       @RequestParam("title") String title, @RequestParam("date") String date,
                       @RequestParam("post") String post) throws ParseException {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date theDate = sdf.parse(date);

    // save the customer using our service
    Post thePost = new Post();
    thePost.setAuthor(author);
    thePost.setDate(theDate);
    thePost.setTitle(title);
    thePost.setPost(post);

    postService.addPost(thePost);

    System.out.println(thePost.toString()); //testing
    return "success";
}
</code>```

jsp:

```<code><form:form action="savePost" modelAttribute="post" method="POST">

                <table>
                    <tbody>
                    <tr>
                        <td><label>Title:</label></td>
                        <td><input id="title" type="text" name="title"></td>
                    </tr>

                    <tr>
                        <td><label>Author:</label></td>
                        <td><input id="author" type="text" name="author"></td>
                    </tr>

                    <tr>
                        <td><label>Date:</label></td>
                        <td><input id="date" type="text" name="date"></td>
                    </tr>

                    <tr>
                        <td><label>Post:</label></td>
                        <td><textarea id="post" type="text"
  name="post"></textarea></td>
                    </tr>

                    <tr>
                        <td><label></label></td>
                        <td><input type="submit"  value="Save"></td>
                    </tr>

                    </tbody>
                </table>
            </form:form>
</code>```

Body:
I'm building a blog in Java using Spring and Hibernate. I can't seem to figure out what is going on but I keep running into a Bad Request error when I try to add (save) a post and I can't figure out where I am wrong in my mapping.

Error message:

Controller:

@Controller
@RequestMapping("/blog")
public class IndexController {

@Autowired
private PostService postService;

@RequestMapping("/list")
public String showPage (Model theModel) {

    // get posts from DAO

    List<Post> thePosts = postService.getAllPosts();

    // add the posts to the model

    theModel.addAttribute("allPosts", thePosts);
    return "allPosts";
}

@GetMapping("/showFormForAdd")
public String showFormForAdd(Model theModel) {

    //create model attribute to bind form data
    Post thePost = new Post();

    theModel.addAttribute("post", thePost);

    return "postSuccess";
}

@PostMapping("/savePost")
public String savePost(@ModelAttribute("post") Post thePost) {
    // save the post using our service

    postService.savePost(thePost);
    return "allPosts";
}

Form snippet:

            <form:form action="savePost" modelAttribute="post"
 method="POST">

                        Title:
                        <form:input path="title" />

                        Author:
                        <form:input path="author" />

                        Date:
                        <form:input path="date" />

                        Post:
                        <form:input path="post" />

                        <input type="submit" value="Save">

            </form:form>

                Back to Home Page

All other pages are working correctly so far, just can't add an actual blog post. Any help is greatly appreciated.

Body:
I figured this out and it is similar to another spring issue I had in the past.

I don't think this really follows a lot of conventional function/design theory, but I added some code into the controller and it now works. I can add a post easily.

First thing was, I removed the @ModelAttribute tag from my "savePost" method. Then I added @RequestParam to my method parameters. Added a little bit of logic and now it saves to the database and then appears on the blog. Good stuff.

Code:

@PostMapping("/savePost")
public String savePost(@RequestParam("author") String author,
                       @RequestParam("title") String title, @RequestParam("date") String date,
                       @RequestParam("post") String post) throws ParseException {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date theDate = sdf.parse(date);

    // save the customer using our service
    Post thePost = new Post();
    thePost.setAuthor(author);
    thePost.setDate(theDate);
    thePost.setTitle(title);
    thePost.setPost(post);

    postService.addPost(thePost);

    System.out.println(thePost.toString()); //testing
    return "success";
}

jsp:

<form:form action="savePost" modelAttribute="post" method="POST">

                <table>
                    <tbody>
                    <tr>
                        <td><label>Title:</label></td>
                        <td><input id="title" type="text" name="title"></td>
                    </tr>

                    <tr>
                        <td><label>Author:</label></td>
                        <td><input id="author" type="text" name="author"></td>
                    </tr>

                    <tr>
                        <td><label>Date:</label></td>
                        <td><input id="date" type="text" name="date"></td>
                    </tr>

                    <tr>
                        <td><label>Post:</label></td>
                        <td><textarea id="post" type="text"
  name="post"></textarea></td>
                    </tr>

                    <tr>
                        <td><label></label></td>
                        <td><input type="submit"  value="Save"></td>
                    </tr>

                    </tbody>
                </table>
            </form:form>


问:
C printf Segmentation fault (core dumped) while mixing with Assembly code
I tried some basic example of mixing C code and x86 Assembly code.
It is simple Find smaller number example.

Here is Assembly code in b.s file (I have to use intel syntax with no prefix and i386 architecture):

```<code>.intel_syntax noprefix
.arch i386

.data
    .globl out_format
    out_format:
        .asciz "min(%i, %i) = %i\n"

.text
    .globl min
    .type min, @function
    min:
        enter 0, 0
        mov ebx, [ebp + 8]
        cmp ebx, [ebp + 12]
        jle 1f
        mov eax, [ebp] + 12
        jmp 2f
        1:
            mov eax, ebx
        2:
            leave
        ret 8

.end
</code>```

Here is the C code in a.c file:

```<code>#include<stdio.h>

extern char out_format;

extern int min(int x, int y);

int main() {
    int x1, x2, r;
    scanf("%i%i", &x1, &x2);
    r = min(x1, x2);
    printf(&out_format, x1, x2, r);

    return 0;
}
</code>```

I compile it with gcc on x64 Arch Linux:

```<code>gcc -m32 -Wall -Werror -g -o p b.s a.c
</code>```

But when I start the executable file p, and insert 2 numbers and hit enter
I get:

```<code>Segmentation fault (core dumped)
</code>```

I researched all previous similar questions, and I tried several things but every time I get the same error.
I also tried to debug it with gdb, and I see that Assembly function min returns the right result, but somehow it always stuck on C printf function.

I tried to not import string out_format from Assembly file, and define it directly in C file (I defined it as simple array of chars, and also as char pointer using malloc and free functions) but it didn't help.

Otherwise the program doesn't give such error if I intialize variable r with some integer instead with result of Assembly function min. But it doesn't have any sense to me as I already checked it with gdb and the Assembly function correctly intialize the variable r with correct smaller number.

Please, can anyone help me with this?

Thanks in advance

答:
The asm uses ret 8 to pop the args from the stack as it returns.

The standard 32-bit x86 Linux calling convention (i386 System V ABI) is caller-pops.  Functions just use ret to return and the caller can clean up the stack if / when it wants.  (e.g. use mov stores to write new args before another call instead of adjusting esp and using push again.)

As the OP's self answer points you, you could instead declare min as

```<code>extern int __attribute__((stdcall)) min(int x, int y);
</code>```

so the compiler-generated code will agree with the asm on the calling convention.  This calling convention is sometimes used on Windows.

Single-stepping with a debugger would have revealed this (if you knew what to look for).  Always use a debugger to figure out where your code segfaults, then look at registers and work backwards to find out why.

Body:
I tried some basic example of mixing C code and x86 Assembly code.
It is simple Find smaller number example.

Here is Assembly code in b.s file (I have to use intel syntax with no prefix and i386 architecture):

.intel_syntax noprefix
.arch i386

.data
    .globl out_format
    out_format:
        .asciz "min(%i, %i) = %i\n"

.text
    .globl min
    .type min, @function
    min:
        enter 0, 0
        mov ebx, [ebp + 8]
        cmp ebx, [ebp + 12]
        jle 1f
        mov eax, [ebp] + 12
        jmp 2f
        1:
            mov eax, ebx
        2:
            leave
        ret 8

.end

Here is the C code in a.c file:

#include<stdio.h>

extern char out_format;

extern int min(int x, int y);

int main() {
    int x1, x2, r;
    scanf("%i%i", &x1, &x2);
    r = min(x1, x2);
    printf(&out_format, x1, x2, r);

    return 0;
}

I compile it with gcc on x64 Arch Linux:

gcc -m32 -Wall -Werror -g -o p b.s a.c

But when I start the executable file p, and insert 2 numbers and hit enter
I get:

Segmentation fault (core dumped)

I researched all previous similar questions, and I tried several things but every time I get the same error.
I also tried to debug it with gdb, and I see that Assembly function min returns the right result, but somehow it always stuck on C printf function.

I tried to not import string out_format from Assembly file, and define it directly in C file (I defined it as simple array of chars, and also as char pointer using malloc and free functions) but it didn't help.

Otherwise the program doesn't give such error if I intialize variable r with some integer instead with result of Assembly function min. But it doesn't have any sense to me as I already checked it with gdb and the Assembly function correctly intialize the variable r with correct smaller number.

Please, can anyone help me with this?

Thanks in advance

Body:
The asm uses ret 8 to pop the args from the stack as it returns.

The standard 32-bit x86 Linux calling convention (i386 System V ABI) is caller-pops.  Functions just use ret to return and the caller can clean up the stack if / when it wants.  (e.g. use mov stores to write new args before another call instead of adjusting esp and using push again.)

As the OP's self answer points you, you could instead declare min as

extern int __attribute__((stdcall)) min(int x, int y);

so the compiler-generated code will agree with the asm on the calling convention.  This calling convention is sometimes used on Windows.

Single-stepping with a debugger would have revealed this (if you knew what to look for).  Always use a debugger to figure out where your code segfaults, then look at registers and work backwards to find out why.


问:
How to get the values from Dictionary type SESSION Variable in C#
I am using C#.

I have got below format values in my SESSION variable ["FROMDATA"], I am using DICTIONARY to store the FORM Posted Data. Please see the related question.

Below are the some values in my SESSION Variable.

```<code>1) key - "skywardsNumber" value-"99999039t"
2) key - "password" value-"a2222222"
3) key - "ctl00$MainContent$ctl22$FlightSchedules1$ddlDepartureAirport-suggest" value-"London"
4) key - "ctl00$MainContent$ctl22$ctl07$txtPromoCode" value-"AEEGIT9"
.
.
....so on
</code>```

Now I want to create a CLASS with METHOD in it, in which I will just pass the "KEY" and it will first check it for NULL OR EMPTY and then it will return its value from the SESSION Variable ["FROMDATA"].

Please suggest using C#.

答:
Try this,

```<code>public class Test
{
    public static string GetValue(string key)
    {
        string value = string.Empty;
        if (HttpContext.Current.Session["FROMDATA"] != null)
        {
            Dictionary<string, string> form = (Dictionary<string, string>)HttpContext.Current.Session["FROMDATA"];
            if(form.ContainsKey(key))
                value = form[key];
        }
        return value;
    }
}
</code>```

EDIT:

```<code> public static string GetValue(string sessionkey,string key)
    {
        string value = string.Empty;
        if (HttpContext.Current.Session[sessionkey] != null)
        {
            Dictionary<string, string> form = (Dictionary<string, string>)HttpContext.Current.Session[sessionkey];
            if(form.ContainsKey(key))
                value = form[key];
        }
        return value;
    }
</code>```

Body:
I am using C#.

I have got below format values in my SESSION variable ["FROMDATA"], I am using DICTIONARY to store the FORM Posted Data. Please see the related question.

Below are the some values in my SESSION Variable.

1) key - "skywardsNumber" value-"99999039t"
2) key - "password" value-"a2222222"
3) key - "ctl00$MainContent$ctl22$FlightSchedules1$ddlDepartureAirport-suggest" value-"London"
4) key - "ctl00$MainContent$ctl22$ctl07$txtPromoCode" value-"AEEGIT9"
.
.
....so on

Now I want to create a CLASS with METHOD in it, in which I will just pass the "KEY" and it will first check it for NULL OR EMPTY and then it will return its value from the SESSION Variable ["FROMDATA"].

Please suggest using C#.

Body:
Try this,

public class Test
{
    public static string GetValue(string key)
    {
        string value = string.Empty;
        if (HttpContext.Current.Session["FROMDATA"] != null)
        {
            Dictionary<string, string> form = (Dictionary<string, string>)HttpContext.Current.Session["FROMDATA"];
            if(form.ContainsKey(key))
                value = form[key];
        }
        return value;
    }
}

EDIT:

 public static string GetValue(string sessionkey,string key)
    {
        string value = string.Empty;
        if (HttpContext.Current.Session[sessionkey] != null)
        {
            Dictionary<string, string> form = (Dictionary<string, string>)HttpContext.Current.Session[sessionkey];
            if(form.ContainsKey(key))
                value = form[key];
        }
        return value;
    }


问:
Can a spring boot application have multiple Failure Analyzers?
Can a spring boot application support multiple custom Failure Analyzers? If Yes how is it configured? in spring.factories you can have only one property as below

org.springframework.boot.diagnostics.FailureAnalyzer=xxxxxxx

答:
Register your multiple custom Failure Analyzers using comma separator like below</p>

```<code>org.springframework.boot.diagnostics.FailureAnalyzer=com.x.x.CustomFailureAnalyzer1, com.x.x.CustomFailureAnalyzer1
</code>```

Body:
Register your multiple custom Failure Analyzers using comma separator like below

org.springframework.boot.diagnostics.FailureAnalyzer=com.x.x.CustomFailureAnalyzer1, com.x.x.CustomFailureAnalyzer1


问:
update preview field after submitting the value
I have a model for storing document numbering where the fields to fill are document, prefix, suffix, length and start. This I could do but after filling those data I need to show preview field in the table and preview field is based on the prefix, suffix and length.

What I mean to say is if I fill the prefix as 1, suffix as -2345 and length as 4 then the preview should be for that document as

```<code>1xxxx-2345
</code>```

if prefix as he-, suffix as -7459 and length as 5 then the preview should be

```<code>he-xxxxx-7459
</code>```

This can be done with the following logic

```<code>preview = str(prefix)+(('x')*length)+str(sufix)
</code>```

But how can I implement this in django. Do I have to use signals or override save method? Can anyone give me an idea, please?

Here is my model

```<code>class DocumentNumbering(models.Model):
    office = models.OneToOneField(OfficeSetup, blank=True, null=True)
    document = models.OneToOneField(Document blank=False, null=False)
    prefix = models.CharField(max_length=100, blank=True, null=True)
    sufix = models.IntegerField(blank=True, null=True)
    start_number = models.PositiveIntegerField(
        default=0, blank=False, null=False)
    length = models.PositiveIntegerField(default=0, blank=False, null=False, validators=[
                                         MaxValueValidator(10), MinValueValidator(1)])

    // not sure where to implement the logic for preview
    def save(self, *args, **kwargs):
</code>```

答:
Do you really need to store this in the database? If it is just for display purposes you could use a derived property:</p>

```<code>@property
def preview(self):
    return str(self.prefix)+(('x')*self.length)+str(self.sufix)
</code>```

Body:
I have a model for storing document numbering where the fields to fill are document, prefix, suffix, length and start. This I could do but after filling those data I need to show preview field in the table and preview field is based on the prefix, suffix and length.

What I mean to say is if I fill the prefix as 1, suffix as -2345 and length as 4 then the preview should be for that document as

1xxxx-2345

if prefix as he-, suffix as -7459 and length as 5 then the preview should be

he-xxxxx-7459

This can be done with the following logic

preview = str(prefix)+(('x')*length)+str(sufix)

But how can I implement this in django. Do I have to use signals or override save method? Can anyone give me an idea, please?

Here is my model

class DocumentNumbering(models.Model):
    office = models.OneToOneField(OfficeSetup, blank=True, null=True)
    document = models.OneToOneField(Document blank=False, null=False)
    prefix = models.CharField(max_length=100, blank=True, null=True)
    sufix = models.IntegerField(blank=True, null=True)
    start_number = models.PositiveIntegerField(
        default=0, blank=False, null=False)
    length = models.PositiveIntegerField(default=0, blank=False, null=False, validators=[
                                         MaxValueValidator(10), MinValueValidator(1)])

    // not sure where to implement the logic for preview
    def save(self, *args, **kwargs):

Body:
Do you really need to store this in the database? If it is just for display purposes you could use a derived property:

@property
def preview(self):
    return str(self.prefix)+(('x')*self.length)+str(self.sufix)


问:
How to shorten this? Is there a way?
I have to output each test score, 5 per line and the last being the three. Is there a way to do this any shorter, as in less code?</p>

```<code>int arrayDisplay(int testScore[], int size){

    printf("%d %d %d %d %d", testScore[0], testScore[1], testScore[2], testScore[3], testScore[4]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[5], testScore[6], testScore[7], testScore[8], testScore[9]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[10], testScore[11], testScore[12], testScore[13], testScore[14]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[15], testScore[16], testScore[17], testScore[18], testScore[19]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[20], testScore[21], testScore[22], testScore[23], testScore[23]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[24], testScore[25], testScore[26], testScore[27], testScore[28]);
    printf("\n");
    printf("%d %d %d", testScore[29], testScore[30], testScore[31]);
    printf("\n");

    return 0;
}
</code>```

答:
I feel a little dirty doing this, but:

```<code>    int arrayDisplay(int *testScore, int size)
    {
        for (int i = 0 ; i < size; i++)
        {
          printf("%d ", testScore[i]);
          if (i%5==0)
          {
            printf("\n");
          }

        }

    return 0;

    }
</code>```

To be clear: SO doesn't usually take kindly to these types of questions. Consider this your one free one ;)

Title: How to shorten this? Is there a way?

Body:
I have to output each test score, 5 per line and the last being the three. Is there a way to do this any shorter, as in less code?

int arrayDisplay(int testScore[], int size){

    printf("%d %d %d %d %d", testScore[0], testScore[1], testScore[2], testScore[3], testScore[4]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[5], testScore[6], testScore[7], testScore[8], testScore[9]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[10], testScore[11], testScore[12], testScore[13], testScore[14]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[15], testScore[16], testScore[17], testScore[18], testScore[19]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[20], testScore[21], testScore[22], testScore[23], testScore[23]);
    printf("\n");
    printf("%d %d %d %d %d", testScore[24], testScore[25], testScore[26], testScore[27], testScore[28]);
    printf("\n");
    printf("%d %d %d", testScore[29], testScore[30], testScore[31]);
    printf("\n");

    return 0;
}

Body:
I feel a little dirty doing this, but:

    int arrayDisplay(int *testScore, int size)
    {
        for (int i = 0 ; i < size; i++)
        {
          printf("%d ", testScore[i]);
          if (i%5==0)
          {
            printf("\n");
          }

        }

    return 0;

    }

To be clear: SO doesn't usually take kindly to these types of questions. Consider this your one free one ;)


问:
After inserting, only one character is inserted of "string" in database
Below is my table screenshot:

Data after insertion

Code in C#

```<code>SqlConnection con = new SqlConnection(connectionsession.Con);
con.Open();
SqlCommand cmd = new SqlCommand("finalinsert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@fid", SqlDbType.Int)).Value = flightsession.Sflightid;
cmd.Parameters.Add(new SqlParameter("@fcid", SqlDbType.Int)).Value = flightsession.Sflightcostid;
cmd.Parameters.Add(new SqlParameter("@ftid", SqlDbType.Int)).Value = flightsession.Sflighttimingid;
cmd.Parameters.Add(new SqlParameter("@frdn", SqlDbType.Date)).Value = DateTime.Now.ToString("dd-MM-yyyy");
cmd.Parameters.Add(new SqlParameter("@ford", SqlDbType.Date)).Value = flightsession.Regdate;
cmd.Parameters.Add(new SqlParameter("@uid", SqlDbType.Int)).Value = loginsession.Auser;
cmd.Parameters.Add(new SqlParameter("@paid", SqlDbType.Int)).Value = "1";
cmd.Parameters.Add(new SqlParameter("@source", SqlDbType.VarChar)).Value = flightsession.Sscource;
cmd.Parameters.Add(new SqlParameter("@destination", SqlDbType.VarChar)).Value = flightsession.Sdestination;
cmd.Parameters.Add(new SqlParameter("@fn", SqlDbType.VarChar)).Value = flightsession.Sflightname;
cmd.Parameters.Add(new SqlParameter("@fc", SqlDbType.VarChar)).Value = flightsession.Total;
cmd.Parameters.Add(new SqlParameter("@fty", SqlDbType.VarChar)).Value = flightsession.Stype;
cmd.Parameters.Add(new SqlParameter("@fcl", SqlDbType.VarChar)).Value = flightsession.Sflightclass;
cmd.Parameters.Add(new SqlParameter("@ft", SqlDbType.Time)).Value =flightsession.Sflighttime;
cmd.ExecuteNonQuery();
MessageBox.Show("Succesful");
con.Close();
flightreceipt ob18 = new flightreceipt();
ob18.ShowDialog();
this.Hide();
</code>```

Code for creating procedure in SQL server 2008

```<code>ALTER procedure [dbo].[finalinsert] @fid int,@fcid int,@ftid int,@frdn date,@ford date,@uid int,
@paid int,@source varchar,@destination varchar,@fc varchar,@fty varchar,@fcl varchar,@ft time(7) ,@fn varchar
AS
INSERT INTO [shangrila].[dbo].[flight_reg_table]
           ([flight_id]
           ,[flight_cost_id]
           ,[flight_time_id]
           ,[flight_reg_date_now]
           ,[flight_on_reg_date]
           ,[user_id]
           ,[paid]
           ,[source]
           ,[destination]
           ,[flight_name]
           ,[flight_cost]
           ,[flight_type]
           ,[flight_class]
           ,[flight_time])
     VALUES
           (@fid,
           @fcid,
           @ftid,
           @frdn,
           @ford,
           @uid,
           @paid,
           @source,
           @destination,
           @fn,
           @fc,
           @fty,
           @fcl,
           @ft)
</code>```

I tried to figure out why! But i am stuck.
Remember all format which I am inserting is string.
Thanks.

答: Along with the data type of the variables, you should mention the size of the data item. Ex: varchar(50)</p>

Body:
Below is my table screenshot:

Data after insertion

Code in C#

SqlConnection con = new SqlConnection(connectionsession.Con);
con.Open();
SqlCommand cmd = new SqlCommand("finalinsert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@fid", SqlDbType.Int)).Value = flightsession.Sflightid;
cmd.Parameters.Add(new SqlParameter("@fcid", SqlDbType.Int)).Value = flightsession.Sflightcostid;
cmd.Parameters.Add(new SqlParameter("@ftid", SqlDbType.Int)).Value = flightsession.Sflighttimingid;
cmd.Parameters.Add(new SqlParameter("@frdn", SqlDbType.Date)).Value = DateTime.Now.ToString("dd-MM-yyyy");
cmd.Parameters.Add(new SqlParameter("@ford", SqlDbType.Date)).Value = flightsession.Regdate;
cmd.Parameters.Add(new SqlParameter("@uid", SqlDbType.Int)).Value = loginsession.Auser;
cmd.Parameters.Add(new SqlParameter("@paid", SqlDbType.Int)).Value = "1";
cmd.Parameters.Add(new SqlParameter("@source", SqlDbType.VarChar)).Value = flightsession.Sscource;
cmd.Parameters.Add(new SqlParameter("@destination", SqlDbType.VarChar)).Value = flightsession.Sdestination;
cmd.Parameters.Add(new SqlParameter("@fn", SqlDbType.VarChar)).Value = flightsession.Sflightname;
cmd.Parameters.Add(new SqlParameter("@fc", SqlDbType.VarChar)).Value = flightsession.Total;
cmd.Parameters.Add(new SqlParameter("@fty", SqlDbType.VarChar)).Value = flightsession.Stype;
cmd.Parameters.Add(new SqlParameter("@fcl", SqlDbType.VarChar)).Value = flightsession.Sflightclass;
cmd.Parameters.Add(new SqlParameter("@ft", SqlDbType.Time)).Value =flightsession.Sflighttime;
cmd.ExecuteNonQuery();
MessageBox.Show("Succesful");
con.Close();
flightreceipt ob18 = new flightreceipt();
ob18.ShowDialog();
this.Hide();

Code for creating procedure in SQL server 2008

ALTER procedure [dbo].[finalinsert] @fid int,@fcid int,@ftid int,@frdn date,@ford date,@uid int,
@paid int,@source varchar,@destination varchar,@fc varchar,@fty varchar,@fcl varchar,@ft time(7) ,@fn varchar
AS
INSERT INTO [shangrila].[dbo].[flight_reg_table]
           ([flight_id]
           ,[flight_cost_id]
           ,[flight_time_id]
           ,[flight_reg_date_now]
           ,[flight_on_reg_date]
           ,[user_id]
           ,[paid]
           ,[source]
           ,[destination]
           ,[flight_name]
           ,[flight_cost]
           ,[flight_type]
           ,[flight_class]
           ,[flight_time])
     VALUES
           (@fid,
           @fcid,
           @ftid,
           @frdn,
           @ford,
           @uid,
           @paid,
           @source,
           @destination,
           @fn,
           @fc,
           @fty,
           @fcl,
           @ft)

I tried to figure out why! But i am stuck.
Remember all format which I am inserting is string.
Thanks.


问:
SKPaymentQueue.defaultQueue().removeTransactionObserver(self) Removing and adding
Right so i have this game on the app store called misshapen, in my game i have in app purchases which work fine however i have found a bug which will make the game crash if someone presses the in app purchase button then goes to the main menu (the IAP is on the options screen) if the user then go back to option and clicks of IAP the game crashes because there is already a transaction observer.

To fix my issue the line of code i need is

```<code>    SKPaymentQueue.defaultQueue().removeTransactionObserver(self)
</code>```

but im not sure where to call it because if it is called wrong then it promts the user will apple login screen all the time. My fix was to call it in

```<code> deinit {
        if SKPaymentQueue.canMakePayments() {
            SKPaymentQueue.defaultQueue().removeTransactionObserver(self)
        }
}
</code>```

this works and fixes my issue but when the user is returned to the menu the user gets promted with apple login screen and i dont want this!! Please help me thank you!! :)

答:
Add this before you closing your Purchase ViewController</p>

```<code>SKPaymentQueue.defaultQueue().removeTransactionObserver(self)
</code>```

Body:
Right so i have this game on the app store called misshapen, in my game i have in app purchases which work fine however i have found a bug which will make the game crash if someone presses the in app purchase button then goes to the main menu (the IAP is on the options screen) if the user then go back to option and clicks of IAP the game crashes because there is already a transaction observer.

To fix my issue the line of code i need is

    SKPaymentQueue.defaultQueue().removeTransactionObserver(self)

but im not sure where to call it because if it is called wrong then it promts the user will apple login screen all the time. My fix was to call it in

 deinit {
        if SKPaymentQueue.canMakePayments() {
            SKPaymentQueue.defaultQueue().removeTransactionObserver(self)
        }
}

this works and fixes my issue but when the user is returned to the menu the user gets promted with apple login screen and i dont want this!! Please help me thank you!! :)

Body:
Add this before you closing your Purchase ViewController

SKPaymentQueue.defaultQueue().removeTransactionObserver(self)


问:
Cannot set port forwarding on home router for ubuntu virtualbox guest destination
I have Windows 10 host machine running VirtualBox with an Ubuntu guest having a bridge adapter @ 192.168.1.5. Also, I am running a docker container in Ubuntu with ports bound to port 8080. I can hit the 192.168.1.5:8080 just fine from within my network (e.g. from my mobile and desktop host).

However, I cannot get port forwarding on my mi424wr router to forward to the ubuntu guest @ 192.168.1.5. I can get port forwarding to work against my Windows 10 machine.

Could there be something that my router doesn't like about the ubuntu guest vm?

Edited:
Here are the entries in the router security log when I try from my external ip address:

Port forward rule: 56123 -> 192.168.1.5:8080

Connection Opened: TCP 192.168.1.5:8080 <-->myIp:56123 [74.96.218.140:1024] CLOSED/CLOSED local_dev NAPT Incoming STATIC UNINIT UNSECURED

Connection opened: TCP 192.168.1.5:8080 <-->myIp:56123 [myIp:1025] CLOSED/CLOSED local_dev NAPT Incoming STATIC UNINIT UNSECURED

Wildcard connection hooked: TCP 192.168.1.5:8080 <-->myIp:56123 [myIp:1024] CLOSED/SYN_SENT local_dev NAPT Incoming STATIC BNAPT UNSECURED

Wildcard connection hooked: TCP 192.168.1.5:8080 <-->myIp:56123 [myIp:1025] CLOSED/SYN_SENT local_dev NAPT Incoming STATIC BNAPT UNSECURED

Connection Opened : TCP 192.168.1.5:8080 <-->myIp:56123 [74.96.218.140:1026] CLOSED/CLOSED local_dev NAPT Incoming STATIC UNINIT UNSECURED

Connection Opened: TCP 192.168.1.5:8080 <-->myIp:56123 [myIp:1026] CLOSED/CLOSED local_dev NAPT Incoming STATIC UNINIT UNSECURED

Wildcard connection hooked: TCP 192.168.1.5:8080 <-->myIp:56123 [myIp:1026] CLOSED/SYN_SENT local_dev NAPT Incoming STATIC BNAPT UNSECURED

my actual ip address was replaced with "myIp"

Also, I have tested with a http-server npm package hosting a static file. It works from within my LAN, but port forwarding fails also which should negate Docker as the culprit.

答:
Maybe this could be because of the firewall settings on the Ubuntu VM, the Docker container, or Windows Firewall as well. Perhaps they are set to allow 192.168.*.* private addresses but not public IP addresses?

See: UFW,
 iptables, Docker and iptables, Windows Firewall

I would step through each firewall configuration one by one and test if you can get through after each change you make. Note that UFW is just a front end for iptables, and may or may not be enabled.

If none of this seems to help, maybe you would have more success running the Ubuntu VM in NAT mode, with port forwarding setup through Virtual Box in addition to at your router.
See: Virtual Box Networking (especially 6.3.1).


问:
RecyclerView inside NestedScrollView scrolling issue
Iv seen many threads like that, but non of them helped me. When i use RecyclerView inside NestedScrollView im having scrolling issues - stuck. I know its because that is scroll inside scroll,

rv.setNestedScrollingEnabled(false); is not working for me.
on few thread there was information that NestedScrollView dont have to be used - but then toolbar is not collapsing.

My XML:

```<code>  <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleGravity="bottom"
            app:expandedTitleMarginStart="@dimen/activity_vertical_margin"
            app:expandedTitleTextAppearance="@style/CollapsedAppBarTopic"
            app:layout_collapseMode="parallax"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax">

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                 android:layout_marginTop="@dimen/activity_vertical_margin">

                    <RelativeLayout

                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ImageView
                            android:id="@+id/imageView2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="@dimen/activity_vertical_margin"
                            android:alpha="0.5"
                            app:layout_collapseMode="parallax"
                            app:srcCompat="@drawable/logo_white" />

                        <TextView
                            android:id="@+id/yourVotes"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_marginEnd="15dp"
                            android:layout_marginRight="15dp"
                            android:layout_toLeftOf="@+id/votesSum"
                            android:layout_toStartOf="@+id/votesSum"
                            android:text="@string/YourVotes"
                            android:textAlignment="viewStart" />

                        <TextView
                            android:id="@+id/votesSum"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_alignParentEnd="true"
                            android:layout_alignParentRight="true"
                            android:layout_marginRight="@dimen/activity_horizontal_margin"

                            android:text="1" />

                    </RelativeLayout>

                </FrameLayout>

            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbarDetails"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <TableLayout
            android:id="@+id/tableLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorBackground">

            <TableRow>

                <TextView
                    android:layout_weight="1"
                    android:elevation="1dp"
                    android:text="@string/VotesSum"
                    android:textAlignment="center" />

                <TextView
                    android:layout_weight="1"
                    android:elevation="0dp"
                    android:text="@string/TodayVotes"
                    android:textAlignment="center" />

                <TextView
                    android:layout_weight="1"
                    android:text="@string/TodayAdded"
                    android:textAlignment="center" />
            </TableRow>

            <TableRow>

                <TextView
                    android:layout_weight="1"
                    android:text="1"
                    android:textAlignment="center" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_weight="1"
                    android:text="2"
                    android:textAlignment="center" />

                <TextView
                    android:layout_weight="1"
                    android:text="3"
                    android:textAlignment="center" />
            </TableRow>
        </TableLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/tracks_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="60dp"
            android:background="@color/colorBackground" />

        <ProgressBar
            android:id="@+id/progressBarDetails"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center"
            android:background="@android:color/transparent" />

    </LinearLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/colorPrimary"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@drawable/bottom_nav_colors"
        app:itemTextColor="@drawable/bottom_nav_colors"
        app:menu="@menu/navigation" />
</android.support.design.widget.CoordinatorLayout>
</code>```

So, please help me to make that work

```<code>public class PlaylistDetailActivityWithoutFragmet extends AppCompatActivity {

    private TextView votesLeft;
    private RecyclerView lvTracks;
    private SinglePlaylistFragment_.OnFragmentInteractionListener mListener;
    SinglTracksAdapter recyclerViewAdapter;
    final ArrayList<PlaylistTracks> playlistsTracks = new ArrayList<PlaylistTracks>();
    final ArrayList<PlaylistTracks> playlistsTracks2 = new ArrayList<PlaylistTracks>();
    int lastId = 0;
    private boolean loading = true;
    ProgressBar progressBar;
    Toolbar toolbarDetails;
    CollapsingToolbarLayout collapsingToolbarLayout;
    int firstVisibleItem, visibleItemCount, totalItemCount;
    private int visibleThreshold = 2;
    final LinearLayoutManager llm = new LinearLayoutManager(this);

    int height;
    NestedScrollView nestedScrollView;
    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    //  mTextMessage.setText(R.string.Playlist);

                    return true;
                case R.id.navigation_dashboard:
                    //  mTextMessage.setText(R.string.Statistics);
                    return true;
                case R.id.navigation_notifications:
                    //    mTextMessage.setText(R.string.Users);
                    return true;
            }
            return false;
        }

    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_coordinator_layout);

        toolbarDetails = (Toolbar) findViewById(R.id.toolbarDetails);
        collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        setSupportActionBar(toolbarDetails);
        collapsingToolbarLayout.setTitle(playlistName);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        toolbarDetails.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_black_24dp));
        toolbarDetails.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mWebSocketClient.close();
                onBackPressed();

            }
        });

        llm.setOrientation(LinearLayoutManager.VERTICAL);

       //  nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScroll);

        lvTracks = (RecyclerView) findViewById(R.id.tracks_recycler_view);
        lvTracks.setLayoutManager(llm);
        lvTracks.setNestedScrollingEnabled(false);

//       nestedScrollView.setSmoothScrollingEnabled(true);
        progressBar = (ProgressBar) findViewById(R.id.progressBarDetails);
        progressBar.setVisibility(View.GONE);
        loading = true;
        getTracks();
        lvTracks.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                visibleItemCount = llm.getChildCount();
                totalItemCount = llm.getItemCount();
                firstVisibleItem = llm.findFirstVisibleItemPosition();
                Log.i("dx", String.valueOf(dx));
                Log.i("dy", String.valueOf(dy));
                Log.i("visibleItemCount", String.valueOf(visibleItemCount));
                Log.i("firstVisibleItem", String.valueOf(firstVisibleItem));
                Log.i("totalItemCount", String.valueOf(totalItemCount));
                if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {

                    loading = true;

                    getMoreTracks(1, 2);
                }
            }
        });

//
//        nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
//            @Override
//            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
//                if (!loading && v.getChildAt(v.getChildCount() - 1) != null) {
//                    if ((scrollY >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) &&
//                            scrollY > oldScrollY) {
//                        progressBar.setVisibility(View.VISIBLE);
//                        loading = true;
//
//                        getMoreTracks(scrollX, scrollY);
//
//
//                    }
//                }
//            }
//        });

        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

    }

    @Override
    public void onBackPressed() {
        mWebSocketClient.close();
        super.onBackPressed();
    }

    }

}
</code>```

Updated XML

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleGravity="bottom"
            app:expandedTitleMarginStart="@dimen/activity_vertical_margin"
            app:expandedTitleTextAppearance="@style/CollapsedAppBarTopic"
            app:layout_collapseMode="parallax"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax">

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/activity_vertical_margin">

                    <RelativeLayout

                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ImageView
                            android:id="@+id/imageView2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="@dimen/activity_vertical_margin"
                            android:alpha="0.5"
                            app:layout_collapseMode="parallax"
                            app:srcCompat="@drawable/logo_white" />

                        <TextView
                            android:id="@+id/yourVotes"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_marginEnd="15dp"
                            android:layout_marginRight="15dp"
                            android:layout_toLeftOf="@+id/votesSum"
                            android:layout_toStartOf="@+id/votesSum"
                            android:text="@string/YourVotes"
                            android:textAlignment="viewStart" />

                        <TextView
                            android:id="@+id/votesSum"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_alignParentEnd="true"
                            android:layout_alignParentRight="true"
                            android:layout_marginRight="@dimen/activity_horizontal_margin"

                            android:text="1" />

                    </RelativeLayout>

                </FrameLayout>

            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbarDetails"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/tracks_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="60dp"
            android:background="@color/colorBackground"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/colorPrimary"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@drawable/bottom_nav_colors"
        app:itemTextColor="@drawable/bottom_nav_colors"
        app:menu="@menu/navigation" />

</android.support.design.widget.CoordinatorLayout>
</code>```

答:
All you have to do is use below line in your activity class:

```<code>ViewCompat.setNestedScrollingEnabled(recycler_view, false);
</code>```

its compatible for lower versions also. and if you want to give compatible to API >21 only then use;

```<code>recycler_view.setNestedScrollingEnabled(false);
</code>```

Body:
Iv seen many threads like that, but non of them helped me. When i use RecyclerView inside NestedScrollView im having scrolling issues - stuck. I know its because that is scroll inside scroll,

rv.setNestedScrollingEnabled(false); is not working for me.
on few thread there was information that NestedScrollView dont have to be used - but then toolbar is not collapsing.

My XML:

  <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleGravity="bottom"
            app:expandedTitleMarginStart="@dimen/activity_vertical_margin"
            app:expandedTitleTextAppearance="@style/CollapsedAppBarTopic"
            app:layout_collapseMode="parallax"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax">

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                 android:layout_marginTop="@dimen/activity_vertical_margin">

                    <RelativeLayout

                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ImageView
                            android:id="@+id/imageView2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="@dimen/activity_vertical_margin"
                            android:alpha="0.5"
                            app:layout_collapseMode="parallax"
                            app:srcCompat="@drawable/logo_white" />

                        <TextView
                            android:id="@+id/yourVotes"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_marginEnd="15dp"
                            android:layout_marginRight="15dp"
                            android:layout_toLeftOf="@+id/votesSum"
                            android:layout_toStartOf="@+id/votesSum"
                            android:text="@string/YourVotes"
                            android:textAlignment="viewStart" />

                        <TextView
                            android:id="@+id/votesSum"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_alignParentEnd="true"
                            android:layout_alignParentRight="true"
                            android:layout_marginRight="@dimen/activity_horizontal_margin"

                            android:text="1" />

                    </RelativeLayout>

                </FrameLayout>

            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbarDetails"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <TableLayout
            android:id="@+id/tableLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorBackground">

            <TableRow>

                <TextView
                    android:layout_weight="1"
                    android:elevation="1dp"
                    android:text="@string/VotesSum"
                    android:textAlignment="center" />

                <TextView
                    android:layout_weight="1"
                    android:elevation="0dp"
                    android:text="@string/TodayVotes"
                    android:textAlignment="center" />

                <TextView
                    android:layout_weight="1"
                    android:text="@string/TodayAdded"
                    android:textAlignment="center" />
            </TableRow>

            <TableRow>

                <TextView
                    android:layout_weight="1"
                    android:text="1"
                    android:textAlignment="center" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_weight="1"
                    android:text="2"
                    android:textAlignment="center" />

                <TextView
                    android:layout_weight="1"
                    android:text="3"
                    android:textAlignment="center" />
            </TableRow>
        </TableLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/tracks_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="60dp"
            android:background="@color/colorBackground" />

        <ProgressBar
            android:id="@+id/progressBarDetails"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center"
            android:background="@android:color/transparent" />

    </LinearLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/colorPrimary"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@drawable/bottom_nav_colors"
        app:itemTextColor="@drawable/bottom_nav_colors"
        app:menu="@menu/navigation" />
</android.support.design.widget.CoordinatorLayout>

So, please help me to make that work

public class PlaylistDetailActivityWithoutFragmet extends AppCompatActivity {

    private TextView votesLeft;
    private RecyclerView lvTracks;
    private SinglePlaylistFragment_.OnFragmentInteractionListener mListener;
    SinglTracksAdapter recyclerViewAdapter;
    final ArrayList<PlaylistTracks> playlistsTracks = new ArrayList<PlaylistTracks>();
    final ArrayList<PlaylistTracks> playlistsTracks2 = new ArrayList<PlaylistTracks>();
    int lastId = 0;
    private boolean loading = true;
    ProgressBar progressBar;
    Toolbar toolbarDetails;
    CollapsingToolbarLayout collapsingToolbarLayout;
    int firstVisibleItem, visibleItemCount, totalItemCount;
    private int visibleThreshold = 2;
    final LinearLayoutManager llm = new LinearLayoutManager(this);

    int height;
    NestedScrollView nestedScrollView;
    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    //  mTextMessage.setText(R.string.Playlist);

                    return true;
                case R.id.navigation_dashboard:
                    //  mTextMessage.setText(R.string.Statistics);
                    return true;
                case R.id.navigation_notifications:
                    //    mTextMessage.setText(R.string.Users);
                    return true;
            }
            return false;
        }

    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_coordinator_layout);

        toolbarDetails = (Toolbar) findViewById(R.id.toolbarDetails);
        collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        setSupportActionBar(toolbarDetails);
        collapsingToolbarLayout.setTitle(playlistName);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        toolbarDetails.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_black_24dp));
        toolbarDetails.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mWebSocketClient.close();
                onBackPressed();

            }
        });

        llm.setOrientation(LinearLayoutManager.VERTICAL);

       //  nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScroll);

        lvTracks = (RecyclerView) findViewById(R.id.tracks_recycler_view);
        lvTracks.setLayoutManager(llm);
        lvTracks.setNestedScrollingEnabled(false);

//       nestedScrollView.setSmoothScrollingEnabled(true);
        progressBar = (ProgressBar) findViewById(R.id.progressBarDetails);
        progressBar.setVisibility(View.GONE);
        loading = true;
        getTracks();
        lvTracks.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                visibleItemCount = llm.getChildCount();
                totalItemCount = llm.getItemCount();
                firstVisibleItem = llm.findFirstVisibleItemPosition();
                Log.i("dx", String.valueOf(dx));
                Log.i("dy", String.valueOf(dy));
                Log.i("visibleItemCount", String.valueOf(visibleItemCount));
                Log.i("firstVisibleItem", String.valueOf(firstVisibleItem));
                Log.i("totalItemCount", String.valueOf(totalItemCount));
                if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {

                    loading = true;

                    getMoreTracks(1, 2);
                }
            }
        });

//
//        nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
//            @Override
//            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
//                if (!loading && v.getChildAt(v.getChildCount() - 1) != null) {
//                    if ((scrollY >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) &&
//                            scrollY > oldScrollY) {
//                        progressBar.setVisibility(View.VISIBLE);
//                        loading = true;
//
//                        getMoreTracks(scrollX, scrollY);
//
//
//                    }
//                }
//            }
//        });

        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

    }

    @Override
    public void onBackPressed() {
        mWebSocketClient.close();
        super.onBackPressed();
    }

    }

}

Updated XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleGravity="bottom"
            app:expandedTitleMarginStart="@dimen/activity_vertical_margin"
            app:expandedTitleTextAppearance="@style/CollapsedAppBarTopic"
            app:layout_collapseMode="parallax"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax">

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/activity_vertical_margin">

                    <RelativeLayout

                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <ImageView
                            android:id="@+id/imageView2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="@dimen/activity_vertical_margin"
                            android:alpha="0.5"
                            app:layout_collapseMode="parallax"
                            app:srcCompat="@drawable/logo_white" />

                        <TextView
                            android:id="@+id/yourVotes"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_marginEnd="15dp"
                            android:layout_marginRight="15dp"
                            android:layout_toLeftOf="@+id/votesSum"
                            android:layout_toStartOf="@+id/votesSum"
                            android:text="@string/YourVotes"
                            android:textAlignment="viewStart" />

                        <TextView
                            android:id="@+id/votesSum"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_alignParentEnd="true"
                            android:layout_alignParentRight="true"
                            android:layout_marginRight="@dimen/activity_horizontal_margin"

                            android:text="1" />

                    </RelativeLayout>

                </FrameLayout>

            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbarDetails"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/tracks_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="60dp"
            android:background="@color/colorBackground"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/colorPrimary"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@drawable/bottom_nav_colors"
        app:itemTextColor="@drawable/bottom_nav_colors"
        app:menu="@menu/navigation" />

</android.support.design.widget.CoordinatorLayout>

Body:
All you have to do is use below line in your activity class:

ViewCompat.setNestedScrollingEnabled(recycler_view, false);

its compatible for lower versions also. and if you want to give compatible to API >21 only then use;

recycler_view.setNestedScrollingEnabled(false);


问:
SharePoint | Filter a Calendar with a query string
I am looking for a way to filter a SharePoint Calendar WebPart by using a query string.  It looks like the default "Query string (URL) Filter" web part doesn't work for this.

Thanks for the help,

Chris

答:
I'm not sure on what you really wanted to achieve but try to check this out

http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx

you might find CAML queries useful on your end... this might help :)


问:
Vuejs: v-model array in multiple input
I have an input text field with a v-model attached, and every time someone hits the "Add" button, another input text gets added to the DOM with the same v-model attached. I thought I'd then get an array of the v-model values, but it only gets the value of the first v-model input:

```<code><div id="app">
  <div id="references">
    <input v-model="references" type="text">
  </div>
  <button @click="addReference">Add</button>
</div>
</code>```

The html I append to the dom is triggered by the addReference method:

```<code>addReference: function(e) {
  e.preventDefault();
  console.log(this.references);
  var inputEl = '<input v-model="references" type="text">';
  $('#references').append(inputEl);
}
</code>```

Is this something Vue.js can't do? Is there a different approach of gathering values from dynamic dom elements with Vue.js?

new Vue({
  el: "#app",
  data: {
    references: "text"
  },
  methods: {
    addReference: function(e) {
      e.preventDefault();
      console.log(this.references);
      var inputEl = '<input v-model="references" type="text">';
      $('#references').append(inputEl);
    }
  }
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>input {
  display: block;
  margin: 1px;
}</code>```

    <input v-model="references" type="text">

  <button @click="addReference">Add</button>

```

答:
If you were asking how to do it in vue2 and make options to insert and delete it, please, have a look an js fiddle

new Vue({
  el: '#app',
  data: {
    finds: []
  },
  methods: {
    addFind: function () {
      this.finds.push({ value: 'def' });
    },
    deleteFind: function (index) {
      console.log(index);
      console.log(this.finds);
      this.finds.splice(index, 1);
    }
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://unpkg.com/vue@2.5.3/dist/vue.js"></script>
<div id="app">
  <h1>Finds</h1>
  <div v-for="(find, index) in finds">
    <input v-model="find.value">
    <button @click="deleteFind(index)">
      delete
    </button>
  </div>

  <button @click="addFind">
    New Find
  </button>

  ```{{ $data }}```
</div></code>```

ContentLicense: CC BY-SA 4.0

Title: Vuejs: v-model array in multiple input

Body:
I have an input text field with a v-model attached, and every time someone hits the "Add" button, another input text gets added to the DOM with the same v-model attached. I thought I'd then get an array of the v-model values, but it only gets the value of the first v-model input:

    <input v-model="references" type="text">

  <button @click="addReference">Add</button>

The html I append to the dom is triggered by the addReference method:

addReference: function(e) {
  e.preventDefault();
  console.log(this.references);
  var inputEl = '<input v-model="references" type="text">';
  $('#references').append(inputEl);
}

Is this something Vue.js can't do? Is there a different approach of gathering values from dynamic dom elements with Vue.js?

new Vue({
  el: "#app",
  data: {
    references: "text"
  },
  methods: {
    addReference: function(e) {
      e.preventDefault();
      console.log(this.references);
      var inputEl = '<input v-model="references" type="text">';
      $('#references').append(inputEl);
    }
  }
})

input {
  display: block;
  margin: 1px;
}

    <input v-model="references" type="text">

  <button @click="addReference">Add</button>

Body:
If you were asking how to do it in vue2 and make options to insert and delete it, please, have a look an js fiddle

new Vue({
  el: '#app',
  data: {
    finds: []
  },
  methods: {
    addFind: function () {
      this.finds.push({ value: 'def' });
    },
    deleteFind: function (index) {
      console.log(index);
      console.log(this.finds);
      this.finds.splice(index, 1);
    }
  }
});

<script src="https://unpkg.com/vue@2.5.3/dist/vue.js"></script>
<div id="app">
  <h1>Finds</h1>
  <div v-for="(find, index) in finds">
    <input v-model="find.value">
    <button @click="deleteFind(index)">
      delete
    </button>
  </div>

  <button @click="addFind">
    New Find
  </button>

  <pre>{{ $data }}</pre>
</div>