问:
MySql database doesn't submit the values of my form
My database doesn't submit my values of my form, when I enter values into my form it shows nothing at all the varchar value columns and at the integer value columns there is a 0.   After I submit values

database

I'm using xampp.

```<code>   <?php
 error_reporting(0);

$con = mysqli_connect("localhost","root",'',"bwl_db");

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$dbhost = 'localhost';
$user = 'root';
$password = 'root123';
$database = 'bwl_db';

$Name =  $_POST['Name'];
$Surname =  $_POST['Surname'];
$Email =  $_POST['Email'];
$Telephone = $_POST['Telephone'];
$ID_Number = $_POST['ID_Number'];

$sql="INSERT INTO reg_db (Name,Surname,Email,Telephone,ID_Number)
VALUES ('$Name','$Surname','$Email','$Telephone','$ID_Number')";

if (!mysqli_query($con,$sql)) {
  die('Error: ' . mysqli_error($con));
}

mysqli_close($con);

error_reporting(0);
ini_set('display_errors', 0)

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <title>BWL | Registration </title>
    <meta charset="utf-8">
    <meta name="description" content="Simple, clean, responsive website built with html5, CSS3, Js, jQuery and Bootstrap">
    <meta name="keywords" content="web, design, html, css, html5, css3, javascript, jquery, bootstrap, development">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Google Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Raleway:500italic,600italic,600,700,700italic,300italic,300,400,400italic,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600italic,700,900' rel='stylesheet' type='text/css'>
    <!-- favicon -->
    <link rel="icon" type="image/png" href="images/favicon.png">
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <!-- Fontawesome  -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- responsive css -->
    <link rel="stylesheet" type="text/css" href="css/responsive.css"> </head>

<body>

    <div class="registaration-logo">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <img src="images/translogo.png" alt=" ">
            </div>
        </div>
    </div>

    <form class="form-registration" action="reg_db.php" method="post">
              <h2> Registration </h2>
        <div class="form-group-row">
            <label for="Name" class="col-2 col-form-label">Name</label>
            <div class="col-10">
                <input class="form-control" name="Name" type="text" id="Name" placeholder="Enter Name"> </div>
        </div>
        <div class="form-group-row">
            <label for="Surname" class="col-2 col-form-label">Surname</label>
            <div class="col-10">
                <input class="form-control" name="Surname"  type="text" id="Surname" placeholder="Enter Surname"> </div>
        </div>
        <div class="form-group-row">
            <label for="Email" class="col-2 col-form-label">Email</label>
            <div class="col-10">
                <input class="form-control" name="Email"  type="email" id="Email" placeholder="Enter email"> </div>
        </div>
        <div class="form-group-row">
            <label for="Confirm Email" class="col-2 col-form-label"> Confirm Email</label>
            <div class="col-10">
                <input class="form-control"  type="email" id="Confirm Email" placeholder="Confirm email"> </div>
        </div>
        <div class="form-group-row">
            <label for="Telephone" class="col-2 col-form-label">Telephone Number</label>
            <div class="col-10">
                <input class="form-control" name="Telephone"  type="tel" id="telephone" placeholder="Enter Telephone Number"> </div>
        </div>
        <div class="form-group-row">
            <label for="ID_Number" class="col-2 col-form-label">ID Number</label>
            <div class="col-10">
                <input class="form-control" name="ID_Number"  type="text" id="id-number" placeholder="Enter ID Number"> </div>
        </div>
        <div class="form-group-row">
            <div class="col-sm-10">
                    <a href="verify.html" class="btn btn-default1" role="button" type="submit">Submit</a>
            </div>
        </div>

        <div class="panel panel-default">
  <div class="panel-body">
    <h3> Disclaimer</h3>
      <p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
  </div>
        </div>
 </form>

</body>

</html>

 VERIFY.HTML PAGE
    <!DOCTYPE html>
<html lang="en">

<head>
    <title>BWL | Verify </title>
    <meta charset="utf-8">
    <meta name="description" content="Simple, clean, responsive website built with html5, CSS3, Js, jQuery and Bootstrap">
    <meta name="keywords" content="web, design, html, css, html5, css3, javascript, jquery, bootstrap, development">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Google Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Raleway:500italic,600italic,600,700,700italic,300italic,300,400,400italic,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600italic,700,900' rel='stylesheet' type='text/css'>
    <!-- favicon -->
    <link rel="icon" type="image/png" href="images/favicon.png">
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <!-- Fontawesome  -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- responsive css -->
    <link rel="stylesheet" type="text/css" href="css/responsive.css"> </head>

<body>

   <div class="verify">
  <div class="jumbotron">
    <h2>Thank You</h2>
    <p>We will send you your login information when you are verified.</p>
  </div>
       </div>
</body>

</html>
</code>```

答:
```<code><?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (isset($_POST['submit'])) {
$con = mysqli_connect("localhost", "root", '', "bwl_db");

if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$Name = $_POST['Name'];
$Surname = $_POST['Surname'];
$Email = $_POST['Email'];
$Telephone = $_POST['Telephone'];
$ID_Number = $_POST['ID_Number'];

$sql = "INSERT INTO reg_db (Name,Surname,Email,Telephone,ID_Number)
VALUES ('$Name','$Surname','$Email','$Telephone','$ID_Number')";

if (!mysqli_query($con, $sql)) {
    die('Error: ' . mysqli_error($con));
}

mysqli_close($con);
}

?>
</code>```

```<code><head>
    <title>BWL | Registration </title>
    <meta charset="utf-8">
    <meta name="description" content="Simple, clean, responsive website built with html5, CSS3, Js, jQuery and Bootstrap">
    <meta name="keywords" content="web, design, html, css, html5, css3, javascript, jquery, bootstrap, development">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Google Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Raleway:500italic,600italic,600,700,700italic,300italic,300,400,400italic,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600italic,700,900' rel='stylesheet' type='text/css'>
    <!-- favicon -->
    <link rel="icon" type="image/png" href="images/favicon.png">
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <!-- Fontawesome  -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- responsive css -->
    <link rel="stylesheet" type="text/css" href="css/responsive.css"> </head>

<body>

    <div class="registaration-logo">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <img src="images/translogo.png" alt=" ">
            </div>
        </div>
    </div>

    <form class="form-registration" action="" method="post">
        <h2> Registration </h2>
        <div class="form-group-row">
            <label for="Name" class="col-2 col-form-label">Name</label>
            <div class="col-10">
                <input class="form-control" name="Name" type="text" id="Name" placeholder="Enter Name"> </div>
        </div>
        <div class="form-group-row">
            <label for="Surname" class="col-2 col-form-label">Surname</label>
            <div class="col-10">
                <input class="form-control" name="Surname"  type="text" id="Surname" placeholder="Enter Surname"> </div>
        </div>
        <div class="form-group-row">
            <label for="Email" class="col-2 col-form-label">Email</label>
            <div class="col-10">
                <input class="form-control" name="Email"  type="email" id="Email" placeholder="Enter email"> </div>
        </div>
        <div class="form-group-row">
            <label for="Confirm Email" class="col-2 col-form-label"> Confirm Email</label>
            <div class="col-10">
                <input class="form-control"  type="email" id="Confirm Email" placeholder="Confirm email"> </div>
        </div>
        <div class="form-group-row">
            <label for="Telephone" class="col-2 col-form-label">Telephone Number</label>
            <div class="col-10">
                <input class="form-control" name="Telephone"  type="tel" id="telephone" placeholder="Enter Telephone Number"> </div>
        </div>
        <div class="form-group-row">
            <label for="ID_Number" class="col-2 col-form-label">ID Number</label>
            <div class="col-10">
                <input class="form-control" name="ID_Number"  type="text" id="id-number" placeholder="Enter ID Number"> </div>
        </div>
        <div class="form-group-row">
            <div class="col-sm-10">
                <input class="btn btn-default1" role="button" type="submit" name="submit" value="Submit">
            </div>
        </div>

        <div class="panel panel-default">
            <div class="panel-body">
                <h3> Disclaimer</h3>
                <p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
            </div>
        </div>
    </form>

</body>
</code>```

Body:
My database doesn't submit my values of my form, when I enter values into my form it shows nothing at all the varchar value columns and at the integer value columns there is a 0.   After I submit values

database

I'm using xampp.

   <?php
 error_reporting(0);

$con = mysqli_connect("localhost","root",'',"bwl_db");

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$dbhost = 'localhost';
$user = 'root';
$password = 'root123';
$database = 'bwl_db';

$Name =  $_POST['Name'];
$Surname =  $_POST['Surname'];
$Email =  $_POST['Email'];
$Telephone = $_POST['Telephone'];
$ID_Number = $_POST['ID_Number'];

$sql="INSERT INTO reg_db (Name,Surname,Email,Telephone,ID_Number)
VALUES ('$Name','$Surname','$Email','$Telephone','$ID_Number')";

if (!mysqli_query($con,$sql)) {
  die('Error: ' . mysqli_error($con));
}

mysqli_close($con);

error_reporting(0);
ini_set('display_errors', 0)

?>

<!DOCTYPE html>

    <title>BWL | Registration </title>
    <meta charset="utf-8">
    <meta name="description" content="Simple, clean, responsive website built with html5, CSS3, Js, jQuery and Bootstrap">
    <meta name="keywords" content="web, design, html, css, html5, css3, javascript, jquery, bootstrap, development">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href='https://fonts.googleapis.com/css?family=Raleway:500italic,600italic,600,700,700italic,300italic,300,400,400italic,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600italic,700,900' rel='stylesheet' type='text/css'>

    <link rel="icon" type="image/png" href="images/favicon.png">

    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">

    <link rel="stylesheet" href="css/font-awesome.min.css">

    <link rel="stylesheet" type="text/css" href="css/responsive.css">

    <form class="form-registration" action="reg_db.php" method="post">

 Registration

            Name

                <input class="form-control" name="Name" type="text" id="Name" placeholder="Enter Name">

            Surname

                <input class="form-control" name="Surname"  type="text" id="Surname" placeholder="Enter Surname">

            Email

                <input class="form-control" name="Email"  type="email" id="Email" placeholder="Enter email">

             Confirm Email

                <input class="form-control"  type="email" id="Confirm Email" placeholder="Confirm email">

            Telephone Number

                <input class="form-control" name="Telephone"  type="tel" id="telephone" placeholder="Enter Telephone Number">

            ID Number

                <input class="form-control" name="ID_Number"  type="text" id="id-number" placeholder="Enter ID Number">

                    Submit

 Disclaimer

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

 </form>

 VERIFY.HTML PAGE
    <!DOCTYPE html>

    <title>BWL | Verify </title>
    <meta charset="utf-8">
    <meta name="description" content="Simple, clean, responsive website built with html5, CSS3, Js, jQuery and Bootstrap">
    <meta name="keywords" content="web, design, html, css, html5, css3, javascript, jquery, bootstrap, development">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href='https://fonts.googleapis.com/css?family=Raleway:500italic,600italic,600,700,700italic,300italic,300,400,400italic,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600italic,700,900' rel='stylesheet' type='text/css'>

    <link rel="icon" type="image/png" href="images/favicon.png">

    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">

    <link rel="stylesheet" href="css/font-awesome.min.css">

    <link rel="stylesheet" type="text/css" href="css/responsive.css">

Thank You

We will send you your login information when you are verified.

Body:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (isset($_POST['submit'])) {
$con = mysqli_connect("localhost", "root", '', "bwl_db");

if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$Name = $_POST['Name'];
$Surname = $_POST['Surname'];
$Email = $_POST['Email'];
$Telephone = $_POST['Telephone'];
$ID_Number = $_POST['ID_Number'];

$sql = "INSERT INTO reg_db (Name,Surname,Email,Telephone,ID_Number)
VALUES ('$Name','$Surname','$Email','$Telephone','$ID_Number')";

if (!mysqli_query($con, $sql)) {
    die('Error: ' . mysqli_error($con));
}

mysqli_close($con);
}

?>

<head>
    <title>BWL | Registration </title>
    <meta charset="utf-8">
    <meta name="description" content="Simple, clean, responsive website built with html5, CSS3, Js, jQuery and Bootstrap">
    <meta name="keywords" content="web, design, html, css, html5, css3, javascript, jquery, bootstrap, development">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Google Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Raleway:500italic,600italic,600,700,700italic,300italic,300,400,400italic,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600italic,700,900' rel='stylesheet' type='text/css'>
    <!-- favicon -->
    <link rel="icon" type="image/png" href="images/favicon.png">
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <!-- Fontawesome  -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- responsive css -->
    <link rel="stylesheet" type="text/css" href="css/responsive.css"> </head>

<body>

    <div class="registaration-logo">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <img src="images/translogo.png" alt=" ">
            </div>
        </div>
    </div>

    <form class="form-registration" action="" method="post">
        <h2> Registration </h2>
        <div class="form-group-row">
            <label for="Name" class="col-2 col-form-label">Name</label>
            <div class="col-10">
                <input class="form-control" name="Name" type="text" id="Name" placeholder="Enter Name"> </div>
        </div>
        <div class="form-group-row">
            <label for="Surname" class="col-2 col-form-label">Surname</label>
            <div class="col-10">
                <input class="form-control" name="Surname"  type="text" id="Surname" placeholder="Enter Surname"> </div>
        </div>
        <div class="form-group-row">
            <label for="Email" class="col-2 col-form-label">Email</label>
            <div class="col-10">
                <input class="form-control" name="Email"  type="email" id="Email" placeholder="Enter email"> </div>
        </div>
        <div class="form-group-row">
            <label for="Confirm Email" class="col-2 col-form-label"> Confirm Email</label>
            <div class="col-10">
                <input class="form-control"  type="email" id="Confirm Email" placeholder="Confirm email"> </div>
        </div>
        <div class="form-group-row">
            <label for="Telephone" class="col-2 col-form-label">Telephone Number</label>
            <div class="col-10">
                <input class="form-control" name="Telephone"  type="tel" id="telephone" placeholder="Enter Telephone Number"> </div>
        </div>
        <div class="form-group-row">
            <label for="ID_Number" class="col-2 col-form-label">ID Number</label>
            <div class="col-10">
                <input class="form-control" name="ID_Number"  type="text" id="id-number" placeholder="Enter ID Number"> </div>
        </div>
        <div class="form-group-row">
            <div class="col-sm-10">
                <input class="btn btn-default1" role="button" type="submit" name="submit" value="Submit">
            </div>
        </div>

        <div class="panel panel-default">
            <div class="panel-body">
                <h3> Disclaimer</h3>
                <p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
            </div>
        </div>
    </form>

</body>


来源: stackexchange

问:
The sidebar always shows the wrong page as "active"
Whenever I create a new page in the sidebar, it always has the "active" state in the sidebar nav. When I go to other pages, the newly created page still has the active state.

I'm new to Dokuwiki, but any suggestions?

答: Disable caching in the sidebar using the ~~NOCACHE~~ macro. </p>

ContentLicense: CC BY-SA 3.0


问:
Programmatically switch between appicon-sets at runtime
I created two versions of my iOS app with Xcode 6 : free and paid. To visually differentiate one from the other I use different background colors : the free version is orange while the paid version is red. I am using one single project for both versions, and a global boolean variable changes the entire app from free to paid (and vice versa).

Of course, all the icons must be different too. I need two appicon sets: one full with orange icons, and the other with red icons.

So my problem is: how to programmatically switch between two appicon sets at runtime? How to tell my project that, if the global variable is false, use the orange icons set, and if it is true use the red icons set?

Next image ilustrate the two appicon sets, but how to call them in-code?

The idea is that, if by the end of the month you forget to pay your subscription, the app becomes orange, then you visually realise you forgot to pay, and after you pay the app turns red again.

答:
You can try below method introduced in iOS 10.3
https://developer.apple.com/reference/uikit/uiapplication/2806818-setalternateiconname</p>


问:
How do you update float data type in SQL column to hold numbers with upto 20 scale
I have a SQL table with a column having float data type with default precision.
I want this column to hold data with upto 20 digits after the decimal point.

How do I update existing column to do this?

答:
It depends on how much value You want to store to the left of the decimal point. Lets say only number from 0-9 and 20 digits on the right.</p>

```<code>Alter table tablename altercolumn columnname(21,20)
</code>```

Body:
It depends on how much value You want to store to the left of the decimal point. Lets say only number from 0-9 and 20 digits on the right.

Alter table tablename altercolumn columnname(21,20)


问:
need some help understanding an aspect of this code
Please refer the code below

```<code>import java.util.Scanner;

public class Reverse {

public static void main(String[] args) {

    String words = "";
    String output = "";

    Scanner scan = new Scanner(System.in);
    while (scan.hasNextLine()) {
        words = scan.nextLine();

        for (int i = 0; i < words.length(); i++) {
            output += words.charAt(words.length() - i - 1);
        }
        output += "\n";
    }
    System.out.print(output);

 }
}
</code>```

First of all, sorry for the vague title but I didn't know how to put it any other way. I am new to Java and for uni, we were given a task that read standard input until the end of file and then outputs the reverse of each line.

I was wondering how

```<code>String output
</code>```

is able to output multiple strings at the end. Shouldn't it only be able to hold one string? Sorry if this question doesn't make much sense.

答:
Because
String is an immutable class in Java. An immutable class is simply a class whose instances cannot be modified. All information in an instance is initialized when the instance is created and the information can not be modified.

```<code>public class ExampleString{

public static void main(String[] args) {

   String examp="";
   examp="HI";
   examp=examp+"HOW";
   System.out.println(examp);

 }
}
</code>```

output: HIHOW

Body:
Please refer the code below

import java.util.Scanner;

public class Reverse {

public static void main(String[] args) {

    String words = "";
    String output = "";

    Scanner scan = new Scanner(System.in);
    while (scan.hasNextLine()) {
        words = scan.nextLine();

        for (int i = 0; i < words.length(); i++) {
            output += words.charAt(words.length() - i - 1);
        }
        output += "\n";
    }
    System.out.print(output);

 }
}

First of all, sorry for the vague title but I didn't know how to put it any other way. I am new to Java and for uni, we were given a task that read standard input until the end of file and then outputs the reverse of each line.

I was wondering how

String output

is able to output multiple strings at the end. Shouldn't it only be able to hold one string? Sorry if this question doesn't make much sense.

Body:
Because
String is an immutable class in Java. An immutable class is simply a class whose instances cannot be modified. All information in an instance is initialized when the instance is created and the information can not be modified.

public class ExampleString{

public static void main(String[] args) {

   String examp="";
   examp="HI";
   examp=examp+"HOW";
   System.out.println(examp);

 }
}

output: HIHOW


问:
Uncaught SyntaxError: Invalid or unexpected token one element works but other one does not
When I run this code it works fine, but if I add another select box it does not work - actually 'Select Project Team Member Role' does not work at all but 'Select Project Team Member' works really fine.

When I run code for 'Select Project Team Member Role' it gives error 'uncaught SyntaxError: Invalid or unexpected token'

I need both select box and when I run both none works. I cant find what is the error; please help me out.

HTML

```<code><form name="add_name" id="add_name">
  <div class="table-responsive">
    <table class="table table-bordered" id="dynamic_field">
      <tr>
        <td>
          <select name="projteam[]" id="projmem_id" class="form-control">
            <option> Select Project Team Member</option>
            <?php foreach($this->memdata as $pc){ ?>
              <option value="<?php echo $pc->id ?>"><?php echo $pc->name ?></option>
            <?php } ?>
          </select>
         </td>
        <td>
          <select name="keyrole[]" id="role_id" class="form-control">
            <option> Select Project Team Member Role</option>
            <?php foreach($this->roldata as $mr){ ?>
              <option value="<?php echo $mr->id ?>"><?php echo $mr->key_role ?></option>
            <?php } ?>
          </select>
        </td>
        <td>
          <button type="button" name="add" id="add" class="btn btn-success">Add More</button>
        </td>
      </tr>
    </table>
  </div>
</form>
</code>```

JavaScript

```<code><script>
  $(document).ready(function(){
    var i=1;
    $('#add').click(function(){
      i++;
      $('#dynamic_field').append('<tr id="row'+i+'"><td><input type="text" name="name[]" placeholder="Enter your Name" class="form-control name_list" /></td><td><select name="projteam[]" id="projmem_id" class="form-control"><option> Select Project Team Member</option> <?php foreach($this->memdata as $pc){ ?> <option value="<?php echo $pc->id ?>"><?php echo $pc->name ?></option> <?php } ?> </select></td><td><select name="keyrole[]" id="role_id" class="form-control"><option> Select Project Team Member Role</option> <?php foreach($this->roldata as $mr){ ?> <option value="<?php echo $mr->id ?>"><?php echo $mr->key_role ?></option> <?php } ?> </select></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');
    });
    $(document).on('click', '.btn_remove', function(){
      var button_id = $(this).attr("id");
      $('#row'+button_id+'').remove();
    });
  });
</script>
</code>```

答:
The html you have written looks fine but not the JavaScript. Because the PHP piece in the click event will return the html before the event occured. Might be good suggestion to keep your select ready and hidden. Add style='display:none'.
And in the add click event just show them $('#projmem_id').Show(). This way you can keep a clear distinction.</p>

Body:
When I run this code it works fine, but if I add another select box it does not work - actually 'Select Project Team Member Role' does not work at all but 'Select Project Team Member' works really fine.

When I run code for 'Select Project Team Member Role' it gives error 'uncaught SyntaxError: Invalid or unexpected token'

I need both select box and when I run both none works. I cant find what is the error; please help me out.

HTML

<form name="add_name" id="add_name">

          <select name="projteam[]" id="projmem_id" class="form-control">
            <option> Select Project Team Member</option>
            <?php foreach($this->memdata as $pc){ ?>
              <option value="<?php echo $pc->id ?>"><?php echo $pc->name ?></option>
            <?php } ?>
          </select>

          <select name="keyrole[]" id="role_id" class="form-control">
            <option> Select Project Team Member Role</option>
            <?php foreach($this->roldata as $mr){ ?>
              <option value="<?php echo $mr->id ?>"><?php echo $mr->key_role ?></option>
            <?php } ?>
          </select>

          <button type="button" name="add" id="add" class="btn btn-success">Add More</button>

</form>

JavaScript


问:
Sharing detail with email for windows mobile7
I am working on an application for windows mobile 7.
I need to send some information from my application to some user via email.
I am using "EmailComposeTask()" for this. But i am getting error "email cant send. make sure u have setup an accout"

How to setup an email account in windows7 emulator.
Can anyone help me?

Following code i am using ...

emailComposeTask = new EmailComposeTask();
            emailComposeTask.Body = textBox1.Text;
            emailComposeTask.To = textBox2.Text;
            emailComposeTask.From=TextBox3.Text;
            emailComposeTask.Show();

Thanks

答:
The EmailComposeTask can't be used in the emulator.

Your code seems correct, it should work on a real device.

ContentLicense: CC BY-SA 2.5


问:
UISearchBar button
I was working on the UISearchBar in Xcode and while running the app, this button appeared in the search text field and it's still there since.

Did anybody face this problem before? How to delete this button.

答: Untick the box shows search results button. it will hide

Title: UISearchBar button


问:
Django Content-Type : Checking if a field is declared as Many-to-Many field
I checking few field names passed by the APIs from the browser and validating them before passing to Django ORM queries.

The question is for a given mode and given field name, how can I determine if the field is declared as Many-to-Many field using the Content-Type framework?

答:
You can get the field and check its .many_to_many property:

```<code>>>> content_type = ContentType.objects.get(model="<model_name>")
>>> field = content_type.model_class()._meta.get_field("<field_name>")
>>> field.many_to_many
True
</code>```

Body:
You can get the field and check its .many_to_many property:

>>> content_type = ContentType.objects.get(model="<model_name>")
>>> field = content_type.model_class()._meta.get_field("<field_name>")
>>> field.many_to_many
True


问:
Identity function (for use in forks, eg)
Consider:

```<code>(i. 5) */ (i. 5)
</code>```

which produces:

```<code>0 0 0  0  0
0 1 2  3  4
0 2 4  6  8
0 3 6  9 12
0 4 8 12 16
</code>```

Is there an identity function that would, eg, allow me to write that expression with a fork, without repeating (i. 5)?

EDIT

I've answered my own question below, but came upon the answer by luck.  If anyone can offer suggestions for searching J's docs "by function" or by keyword, I'd appreciate it.  In this case, it would have been nice to type "identity" into a documentation search, and see the "Reflexive" operator as a suggestion.

答:
You could, indeed, use j's identity functions in a fork to achieve the result you asked for. The reflex adverb is more concise, but that's not a fork.

Here's the implementation you originally specified:

```<code>   ([*/]) i. 5
0 0 0  0  0
0 1 2  3  4
0 2 4  6  8
0 3 6  9 12
0 4 8 12 16
</code>```

A google search site:jsoftware.com identity might have worked for you, since you already understood forks.

Body:
Consider:

(i. 5) */ (i. 5)

which produces:

0 0 0  0  0
0 1 2  3  4
0 2 4  6  8
0 3 6  9 12
0 4 8 12 16

Is there an identity function that would, eg, allow me to write that expression with a fork, without repeating (i. 5)?

EDIT

I've answered my own question below, but came upon the answer by luck.  If anyone can offer suggestions for searching J's docs "by function" or by keyword, I'd appreciate it.  In this case, it would have been nice to type "identity" into a documentation search, and see the "Reflexive" operator as a suggestion.

Body:
You could, indeed, use j's identity functions in a fork to achieve the result you asked for. The reflex adverb is more concise, but that's not a fork.

Here's the implementation you originally specified:

   ([*/]) i. 5
0 0 0  0  0
0 1 2  3  4
0 2 4  6  8
0 3 6  9 12
0 4 8 12 16

A google search site:jsoftware.com identity might have worked for you, since you already understood forks.


问:
Changing background colour of specific select2 through javascript
In a web form, I'm using two select2 control at two panel each.

I wish to change only one of the select2's background colour when it hit certain condition through javascript else it will remain its original colour.

How can I accomplish that?

I am at the stage where the css code below I found is able to modify the select2 to the result I want.

```<code>       .select2-container .select2-selection{
        background: yellow;
        }
</code>```

Any help is much appreciated.

Edited:

Adding some part of my code:

CSS

```<code>    .select2-container {
        position: relative;
        z-index: 2;
        float: left;
        margin-bottom: 0;
        display: table;
        table-layout: fixed;
        font-size: smaller;
    }
</code>```

Markup

```<code><div class="container-fluid">
    <div class="col-md-7">
        <table>
           <tr>
                 <td>
                     <select id="ddl_Select2ONE" runat="server" class="form-control select"></select>
                 </td>
           </tr>
        </table>
    </div>
    <div class="col-md-5">
        <table>
           <tr>
                 <td>
                     <select id="ddl_Select2TWO" runat="server" class="form-control select"></select>
                 </td>
           </tr>
        </table>
    </div>
</div>
</code>```

Javascript

```<code>pageLoad(){
  configureSelect2()
}

configureSelect2(){
    if(hf_value.value == "1"){
        //Change only ddl_Select2ONE to yellow background
    }
    else{
        //Change only ddl_Select2ONE to original background
    }
}
</code>```

Then I will perform some checking on javascript's pageload when it check a hidden field value for conditional enable.

答:
You can use:

```<code>document.getElementById('idOfElement').classList.add('select2-container')`;
</code>```

Or using jquery:

```<code>$("#idOfElement").addClass("select2-container");
$("#idOfElement").addClass("select2-selection");
</code>```

Body:
In a web form, I'm using two select2 control at two panel each.

I wish to change only one of the select2's background colour when it hit certain condition through javascript else it will remain its original colour.

How can I accomplish that?

I am at the stage where the css code below I found is able to modify the select2 to the result I want.

       .select2-container .select2-selection{
        background: yellow;
        }

Any help is much appreciated.

Edited:

Adding some part of my code:

CSS

    .select2-container {
        position: relative;
        z-index: 2;
        float: left;
        margin-bottom: 0;
        display: table;
        table-layout: fixed;
        font-size: smaller;
    }

Markup

                     <select id="ddl_Select2ONE" runat="server" class="form-control select"></select>

                     <select id="ddl_Select2TWO" runat="server" class="form-control select"></select>

Javascript

pageLoad(){
  configureSelect2()
}

configureSelect2(){
    if(hf_value.value == "1"){
        //Change only ddl_Select2ONE to yellow background
    }
    else{
        //Change only ddl_Select2ONE to original background
    }
}

Then I will perform some checking on javascript's pageload when it check a hidden field value for conditional enable.

Body:
You can use:

document.getElementById('idOfElement').classList.add('select2-container')`;

Or using jquery:

$("#idOfElement").addClass("select2-container");
$("#idOfElement").addClass("select2-selection");


问:
NameError: name 'myconf' is not defined
I am working on web2py image blog.

I am unable to understand these errors:

Internal error

Ticket issued: images/127.0.0.1.2016-11-22.16-44-39.95144250-6a2e-4648-83f9-aa55873e6ae8

Error ticket for "images"
  Ticket ID
  127.0.0.1.2016-11-22.16-44-39.95144250-6a2e-4648-83f9-aa55873e6ae8

type 'exceptions.NameError'> name 'myconf' is not defined

Version
  web2py™    Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
  Python Python 2.7.12: /usr/bin/python (prefix: /usr)

Traceback (most recent call last):

File "/home/sonu/Software/web2py /gluon/restricted.py", line 227, in restricted
      exec ccode in environment

File "/home/sonu/Software/web2py /applications/images/models/menu.py", line 17, in
      response.meta.author = myconf.get('app.author')
  NameError: name 'myconf' is not defined

答:
I fixed this very same problem as follows:

I removed models/menu.py, and then the problem appears to be solved.

=> Remeber delete the models/menu.py

Title: NameError: name 'myconf' is not defined


问:
My jquery click isnt working
I am making a website and I included jQuery.

When I use click events, it isn't working.

HTML

```<code><body>
  <header>
    <h1 class="text-center">Pomodoro Clock</h1>
  </header>

  <section class="container">

    <div id="counter-main">
      <h1>Session Time</h1>
      <a href="#" class="btn btn-primary" id="plusCounterMain">-</a>
      <h2 id="timerMain">5</h2>
      <a href="#" class="btn btn-primary" id="minusCounterMain">+</a>
    </div>
    <div id="resetDiv">
      <a href="#" class="btn btn-primary" id="resetMain">Reset</a>
    </div>

    <div id="break-main">
      <h1>Session Time</h1>
      <a href="#" class="btn btn-primary" id="plusBreakMain">-</a>
      <h2 id="breakCount">5</h2>
      <a href="#" class="btn btn-primary" id="minusBreakMain">+</a>
    </div>
    <div id="startDiv">
      <button class="btn btn-primary" id="start">Start</button>
    </div>
  </section>
  <!-- jQuery library -->
  <script type="text/javascript" src="jquery-3.2.0"></script>
</body>
</code>```

Here is my JavaScript(jQuery) code:

```<code>$(document).ready(function(){
  var timer_main = $("#timerMain");
  var break_count = $("#breakCount");

  var count = parseInt(timer_main.html());
  var break = parseInt(break_count.html());

  $("plusCounterMain").click(function(){
    count +=5;
    console.log(count.toString());
    timer_main.text(count.toString());
  });

  $("#start").click(function{
    var counter = setInterval(timer,1000);

    function timer() {
      count -=1;
      if (count === 0) {
        clearInterval(counter);
      }
      $("#timerMain").text(count.toString());
    }
  });
});
</code>```

I have no idea where I went wrong.

I was trying to make a pomodoro clock, so I used the setInterval function to execute code every second.

Where have I went wrong?

答:
Check your click events in console with following approach</p>

```<code>$(document).on('click','#plusCounterMain',function(){
       console.log('In plusCounterMain');
});

$(document).on('click','#start',function(){
       console.log('In start');
});
</code>```

Title: My jquery click isnt working

Body:
I am making a website and I included jQuery.

When I use click events, it isn't working.

HTML

Pomodoro Clock

Session Time

      -

5

      +

      Reset

Session Time

      -

5

      +

      <button class="btn btn-primary" id="start">Start</button>

Here is my JavaScript(jQuery) code:

$(document).ready(function(){
  var timer_main = $("#timerMain");
  var break_count = $("#breakCount");

  var count = parseInt(timer_main.html());
  var break = parseInt(break_count.html());

  $("plusCounterMain").click(function(){
    count +=5;
    console.log(count.toString());
    timer_main.text(count.toString());
  });

  $("#start").click(function{
    var counter = setInterval(timer,1000);

    function timer() {
      count -=1;
      if (count === 0) {
        clearInterval(counter);
      }
      $("#timerMain").text(count.toString());
    }
  });
});

I have no idea where I went wrong.

I was trying to make a pomodoro clock, so I used the setInterval function to execute code every second.

Where have I went wrong?

Body:
Check your click events in console with following approach

$(document).on('click','#plusCounterMain',function(){
       console.log('In plusCounterMain');
});

$(document).on('click','#start',function(){
       console.log('In start');
});


问:
Hazelcast throwing EventQueue overloaded error in a cluster.
I am getting the following error in the program.

```<code>WARNING: [192.168.2.50]:5703 [dev] [3.9-SNAPSHOT] EventQueue overloaded! Failed to process event packet sent from: [192.168.2.50]:5702
</code>```

Mar 28, 2017 12:32:53 PM com.hazelcast.spi.EventService

This is just a sample program that i have written and I have used only a single distributed map which contains around 5 entries. Thus even if there is way to increase the size of the EventQueue, it shouldn't have run out so fast.

What could be the possible reason for such an error. ?

答: Just guessing into the blue but what do your event listeners do? Event listeners are not supposed to have long running operations as they either block the event queues or event threads. Heavy workload should be offloaded to separate threadpools.</p>

Body:
I am getting the following error in the program.

WARNING: [192.168.2.50]:5703 [dev] [3.9-SNAPSHOT] EventQueue overloaded! Failed to process event packet sent from: [192.168.2.50]:5702

Mar 28, 2017 12:32:53 PM com.hazelcast.spi.EventService

This is just a sample program that i have written and I have used only a single distributed map which contains around 5 entries. Thus even if there is way to increase the size of the EventQueue, it shouldn't have run out so fast.

What could be the possible reason for such an error. ?


问:
Changes in local gem does not show in the application in Rails 5
I am developing a gem for my application and want to see if my gem is working on a real application or not, but the problem is if I want to see the changes in the application I have to restart the server.

I have googled the issue but all the solutions were either not working or relatively old (backing to rails 3 or so); is there any way to see the changes without restarting the server in rails 5?

答: I don't think you can because Gems are initialized when you start the server. Any change to the gemfile or gems themselves will require a server restart. The same is true about Routes, Config, etc.</p>


问:
Android Fragment appends when calling other fragment
Im currently working on a sample app that will be using fragments, but im having a little problem regarding changing the fragment.

My default layout for my fragment is fragmentOne (see code below).

```<code><fragment
    android:id="@+id/fplace"
    android:layout_width="match_parent"
    android:layout_height="498dp"
    android:name="layout.FragmentOne"
    tools:layout="@layout/fragment_fragment_one" />
</code>```

and that's working correctly.

but when im changing the fragment it appends. the behavior must replace the fragment not append.

here is my code for the activity (see code below).

```<code>public void onClick(View view) {
    Button button = (Button) view;
    Fragment fragment = null;
    switch (button.getId()) {
        case R.id.f1:
            fragment = new FragmentOne();
            FragmentManager fm = getFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            ft.replace(R.id.fplace, fragment);
            ft.commit();
            break;
        case R.id.f2:
            fragment = new FragmentTwo();
            fm = getFragmentManager();
            ft = fm.beginTransaction();
            ft.replace(R.id.fplace, fragment);
            ft.commit();
            break;
    }
}
</code>```

and from the fragment one i am loading the data from the onCreateView() which is working correctly. the main problem is the fragment appends not replace.

(see photo below)

the red and yellow must be replaced by the blue colored fragment

答:
As Mike said in comment

You cannot remove/replace Fragments that are declared in your layout.

So here is solution for you. Instead of fragment in xml use framelayout as container which will hold the fragment

use this instead of fragment in xml

```<code><FrameLayout
    android:id="@+id/fplace"
    android:layout_width="match_parent"
    android:layout_height="498dp"
    />
</code>```

Hope this will help you.

Body:
Im currently working on a sample app that will be using fragments, but im having a little problem regarding changing the fragment.

My default layout for my fragment is fragmentOne (see code below).

<fragment
    android:id="@+id/fplace"
    android:layout_width="match_parent"
    android:layout_height="498dp"
    android:name="layout.FragmentOne"
    tools:layout="@layout/fragment_fragment_one" />

and that's working correctly.

but when im changing the fragment it appends. the behavior must replace the fragment not append.

here is my code for the activity (see code below).

public void onClick(View view) {
    Button button = (Button) view;
    Fragment fragment = null;
    switch (button.getId()) {
        case R.id.f1:
            fragment = new FragmentOne();
            FragmentManager fm = getFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            ft.replace(R.id.fplace, fragment);
            ft.commit();
            break;
        case R.id.f2:
            fragment = new FragmentTwo();
            fm = getFragmentManager();
            ft = fm.beginTransaction();
            ft.replace(R.id.fplace, fragment);
            ft.commit();
            break;
    }
}

and from the fragment one i am loading the data from the onCreateView() which is working correctly. the main problem is the fragment appends not replace.

(see photo below)

the red and yellow must be replaced by the blue colored fragment

Body:
As Mike said in comment

You cannot remove/replace Fragments that are declared in your layout.

So here is solution for you. Instead of fragment in xml use framelayout as container which will hold the fragment

use this instead of fragment in xml

<FrameLayout
    android:id="@+id/fplace"
    android:layout_width="match_parent"
    android:layout_height="498dp"
    />

Hope this will help you.


问:
Mongoose using subquery in aggregation to sum data
I am new in mongoose. I have model like this.

```<code>var ForumSchema = new mongoose.Schema({
User_id             : {type : Schema.Types.ObjectId, ref : 'User'},
Title               : {type : String},
Content             : {type : String},
Tags                : [{type : String}],
isPublic            : {type : Boolean, default : false},
Vote                : [{
    User_id         : {type : Schema.Types.ObjectId, ref : 'User'},
    Kind            : {type : Boolean}
}],
Rate                : [{
    User_id         : {type : Schema.Types.ObjectId, ref : 'User'},
    Count           : {type : Number}
}],
Comment             : [{
    User_id         : {type : Schema.Types.ObjectId, ref : 'User'},
    Content         : String,
    Created_at      : {type : Date, required : true, default : Date.now}
}],
Created_at          : {type : Date, required : true, default : Date.now},
Updated_at          : {type : Date}
</code>```

});

I want to get Forum data with sum of Vote that value is true. Like this json.

```<code>{
[
    _id         : <Some object id>,
    User_id     : <Some object id from User Model>,
    Title       : <Title>,
    Content     : <Content>,
    Tags        : [Some array],
    isPublic    : true,
    UpVote      : 23,
    ....
    ....
    ....
]
</code>```

}

In mysql I can do this by using subquery. How can I do it in mongoose?

答:
With MongoDB server 3.4 and above, you can run an aggregate pipeline that uses the $addFields operator which has a $filter on the Vote array to filter those element that have a Kind property value matching true and when you get the filtered array, use it as an input expression for the $size operator which then calculates the count of the items in the filtered array.

Consider the following operation to get the desired result:

```<code>Forum.aggregate([
    {
        "$addFields": {
            "UpVote": {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": "$$el.Kind"
                    }
                }
            }
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})
</code>```

Explanations

In the above, the inner expression

```<code>{
    "$filter": {
        "input": "$Vote",
        "as": "el",
        "cond": "$$el.Kind"
    }
}
</code>```

selects a subset of the array to return based on the specified condition. As a result, it returns an array with only those elements that match the condition.

The input property refers to an expression that resolves to an array. In the above, the input is the Votes array.

The other field as represents the variable name for the element in the input array. The as expression accesses each element in the input array by this variable.

The cond field holds an expression that determines whether to include the element in the resulting array. The expression accesses the element by the variable name specified in as.

So in the above if the element in the array being evaluated has the Kind subproperty equal to true, denoted by the expression "$$el.Kind", then the condition is matched and the element is included in the subset to be returned.

As a simple example, take for instance this high-level expression:

```<code>{
    "$filter": {
        "input": [
            { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
            { "Kind": false, "User_id": "58ad50a429b2961777f91c97" },
            { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
        ],
        "as": "el",
        "cond": {
            "$eq": ["$$el.Kind", true]
        }
    }
}
</code>```

returns the array

```<code>[
    { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
    { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
]
</code>```

The conditional part

```<code>"cond": {
    "$eq": ["$$el.Kind", true]
}
</code>```

can be simplified to just

```<code>"cond": "$$el.Kind"
</code>```

as "$$el.Kind" expression already evaluates to a boolean.

The $size operator trivially calculates the number of elements in an array, thus the expression, for example

```<code>{
    "$size":    {
        "$filter": {
            "input": [
                { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
                { "Kind": false, "User_id": "58ad50a429b2961777f91c97" },
                { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
            ],
            "as": "el",
            "cond": {
                "$eq": ["$$el.Kind", true]
            }
        }
    }
}
</code>```

is expressed as

```<code>{
    "$size": [
        { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
        { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
    ]
}
</code>```

and return a result with 2 as count.

For the contrary DownVote count, the same logic applies:

```<code>Forum.aggregate([
    {
        "$addFields": {
            "UpVote": {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": "$$el.Kind"
                    }
                }
            },
            "DownVote": {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": { "$not": ["$$el.Kind"] }
                    }
                }
            }
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})
</code>```

For the earlier MongoDB version 3.2, you will need to project each and every other element in the document:

```<code>Forum.aggregate([
    {
        "$project": {
            "User_id"     : 1,
            "Title"       : 1,
            "Content"     : 1,
            "Tags"        : 1,
            "isPublic"    : 1,
            "UpVote"      : {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": "$$el.Kind"
                    }
                }
            },
            ....
            ....
            ....
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})
</code>```

For versions that do not support the $filter operator, use the $setDifference operator instead as:

```<code>{
    "$filter": {
        "input": "$Vote",
        "as": "el",
        "cond": "$$el.Kind"
    }
}
</code>```0

Body:
I am new in mongoose. I have model like this.

var ForumSchema = new mongoose.Schema({
User_id             : {type : Schema.Types.ObjectId, ref : 'User'},
Title               : {type : String},
Content             : {type : String},
Tags                : [{type : String}],
isPublic            : {type : Boolean, default : false},
Vote                : [{
    User_id         : {type : Schema.Types.ObjectId, ref : 'User'},
    Kind            : {type : Boolean}
}],
Rate                : [{
    User_id         : {type : Schema.Types.ObjectId, ref : 'User'},
    Count           : {type : Number}
}],
Comment             : [{
    User_id         : {type : Schema.Types.ObjectId, ref : 'User'},
    Content         : String,
    Created_at      : {type : Date, required : true, default : Date.now}
}],
Created_at          : {type : Date, required : true, default : Date.now},
Updated_at          : {type : Date}

});

I want to get Forum data with sum of Vote that value is true. Like this json.

{
[
    _id         : <Some object id>,
    User_id     : <Some object id from User Model>,
    Title       : <Title>,
    Content     : <Content>,
    Tags        : [Some array],
    isPublic    : true,
    UpVote      : 23,
    ....
    ....
    ....
]

}

In mysql I can do this by using subquery. How can I do it in mongoose?

Body:
With MongoDB server 3.4 and above, you can run an aggregate pipeline that uses the $addFields operator which has a $filter on the Vote array to filter those element that have a Kind property value matching true and when you get the filtered array, use it as an input expression for the $size operator which then calculates the count of the items in the filtered array.

Consider the following operation to get the desired result:

Forum.aggregate([
    {
        "$addFields": {
            "UpVote": {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": "$$el.Kind"
                    }
                }
            }
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})

Explanations

In the above, the inner expression

{
    "$filter": {
        "input": "$Vote",
        "as": "el",
        "cond": "$$el.Kind"
    }
}

selects a subset of the array to return based on the specified condition. As a result, it returns an array with only those elements that match the condition.

The input property refers to an expression that resolves to an array. In the above, the input is the Votes array.

The other field as represents the variable name for the element in the input array. The as expression accesses each element in the input array by this variable.

The cond field holds an expression that determines whether to include the element in the resulting array. The expression accesses the element by the variable name specified in as.

So in the above if the element in the array being evaluated has the Kind subproperty equal to true, denoted by the expression "$$el.Kind", then the condition is matched and the element is included in the subset to be returned.

As a simple example, take for instance this high-level expression:

{
    "$filter": {
        "input": [
            { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
            { "Kind": false, "User_id": "58ad50a429b2961777f91c97" },
            { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
        ],
        "as": "el",
        "cond": {
            "$eq": ["$$el.Kind", true]
        }
    }
}

returns the array

[
    { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
    { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
]

The conditional part

"cond": {
    "$eq": ["$$el.Kind", true]
}

can be simplified to just

"cond": "$$el.Kind"

as "$$el.Kind" expression already evaluates to a boolean.

The $size operator trivially calculates the number of elements in an array, thus the expression, for example

{
    "$size":    {
        "$filter": {
            "input": [
                { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
                { "Kind": false, "User_id": "58ad50a429b2961777f91c97" },
                { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
            ],
            "as": "el",
            "cond": {
                "$eq": ["$$el.Kind", true]
            }
        }
    }
}

is expressed as

{
    "$size": [
        { "Kind": true, "User_id": "58afed97bc343887a9ac9206" },
        { "Kind": true, "User_id": "58b3f0f598501abacd8ff391" }
    ]
}

and return a result with 2 as count.

For the contrary DownVote count, the same logic applies:

Forum.aggregate([
    {
        "$addFields": {
            "UpVote": {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": "$$el.Kind"
                    }
                }
            },
            "DownVote": {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": { "$not": ["$$el.Kind"] }
                    }
                }
            }
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})

For the earlier MongoDB version 3.2, you will need to project each and every other element in the document:

Forum.aggregate([
    {
        "$project": {
            "User_id"     : 1,
            "Title"       : 1,
            "Content"     : 1,
            "Tags"        : 1,
            "isPublic"    : 1,
            "UpVote"      : {
                "$size": {
                    "$filter": {
                        "input": "$Vote",
                        "as": "el",
                        "cond": "$$el.Kind"
                    }
                }
            },
            ....
            ....
            ....
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})

For versions that do not support the $filter operator, use the $setDifference operator instead as:

Forum.aggregate([
    {
        "$project": {
            "User_id"     : 1,
            "Title"       : 1,
            "Content"     : 1,
            "Tags"        : 1,
            "isPublic"    : 1,
            "UpVote"      : {
                "$size": {
                    "$setDifference": [
                        { "$map": {
                            "input": "$Vote",
                            "as": "el",
                            "in": { "$cond": ["$$el.Kind", "$$el", false] }
                        }},
                        [false]
                    ]
                }
            },
            ....
            ....
            ....
        }
    }
]).exec((err, results) => {
    if (err) throw err;
    console.log(results);
})


问:
Null reference exception getting from method
I'm using SQLHELPER classes for getting the id from the procedure.
I had written the following code :

```<code>string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
public int CheckUser(string userName,string password)
    {
        SqlParameter[] spc = new SqlParameter[5];
        spc = SqlHelperParameterCache.GetSpParameterSet(constr, "CheckUser");
        spc[0].Value = userName;
        spc[1].Value =password;
        spc[2] = new SqlParameter("@userExist", SqlDbType.Int, 32);
        spc[2].Direction = ParameterDirection.Output;
        int res = (int)SqlHelper.ExecuteScalar(constr, CommandType.StoredProcedure, "CheckUser", spc);

        return res;
    }
</code>```

I'm pssing the username and password but I'm facing "Null reference exception was unhandled by the user" run time exception. When I debug I got the both values which I sent exactly.

```<code>Create proc CheckUser
@userName varchar(50),
@password varchar(50),
@userExist int output
as
  begin
   set @userExist= (select COUNT(*)
                from tbluserInfo
                where  UserName=@userName and [Password]=@password)

    select [uid] from tbluserInfo
            where  UserName=@userName and [Password]=@password

 end
</code>```

Null Ref QuickWatch. Click here for image

答:
You have to return @userExist which you have set from SP please find below updated SP

UPDATED

```<code>Create proc CheckUser
@userName varchar(50),
@password varchar(50),
@userExist int output
as
  begin
   set @userExist= (select isnull([uid],0) from tbluserInfo
            where  UserName=@userName and [Password]=@password)

   return @userExist;

 end
</code>```

Body:
I'm using SQLHELPER classes for getting the id from the procedure.
I had written the following code :

string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
public int CheckUser(string userName,string password)
    {
        SqlParameter[] spc = new SqlParameter[5];
        spc = SqlHelperParameterCache.GetSpParameterSet(constr, "CheckUser");
        spc[0].Value = userName;
        spc[1].Value =password;
        spc[2] = new SqlParameter("@userExist", SqlDbType.Int, 32);
        spc[2].Direction = ParameterDirection.Output;
        int res = (int)SqlHelper.ExecuteScalar(constr, CommandType.StoredProcedure, "CheckUser", spc);

        return res;
    }

I'm pssing the username and password but I'm facing "Null reference exception was unhandled by the user" run time exception. When I debug I got the both values which I sent exactly.

Create proc CheckUser
@userName varchar(50),
@password varchar(50),
@userExist int output
as
  begin
   set @userExist= (select COUNT(*)
                from tbluserInfo
                where  UserName=@userName and [Password]=@password)

    select [uid] from tbluserInfo
            where  UserName=@userName and [Password]=@password

 end

Null Ref QuickWatch. Click here for image

Body:
You have to return @userExist which you have set from SP please find below updated SP

UPDATED

Create proc CheckUser
@userName varchar(50),
@password varchar(50),
@userExist int output
as
  begin
   set @userExist= (select isnull([uid],0) from tbluserInfo
            where  UserName=@userName and [Password]=@password)

   return @userExist;

 end


问:
Fail after copy-paste an existing project into eclipse
I am trying to create an eshop and every time I finish something I copy my last project and paste it into the same workspace (I am working in Eclipse with Maven, hibernate, MySQL).

Today, I have 2 problems and I would like your help. My last project is named eMusicStore35. I cannot run this project because I have not finish all the methods I design.

I finish them in the next project named eMusicStore37 (simple copy eMusicStore35 and paste it with name eMusicStore37).

As you can see from the images:

eMusicStore35 has an exclamation mark (!). This means that I have somewhere in my code error(s)?

eMusicStore37 has errors at ApplicationContext.xml and SprignMVC-servlet.xml. When I am going to these files the error is the same:

```<code>error occurred processing xml 'null'. see error log for more details
</code>```

I tried to search a solution for this problem but I did not succeed to solve it.

Let me know if someone wants from me to upload more files to find the errors.

EDIT

Second error seems to be solved. I simple do:

1. Right click on project

2. Maven --> update project

I have tried this more times and now it is ok so I cannot understand the previous error.

For the first error I uploaded the next image

But now, I cannot see any errors in this project.

My xml files are:

ApplicationContext

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

    <!-- Enable autowire -->
    <context:annotation-config />
    <context:component-scan base-package="com" />

    <mvc:annotation-driven />

    <mvc:resources mapping="/resources/**" location="/resources/" />

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/myeshop" />
        <property name="username" value="root" />
        <property name="password" value="M@trix2014" />
    </bean>

    <!-- Session Factory Declaration -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.entities" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.enable_lazy_load_no_trans">true</prop>
                <!-- <prop key="hibernate.default_schema">myeshop</prop> -->
                <prop key="format_sql">true</prop>
                <prop key="use_sql_comments">true</prop>

            </props>
        </property>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="1024000" />
    </bean>

    <security:http auto-config="true">
        <security:intercept-url pattern="/admin/**"
            access="ROLE_USER" />
        <security:form-login login-page="/login"
            default-target-url="/admin/" authentication-failure-url="/login?error"
            username-parameter="username" password-parameter="password" />
        <security:logout logout-success-url="/login?logout" />
    </security:http>

    <security:authentication-manager>
        <security:authentication-provider>
            <security:jdbc-user-service
                data-source-ref="dataSource"
                authorities-by-username-query="SELECT username, authority From authorities WHERE username = ?"
                users-by-username-query="SELECT username, password, enabled FROM users WHERE username = ?" />
        </security:authentication-provider>
    </security:authentication-manager>
</beans>
</code>```

SpringMVC-servlet

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">

    <!-- My adds-on from previous tutorial -->
    <context:component-scan base-package="com" />
    <mvc:annotation-driven />
    <!-- My adds-on from previous tutorial -->

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/" />

    <tx:annotation-driven />

</beans>
</code>```

pom.xml

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.spring</groupId>
    <artifactId>SpringMVC</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>SpringMVC Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <java-version>1.7</java-version>
        <org.springframework-version>4.2.6.RELEASE</org.springframework-version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- -->

        <!-- http://mvnrepository.com/artifact/org.springframework/spring-context-support -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.36</version>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.10</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>

        <!-- Upload photos -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <!-- This is pre-defined from me!! So comment it!!!!!! -->
        <!-- <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>  maybe error!!!
        </dependency> -->

        <!-- Validation -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>

        <!-- Sping Security Authentication-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>

        <!-- These are for shopping cart! -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.5.1</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>SpringMVC</finalName>
    </build>
</project>
</code>```

答:
From the snipt you shared it shows that problem is not in java code , it is in your xml that's why project shows exclamation mark. You can see in applicationContext.xml and SpringMVC-Servlet.xml having red x mark.

Also you just clone the project by selecting on the project directory and paste it with new name , than you can work in parallel no need to do copy paste every time. Work on which project you want to work.

Body:
I am trying to create an eshop and every time I finish something I copy my last project and paste it into the same workspace (I am working in Eclipse with Maven, hibernate, MySQL).

Today, I have 2 problems and I would like your help. My last project is named eMusicStore35. I cannot run this project because I have not finish all the methods I design.

I finish them in the next project named eMusicStore37 (simple copy eMusicStore35 and paste it with name eMusicStore37).

As you can see from the images:

eMusicStore35 has an exclamation mark (!). This means that I have somewhere in my code error(s)?

eMusicStore37 has errors at ApplicationContext.xml and SprignMVC-servlet.xml. When I am going to these files the error is the same:

error occurred processing xml 'null'. see error log for more details

I tried to search a solution for this problem but I did not succeed to solve it.

Let me know if someone wants from me to upload more files to find the errors.

EDIT

Second error seems to be solved. I simple do:

1. Right click on project

2. Maven --> update project

I have tried this more times and now it is ok so I cannot understand the previous error.

For the first error I uploaded the next image

But now, I cannot see any errors in this project.

My xml files are:

ApplicationContext

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

    <context:annotation-config />
    <context:component-scan base-package="com" />

    <mvc:annotation-driven />

    <mvc:resources mapping="/resources/**" location="/resources/" />

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/myeshop" />
        <property name="username" value="root" />
        <property name="password" value="M@trix2014" />
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.entities" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.enable_lazy_load_no_trans">true</prop>

                <prop key="format_sql">true</prop>
                <prop key="use_sql_comments">true</prop>

            </props>
        </property>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="1024000" />
    </bean>

    <security:http auto-config="true">
        <security:intercept-url pattern="/admin/**"
            access="ROLE_USER" />
        <security:form-login login-page="/login"
            default-target-url="/admin/" authentication-failure-url="/login?error"
            username-parameter="username" password-parameter="password" />
        <security:logout logout-success-url="/login?logout" />
    </security:http>

    <security:authentication-manager>
        <security:authentication-provider>
            <security:jdbc-user-service
                data-source-ref="dataSource"
                authorities-by-username-query="SELECT username, authority From authorities WHERE username = ?"
                users-by-username-query="SELECT username, password, enabled FROM users WHERE username = ?" />
        </security:authentication-provider>
    </security:authentication-manager>
</beans>

SpringMVC-servlet

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">

    <context:component-scan base-package="com" />
    <mvc:annotation-driven />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/" />

    <tx:annotation-driven />

</beans>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.spring</groupId>
    <artifactId>SpringMVC</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>SpringMVC Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <java-version>1.7</java-version>
        <org.springframework-version>4.2.6.RELEASE</org.springframework-version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.36</version>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.10</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.4.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.5.1</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>SpringMVC</finalName>
    </build>
</project>


问:
How to call different methods when min and max values are changed in range seek bar
I have a range seek bar in my app. I need to call a method by passing the min value of the bar only if the value is changed and also to call another method by passing the max value if the max value is changed.
Here is my code so far.

```<code>rangeSeekbar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
                //call this if min value is changed
                mywebView.loadUrl("javascript:setStart(" + minValue.intValue() + ")");

                //call this if max value is changed
                mywebView.loadUrl("javascript:setEnd(" + maxValue.intValue() + ")");
            }

            Toast.makeText(getApplicationContext(), minValue + "-" + maxValue, Toast.LENGTH_LONG).show();
        }
    });
</code>```

The problem is when only one value changes, both methods are called. How can I differentiate the method calls?
Any ideas are welcome.

答:
You can declare a field variable to save the value you have changed:

```<code>int min ,max;
rangeSeekbar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
                if(minValue.intValue!=min){
                    //call this if min value is changed
                    mywebView.loadUrl("javascript:setStart(" + minValue.intValue() + ")");
                    min = minValue.intValue;
                }

                if(maxValue.intValue!=max){
                    //call this if max value is changed
                    mywebView.loadUrl("javascript:setStart(" + maxValue.intValue() + ")");
                    max = maxValue.intValue;
                }

        }

});
</code>```

you can assign the default value for min and max if you can confirm.

Body:
I have a range seek bar in my app. I need to call a method by passing the min value of the bar only if the value is changed and also to call another method by passing the max value if the max value is changed.
Here is my code so far.

rangeSeekbar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
                //call this if min value is changed
                mywebView.loadUrl("javascript:setStart(" + minValue.intValue() + ")");

                //call this if max value is changed
                mywebView.loadUrl("javascript:setEnd(" + maxValue.intValue() + ")");
            }

            Toast.makeText(getApplicationContext(), minValue + "-" + maxValue, Toast.LENGTH_LONG).show();
        }
    });

The problem is when only one value changes, both methods are called. How can I differentiate the method calls?
Any ideas are welcome.

Body:
You can declare a field variable to save the value you have changed:

int min ,max;
rangeSeekbar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
                if(minValue.intValue!=min){
                    //call this if min value is changed
                    mywebView.loadUrl("javascript:setStart(" + minValue.intValue() + ")");
                    min = minValue.intValue;
                }

                if(maxValue.intValue!=max){
                    //call this if max value is changed
                    mywebView.loadUrl("javascript:setStart(" + maxValue.intValue() + ")");
                    max = maxValue.intValue;
                }

        }

});

you can assign the default value for min and max if you can confirm.


问:
Animating a view that has leading and trailing constraints
I know how to do basic position animations in iOS for views that do not have any constraints on them, and how to animate the constant in a constraint, but I don't know how to combine the two.  Basically I created a view in IB that takes up half the screen and has constraints on the individual elements as shown in this picture.

There are leading and trailing edges on each of those 3 UIStackViews where each has a label and a UITextField or UITextView.  What I'd like to do is position the view off screen to the right, and then an event happens, slide it to the left so it all fits on screen with the leading and trailing constraints.  Then when another event happens, slide it to the left again off screen.  When I set the leading and trailing constraints to isActive = false, my view is completely gone.  If I try to change the constants for the leading and trailing constraints' constant value by the same amount, the elements in the container view seem to be cut off vs shifting the view over that amount.

Or are you supposed to not set up the container view with any constraints, animate the view, and then add the constraints you need?

答: Have you tried constraint's priority.that may does some work</p>

ContentLicense: CC BY-SA 4.0


问:
Enterprise Development Profile VS Enterprise Distribution Profile
We are using MDM solution to distribute the apps because it is secure and requires no user interaction.

Now we have been deploying App via MDM using Enterprise Development Profile instead of Enterprise Distribution Profile as we are in development. Everything is working fine. My question is: what difference will it make in both the cases if in one case, I use Enterprise Development Profile and in other case, I use Enterprise Distribution Profile ?

答:
When you build an app with a development provisioning profile, you can debug it on the device. The development provisioning profile is the only provisioning profile that enables debugging on the device. With this type of provisioning profile, you can run your apps only on the devices included in the provisioning profile and you cannot publish apps in the App Store/MDM Store.

If you want to develop and distribute apps privately within your company or to a selected number of end users, you can use a provisioning profile for in-house distribution.

When you build and code sign an app with a pair of matching cryptographic identity and provisioning profile for in-house distribution, you can distribute the app outside of the App Store to the devices registered in your iOS Developer Enterprise Program. You can use an in-house cryptographic identity and provisioning profile to build and code sign private company apps.


答:
Ok your javascript should look something like this:

```<code>document.querySelector('#ddl_Select2ONE').style.background = "Yellow";
</code>```

And in your else clause:

```<code>document.querySelector('#ddl_Select2TWO').style.background = "Yellow";
</code>```

Title: Changing background colour of specific select2 through javascript

Body:
Ok your javascript should look something like this:

document.querySelector('#ddl_Select2ONE').style.background = "Yellow";

And in your else clause:

document.querySelector('#ddl_Select2TWO').style.background = "Yellow";


问:
Change color of checkbox field when checked
I have a check box field with box label colored in green. I need to change the color of the boxlabel (say: yellow) when a user checks the checkbox. i tried validating the checkbox, but it doesnt work. Any suggestions?</p>

```<code>xtype :  'checkbox',
id: 'checkbox1',
name : 'checkbox',
style: 'background-color : #BCF5A9',
boxLabel: 'Mycheckbox'
//I tried the below handler function. but it doesnt work
handler: function (checkbox, checked) {
            if (checked) {
                style : 'background-color: #ddd';
            }
}
</code>```

答:
If you just need to change the color of the boxLabel, try this way.

Ext.create('Ext.form.Panel', {
  bodyPadding: 10,
  title: 'Checkbox Test',
  items: [{
    xtype: 'checkboxfield',
    id: 'checkbox1',
    name: 'checkbox',
    style: {
      color: 'green'
    },
    boxLabel: 'MyCheckbox',
    handler: function(checkbox, checked) {
      if (checked) {
        checkbox.el.setStyle("color","red");
        //checkbox.setBoxLabel('MyCheckbox');
      } else {
         checkbox.el.setStyle("color","green");
        //checkbox.setBoxLabel('MyCheckbox');
      }
    }
  }],
  renderTo: Ext.getBody()
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script type="text/javascript" src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.sencha.io/ext-4.2.0-gpl/resources/css/ext-all.css"></code>```

Body:
I have a check box field with box label colored in green. I need to change the color of the boxlabel (say: yellow) when a user checks the checkbox. i tried validating the checkbox, but it doesnt work. Any suggestions?

xtype :  'checkbox',
id: 'checkbox1',
name : 'checkbox',
style: 'background-color : #BCF5A9',
boxLabel: 'Mycheckbox'
//I tried the below handler function. but it doesnt work
handler: function (checkbox, checked) {
            if (checked) {
                style : 'background-color: #ddd';
            }
}

Body:
If you just need to change the color of the boxLabel, try this way.

Ext.create('Ext.form.Panel', {
  bodyPadding: 10,
  title: 'Checkbox Test',
  items: [{
    xtype: 'checkboxfield',
    id: 'checkbox1',
    name: 'checkbox',
    style: {
      color: 'green'
    },
    boxLabel: 'MyCheckbox',
    handler: function(checkbox, checked) {
      if (checked) {
        checkbox.el.setStyle("color","red");
        //checkbox.setBoxLabel('<span style="color:red">MyCheckbox</span>');
      } else {
         checkbox.el.setStyle("color","green");
        //checkbox.setBoxLabel('<span style="color:green">MyCheckbox</span>');
      }
    }
  }],
  renderTo: Ext.getBody()
});

<script type="text/javascript" src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.sencha.io/ext-4.2.0-gpl/resources/css/ext-all.css">