问:
How to use infinite scroll if data is coming from server?
I would like to do infinite scroll. I am getting data from server and want to show 25 elements at time. When user scrolls down should show next 25 records.And main thing is it should scroll inner scroll bar.

```<code>httpHelper.get(urlName, false, function (err, response) {
    if (err) return err;
    getRecords(response.data.data, $scope.category);
});

var getRecords = function (data, category) {
    $scope.stocks.result = [];
    data.forEach(function (elem) {
        if (elem.duration === category) {
            $scope.stocks.result.push(elem);
        }
    });
};
</code>```

Html :

```<code><div class="row"
   ng-repeat="record in stocks.result | orderBy:stocks.symbol track by $index">

    <div class="col-md-2">
        {{record.Date|date:"dd-MMM"}}
    </div>
    <div class="col-md-2">
        {{record.symbol}}
    </div>
</div>
</code>```

答:
Add infinite scroll directive to your html

```<code><div ng-repeat="record in stocks.result |orderBy:stocks.symbol track by $index" class="row" infinite-scroll="loadMore()">
</code>```

And your loadMore function can be like this.

```<code>var getRecords = function (data, category) {
        $scope.stocks.result = [];
        data.forEach(function (elem) {
            if (elem.duration === category) {
                $scope.stocks.result.push(elem);
            }
        });
    };

function loadMore(){
    httpHelper.get(urlName, false, function (err, response) {
       if (err) return err;

       getRecords(response.data.data, $scope.category);
    });
}
</code>```

Body:
I would like to do infinite scroll. I am getting data from server and want to show 25 elements at time. When user scrolls down should show next 25 records.And main thing is it should scroll inner scroll bar.

httpHelper.get(urlName, false, function (err, response) {
    if (err) return err;
    getRecords(response.data.data, $scope.category);
});

var getRecords = function (data, category) {
    $scope.stocks.result = [];
    data.forEach(function (elem) {
        if (elem.duration === category) {
            $scope.stocks.result.push(elem);
        }
    });
};

Html :

        {{record.Date|date:"dd-MMM"}}

        {{record.symbol}}

Body:
Add infinite scroll directive to your html

<div ng-repeat="record in stocks.result |orderBy:stocks.symbol track by $index" class="row" infinite-scroll="loadMore()">

And your loadMore function can be like this.

var getRecords = function (data, category) {
        $scope.stocks.result = [];
        data.forEach(function (elem) {
            if (elem.duration === category) {
                $scope.stocks.result.push(elem);
            }
        });
    };

function loadMore(){
    httpHelper.get(urlName, false, function (err, response) {
       if (err) return err;

       getRecords(response.data.data, $scope.category);
    });
}


来源: stackexchange

问:
How do I retrieve ebay products with UPC code?
I have a UPC for a digital camera (Canon EOS 350D) and I would like to find products on ebay that match this UPC. I have read the API documentation and tried the following:

http://open.api.ebay.com/shopping?callname=FindProducts&responseencoding=XML&appid=MYAPPID&siteid=0&ProductID.Value=8714574585628&ProductID.Type=UPC&version=773

But, this doesn't give me the restuls even though there is a result when I search that UPC on ebay.co.uk

How can I get the listings that match this UPC to return?

答:
The easiest way to do it would be using the Finding API -> FindItemsAdvanced Call.
Here is an example of a call for what you need.

```<code><?xml version="1.0" encoding="UTF-8"?>
<findItemsAdvancedRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
    <descriptionSearch>true</descriptionSearch>
    <paginationInput>
        <entriesPerPage>10</entriesPerPage>
    </paginationInput>
    <keywords>753182925158</keywords>
</findItemsAdvancedRequest>
</code>```

Of course, this is not the only way. But I find it to be the easiest.

ContentLicense: CC BY-SA 4.0

Body:
The easiest way to do it would be using the Finding API -> FindItemsAdvanced Call.
Here is an example of a call for what you need.

<?xml version="1.0" encoding="UTF-8"?>
<findItemsAdvancedRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
    <descriptionSearch>true</descriptionSearch>
    <paginationInput>
        <entriesPerPage>10</entriesPerPage>
    </paginationInput>
    <keywords>753182925158</keywords>
</findItemsAdvancedRequest>

Of course, this is not the only way. But I find it to be the easiest.

ContentLicense: CC BY-SA 3.0


问:
Create condition when session storage should work
I am using the code below. This causes a message to appear when the window is in portrait mode. When the "X" is clicked, the message disappears and does not return within the same session.

This works well, however, when the window is refreshed/reloaded before even clicking the "X", the message should still appear when the window is sized to portrait mode. Only after the "X" is clicked should the message no longer appear within the same session.

Can you help please?

See Example Here!

```<code>$(document).ready(function() {
    var data = sessionStorage.getItem('isfirst');
    if (data == undefined) {
        $("#warning-message").addClass("shown-modal");
        sessionStorage.setItem('isfirst', 'true');
    } else {
        $("#warning-message").hide();
    }
});
//close the pop
$("#landscape-button").on('click', function() {
    $("#warning-message").hide();
});
</code>```

答:
If you only want the session variable to be set after clicking on 'X', you should simply move sessionStorage.setItem('isfirst', 'true'); inside the on click function of #landscape-button.

```<code>$(document).ready(function() {
    var data = sessionStorage.getItem('isfirst');
    if (data == undefined) {
        $("#warning-message").addClass("shown-modal");
    } else {
        $("#warning-message").hide();
    }
});
//close the pop
$("#landscape-button").on('click', function() {
    sessionStorage.setItem('isfirst', 'true');
    $("#warning-message").hide();
});
</code>```

Body:
I am using the code below. This causes a message to appear when the window is in portrait mode. When the "X" is clicked, the message disappears and does not return within the same session.

This works well, however, when the window is refreshed/reloaded before even clicking the "X", the message should still appear when the window is sized to portrait mode. Only after the "X" is clicked should the message no longer appear within the same session.

Can you help please?

See Example Here!

$(document).ready(function() {
    var data = sessionStorage.getItem('isfirst');
    if (data == undefined) {
        $("#warning-message").addClass("shown-modal");
        sessionStorage.setItem('isfirst', 'true');
    } else {
        $("#warning-message").hide();
    }
});
//close the pop
$("#landscape-button").on('click', function() {
    $("#warning-message").hide();
});

Body:
If you only want the session variable to be set after clicking on 'X', you should simply move sessionStorage.setItem('isfirst', 'true'); inside the on click function of #landscape-button.

$(document).ready(function() {
    var data = sessionStorage.getItem('isfirst');
    if (data == undefined) {
        $("#warning-message").addClass("shown-modal");
    } else {
        $("#warning-message").hide();
    }
});
//close the pop
$("#landscape-button").on('click', function() {
    sessionStorage.setItem('isfirst', 'true');
    $("#warning-message").hide();
});


问:
SOAP request to PHP
The following code is working in SoapUI:

https://webserver.domain.com/Service?server=webserver-prod&webService=WS_Create_Incident

```<code><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:WS_Create_Incident">
<soapenv:Header>
    <urn:AuthenticationInfo>
        <urn:userName>username@domain.com</urn:userName>
        <urn:password>Scrambled</urn:password>
    </urn:AuthenticationInfo>
</soapenv:Header>
<soapenv:Body>
    <urn:HelpDesk_Submit_Service>
        <urn:Assigned_Group>GROUP</urn:Assigned_Group>
        <urn:Assigned_Support_Company>COMPANY</urn:Assigned_Support_Company>
        <urn:Assigned_Support_Organization>ORGANIZATION</urn:Assigned_Support_Organization>
    </urn:HelpDesk_Submit_Service>
</soapenv:Body>
</soapenv:Envelope>
</code>```

I have installed soap extension on my test php server. How can I make this request using php?

答:
Try looking up SOAP examples in PHP Manual: http://php.net/manual/en/book.soap.php</p>

```<code>$client = new SoapClient('http://www....com/.../?WSDL');
$client->__getFunctions();
$client->__getTypes();
</code>```

Title: SOAP request to PHP

Body:
The following code is working in SoapUI:

https://webserver.domain.com/Service?server=webserver-prod&webService=WS_Create_Incident

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:WS_Create_Incident">
<soapenv:Header>
    <urn:AuthenticationInfo>
        <urn:userName>username@domain.com</urn:userName>
        <urn:password>Scrambled</urn:password>
    </urn:AuthenticationInfo>
</soapenv:Header>
<soapenv:Body>
    <urn:HelpDesk_Submit_Service>
        <urn:Assigned_Group>GROUP</urn:Assigned_Group>
        <urn:Assigned_Support_Company>COMPANY</urn:Assigned_Support_Company>
        <urn:Assigned_Support_Organization>ORGANIZATION</urn:Assigned_Support_Organization>
    </urn:HelpDesk_Submit_Service>
</soapenv:Body>
</soapenv:Envelope>

I have installed soap extension on my test php server. How can I make this request using php?

Body:
Try looking up SOAP examples in PHP Manual: http://php.net/manual/en/book.soap.php

$client = new SoapClient('http://www....com/.../?WSDL');
$client->__getFunctions();
$client->__getTypes();


问:
What is the difference between DoS and Brute Force attacks?
I was reading about DoS attacks on Apache servers but the "Brute Force" word pops up sometimes I know DoS attacks but "Brute Force" seems to be similar, is there a difference or it is just another word of DoS?</p>

答:
A "brute force" attack refers to attempting every possible combination, usually in a cryptographic context. (For example, if I'm guessing your password, I can start with "a" and then "b" and then "c" and so on; or if I'm trying to solve a Sudoku puzzle, I can try every possible combination until I find one that works.)

Obviously this is unrelated to a Denial of Service attack (which usually refers to sending so many bogus requests that a server is overwhelmed). If you're seeing both phrases in the same context, the author is probably confused.

OwnerDisplayName: Sulaiman

LastEditorDisplayName: Jeremy Ruten

OwnerDisplayName: Ross

ContentLicense: CC BY-SA 2.5


问:
Workload Scheduler: error while opening the TCR administrator panel after a successful installation of the Dynamic Workload Console
I have successfully installed the Dynamic Workload Console and its prereqs, but, when I try to open the TCR admin panel I get this error message:

Error!
Refresh Edit Minimize Maximize
PF-VAL-6171 Error retrieving metadata for the target fragment.
Details | Retry | Hide this message.
Details
DashboardException
PF-VAL-6171 Error retrieving metadata for the target fragment.

How can I solve this?

答:
If I understood well, try to rename or remove the following jar file:

```<code>BirtAdapterB.jar
</code>```

path:

```<code>/reporting/lib/birt-runtime-2_2_2/ReportEngine/lib
</code>```

Body:
If I understood well, try to rename or remove the following jar file:

BirtAdapterB.jar

path:

/reporting/lib/birt-runtime-2_2_2/ReportEngine/lib


问:
How can i delete particular item stored inside local storage?
Values stored inside local storage

```<code>{"10":true,"11":true,"16":false}
</code>```

I want to delete a particular data stored inside local storage e.g. 10

```<code>var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {};

$.each(checkboxValues, function(key, value) {
                if(value===true) {
                    delete checkboxValues[key];
                    }
                }
            });
</code>```

I stored all checkboxes id and value during onload, and want to remove those checkboxes id with true value when user submit the form.

With the method used above, I unable to delete the data. Is anything wrong with my code?

答:
before saving json object into the localstorage please convert the json object into string and then store it in localstorage like this

```<code>JSON.stringify({"10":true,"11":true,"16":false});
</code>```

and then where you are parsing things it works correctly, just on saving please convert json object into string
here is the updated code

```<code>var jsonData = JSON.stringify({"10":true,"11":true,"16":false});
localStorage.setItem('checkboxValues', jsonData);

var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {};

$.each(checkboxValues, function(key, value) {
    if(value===true) {
        delete checkboxValues[key];
    }
});
</code>```

here it is showing it working fine
https://iamlalit.tinytake.com/sf/MTc1ODUwMl81Nzc4NzMw

Body:
Values stored inside local storage

{"10":true,"11":true,"16":false}

I want to delete a particular data stored inside local storage e.g. 10

var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {};

$.each(checkboxValues, function(key, value) {
                if(value===true) {
                    delete checkboxValues[key];
                    }
                }
            });

I stored all checkboxes id and value during onload, and want to remove those checkboxes id with true value when user submit the form.

With the method used above, I unable to delete the data. Is anything wrong with my code?

Body:
before saving json object into the localstorage please convert the json object into string and then store it in localstorage like this

JSON.stringify({"10":true,"11":true,"16":false});

and then where you are parsing things it works correctly, just on saving please convert json object into string
here is the updated code

var jsonData = JSON.stringify({"10":true,"11":true,"16":false});
localStorage.setItem('checkboxValues', jsonData);

var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {};

$.each(checkboxValues, function(key, value) {
    if(value===true) {
        delete checkboxValues[key];
    }
});

here it is showing it working fine
https://iamlalit.tinytake.com/sf/MTc1ODUwMl81Nzc4NzMw


问:
Angular Material: how to set background-color (without CSS)
I'm developing a pure Material Design application using Angular Material framework.

However, I don't understand how to set containers' background colors (e.g. a login form with a blue background).
I could do it using CSS of course but I wonder if there's a built-in directive / theme option to do this.

答:
You can set any color from the palette with md-colors directive.

https://material.angularjs.org/1.1.4/api/directive/mdColors

The format will be [?theme]-[palette]-[?hue]-[?opacity] where ? means optional parameter.

But from my experience you have to specify the theme even if it's default:

```<code><md-button md-colors="{color: 'default-red-A100', 'background': 'default-primary-600'}">Button</md-button>
</code>```

Body:
You can set any color from the palette with md-colors directive.

https://material.angularjs.org/1.1.4/api/directive/mdColors

The format will be [?theme]-[palette]-[?hue]-[?opacity] where ? means optional parameter.

But from my experience you have to specify the theme even if it's default:

<md-button md-colors="{color: 'default-red-A100', 'background': 'default-primary-600'}">Button</md-button>


问:
SOAP WSDL - How to create working call for specific method in PHP
I am working on a website that will use some API's and encountered a problem.
Could somebody please help me?
There is this method called "createOrder", that is killing me.
It is used to create order at a supplier, as follows:

```<code>$id=$_POST['varname'];
echo $id;
$ilosc=$_POST['ilosc'];
echo "</br> Zamawiana ilosć to :";
echo $ilosc;
$orderInfo = $client->createOrder(
array(

    'description'=> 'OPIS',
    'clientNr' => '025537',
    'type' => 'FV_ZBIORCZA',
    'transport' =>'AD',
    'positions' => array(

    'id'=>$id,
    'count'=>$ilosc

    )

  ) ) ;

var_dump($orderInfo);
</code>```

The problem is that it doesn't pass the "positions". It only creates a blank order (with these four first parameters). The problem is in my opinion that these "positions" block is designed to handle more than one item, so it has to be written in some different way.

Here is SOAP UI code for some help. It works with only "id" and "count" filled in (and api_keys as well of course) :

```<code>    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://katalog.adpolska.pl/ws/api/1.0/">
   <soapenv:Header>
      <personal_key>?</personal_key>
      <kh_kod>?</kh_kod>
      <api_key>?</api_key>
   </soapenv:Header>
   <soapenv:Body>
      <ns:createOrder>
         <order>
            <!--You may enter the following 5 items in any order-->
            <description>OPIS</description>
            <clientNr>025537</clientNr>
            <type>FV_ZBIORCZA</type>
            <transport>AD</transport>
            <positions>
               <!--Zero or more repetitions:-->
               <item>
                  <!--You may enter the following 4 items in any order-->
                  <productId>
                     <!--You may enter the following 2 items in any order-->
                     <id>824210</id>
                     <index></index>
                  </productId>
                  <count>2</count>
                  <error></error>
                  <errorMessage></errorMessage>
               </item>
            </positions>
         </order>
      </ns:createOrder>
   </soapenv:Body>
</soapenv:Envelope>
</code>```

Below the example from documentation, but this documentation has so many mistakes that I no longer look at it, and it also isnt working, but gives the idea:

```<code>    $orderInfo = $client->__soapCall('createOrder', [
        'order' => [
                'description' =>'myDesc',
                'clientNr' =>'my_cart_nr',
                'type' =>'FV',
                'transport' =>'AD',
                'positions' => [
                        [
                                'id' =>'907972',
                                'count' => 1
                        ],
                        [
                                'id' =>'908015',
                                'count' => 1
                        ]
                ]
        ]
]);
</code>```

I've also used something like wsdltophp, and extracted structure of this function:

```<code>   <?php

Array
(
    [0] => ADStructOrder Object
        (
            [description] => OPIS
            [clientNr] => 025537
            [type] => FV_ZBIORCZA
            [transport] => AD
            [positions] => ADStructArrayOfOrderPosition Object
                (
                    [item] => Array
                        (
                            [0] => ADStructOrderPosition Object
                                (
                                    [productId] => ADStructProductId Object
                                        (
                                            [id] => 823514
                                            [index] =>
                                        )
                                    [count] => 1
                                    [error] =>
                                    [errorMessage] =>
                                )
                        )

                )
        )
?>
</code>```

Could you please help me to achive working solution?
Thanks in advance.

答:
As I see, your data structure should be like as

```<code><?php
$productId = [
    'id' => 824210,
    'index' => ''
];
$item = [
    'productId' => $productId,
    'count' => 2,
    'error' => '',
    'errorMessage' => ''
];
$positions = [
    'item' => [$item],
];
$order = [
    'description'=> 'OPIS',
    'clientNr' => '025537',
    'type' => 'FV_ZBIORCZA',
    'transport' =>'AD',
    'positions' => $positions,
];

$orderInfo = $client->createOrder($order);
</code>```

hope it helps

Body:
I am working on a website that will use some API's and encountered a problem.
Could somebody please help me?
There is this method called "createOrder", that is killing me.
It is used to create order at a supplier, as follows:

$id=$_POST['varname'];
echo $id;
$ilosc=$_POST['ilosc'];
echo "
 Zamawiana ilosć to :";
echo $ilosc;
$orderInfo = $client->createOrder(
array(

    'description'=> 'OPIS',
    'clientNr' => '025537',
    'type' => 'FV_ZBIORCZA',
    'transport' =>'AD',
    'positions' => array(

    'id'=>$id,
    'count'=>$ilosc

    )

  ) ) ;

var_dump($orderInfo);

The problem is that it doesn't pass the "positions". It only creates a blank order (with these four first parameters). The problem is in my opinion that these "positions" block is designed to handle more than one item, so it has to be written in some different way.

Here is SOAP UI code for some help. It works with only "id" and "count" filled in (and api_keys as well of course) :

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://katalog.adpolska.pl/ws/api/1.0/">
   <soapenv:Header>
      <personal_key>?</personal_key>
      <kh_kod>?</kh_kod>
      <api_key>?</api_key>
   </soapenv:Header>
   <soapenv:Body>
      <ns:createOrder>
         <order>

            <description>OPIS</description>
            <clientNr>025537</clientNr>
            <type>FV_ZBIORCZA</type>
            <transport>AD</transport>
            <positions>

               <item>

                  <productId>

                     <id>824210</id>
                     <index></index>
                  </productId>
                  <count>2</count>
                  <error></error>
                  <errorMessage></errorMessage>
               </item>
            </positions>
         </order>
      </ns:createOrder>
   </soapenv:Body>
</soapenv:Envelope>

Below the example from documentation, but this documentation has so many mistakes that I no longer look at it, and it also isnt working, but gives the idea:

    $orderInfo = $client->__soapCall('createOrder', [
        'order' => [
                'description' =>'myDesc',
                'clientNr' =>'my_cart_nr',
                'type' =>'FV',
                'transport' =>'AD',
                'positions' => [
                        [
                                'id' =>'907972',
                                'count' => 1
                        ],
                        [
                                'id' =>'908015',
                                'count' => 1
                        ]
                ]
        ]
]);

I've also used something like wsdltophp, and extracted structure of this function:

   <?php

Array
(
    [0] => ADStructOrder Object
        (
            [description] => OPIS
            [clientNr] => 025537
            [type] => FV_ZBIORCZA
            [transport] => AD
            [positions] => ADStructArrayOfOrderPosition Object
                (
                    [item] => Array
                        (
                            [0] => ADStructOrderPosition Object
                                (
                                    [productId] => ADStructProductId Object
                                        (
                                            [id] => 823514
                                            [index] =>
                                        )
                                    [count] => 1
                                    [error] =>
                                    [errorMessage] =>
                                )
                        )

                )
        )
?>

Could you please help me to achive working solution?
Thanks in advance.

Body:
As I see, your data structure should be like as

<?php
$productId = [
    'id' => 824210,
    'index' => ''
];
$item = [
    'productId' => $productId,
    'count' => 2,
    'error' => '',
    'errorMessage' => ''
];
$positions = [
    'item' => [$item],
];
$order = [
    'description'=> 'OPIS',
    'clientNr' => '025537',
    'type' => 'FV_ZBIORCZA',
    'transport' =>'AD',
    'positions' => $positions,
];

$orderInfo = $client->createOrder($order);

hope it helps


问:
React Js TypeError: Cannot read property 'LoginAuth' of undefined
I want to call a function from after doing a map of an array to check the values for any that match my variables but i want to do it in a separate function so i try and call the function and i get the error TypeError: Cannot read property 'LoginAuth' of undefined

my code is this

```<code>LoginAuth = (Res) => {
    if (this.username === this.state.Username) {
        console.log("get to login auth and true");
    } else {
        console.log("Gets to login auth and false");
    }
}
CheckLoginAuth() {
    console.log("gets to check login auth");
    console.log(this.state.AuthRes);
    console.log("Username=" + this.state.Username);
    console.log("Password=" + this.state.Password);
    this.props.AuthRes.map(function (Res) {
        console.log("ID=" + Res.id);
        console.log("Username=" + Res.username);
        console.log("Password=" + Res.password);
        this.LoginAuth(Res);//react is actually throwing the error here.
    })
}
</code>```

how come this is erroring it gets called when i click a button on a form that bit works its just this new function.

答:
this in the map function does not go to the this you want and is in fact undefined in itself.

also, as the people said in the comment, why not use a fat arrow?
No need to use the function call but if you want to keep it like that, here it goes.

Try this:

notice:

```<code>var self = this;
</code>```

and calling self.login...

```<code>LoginAuth = (Res) => {
    if (this.username === this.state.Username) {
        console.log("get to login auth and true");
    } else {
        console.log("Gets to login auth and false");
    }
}
CheckLoginAuth() {
    console.log("gets to check login auth");
    console.log(this.state.AuthRes);
    console.log("Username=" + this.state.Username);
    console.log("Password=" + this.state.Password);
var self = this;
    this.props.AuthRes.map(function (Res) {
        console.log("ID=" + Res.id);
        console.log("Username=" + Res.username);
        console.log("Password=" + Res.password);
        self.LoginAuth(Res);//react is actually throwing the error here.
    })
}
</code>```

Body:
I want to call a function from after doing a map of an array to check the values for any that match my variables but i want to do it in a separate function so i try and call the function and i get the error TypeError: Cannot read property 'LoginAuth' of undefined

my code is this

LoginAuth = (Res) => {
    if (this.username === this.state.Username) {
        console.log("get to login auth and true");
    } else {
        console.log("Gets to login auth and false");
    }
}
CheckLoginAuth() {
    console.log("gets to check login auth");
    console.log(this.state.AuthRes);
    console.log("Username=" + this.state.Username);
    console.log("Password=" + this.state.Password);
    this.props.AuthRes.map(function (Res) {
        console.log("ID=" + Res.id);
        console.log("Username=" + Res.username);
        console.log("Password=" + Res.password);
        this.LoginAuth(Res);//react is actually throwing the error here.
    })
}

how come this is erroring it gets called when i click a button on a form that bit works its just this new function.

Body:
this in the map function does not go to the this you want and is in fact undefined in itself.

also, as the people said in the comment, why not use a fat arrow?
No need to use the function call but if you want to keep it like that, here it goes.

Try this:

notice:

var self = this;

and calling self.login...

LoginAuth = (Res) => {
    if (this.username === this.state.Username) {
        console.log("get to login auth and true");
    } else {
        console.log("Gets to login auth and false");
    }
}
CheckLoginAuth() {
    console.log("gets to check login auth");
    console.log(this.state.AuthRes);
    console.log("Username=" + this.state.Username);
    console.log("Password=" + this.state.Password);
var self = this;
    this.props.AuthRes.map(function (Res) {
        console.log("ID=" + Res.id);
        console.log("Username=" + Res.username);
        console.log("Password=" + Res.password);
        self.LoginAuth(Res);//react is actually throwing the error here.
    })
}


问:
Android Wear App Crash in Moto 360 in other watches app is working fine
I am working on wear application. Application is working fine in other watches but in Moto 360 it is getting crashed as we launch application.
Android wear 1.5.0, OS: 6.0.1,Google Play service 11.0.55.
Here is the logs.</p>

```<code>--------- beginning of crash
07-06 12:48:54.471 5752-5752/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: com.google.android.wearable.app, PID: 5752
                                             java.lang.RuntimeException: Unable to destroy activity {com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
                                                 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3831)
                                                 at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
                                                 at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4053)
                                                 at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:148)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                              Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
                                                 at com.google.android.clockwork.home.cuecard.VoicePlateFragment.onCueCardClosed(VoicePlateFragment.java:1734)
                                                 at com.google.android.clockwork.home.cuecard.VoiceUiController.close(VoiceUiController.java:440)
                                                 at com.google.android.clockwork.home.HomeActivity.removeCueCard(HomeActivity.java:1720)
                                                 at com.google.android.clockwork.home.HomeActivity.destroyCueCard(HomeActivity.java:876)
                                                 at com.google.android.clockwork.home.HomeActivity.onDestroy(HomeActivity.java:908)
                                                 at android.app.Activity.performDestroy(Activity.java:6422)
                                                 at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1142)
                                                 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3818)
                                                 at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
                                                 at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4053)
                                                 at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:148)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-06 12:48:54.480 467-933/? W/ActivityManager:   Force finishing activity com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity
07-06 12:48:54.745 467-508/? V/WindowManager: Layouts looping: On entry to LockedInner, mPendingLayoutChanges = 0x1
07-06 12:48:54.745 467-508/? V/WindowManager: Layouts looping: after finishPostLayoutPolicyLw, mPendingLayoutChanges = 0x0
07-06 12:48:54.746 467-508/? V/WindowManager: Layouts looping: mLayoutNeeded, mPendingLayoutChanges = 0x1
07-06 12:48:54.746 467-508/? V/WindowManager: Layouts looping: On entry to LockedInner, mPendingLayoutChanges = 0x1
07-06 12:48:54.747 467-508/? V/WindowManager: Layouts looping: after finishPostLayoutPolicyLw, mPendingLayoutChanges = 0x0
07-06 12:48:54.753 467-508/? V/WindowManager: Layouts looping: mLayoutNeeded, mPendingLayoutChanges = 0x1
07-06 12:48:54.754 467-508/? E/WindowManager: Performed 6 layouts in a row. Skipping
07-06 12:48:54.760 467-508/? I/ActivityManager: Displayed com.us.lexusenformremote/.Splash: +602ms
07-06 12:48:54.975 5359-5359/? I/CmaSystemUpdateService: ActiveReceiver: Intent { act=android.os.UpdateLock.UPDATE_LOCK_CHANGED flg=0x4000010 cmp=com.google.android.gms/.update.SystemUpdateServiceActiveReceiver (has extras) }
07-06 12:48:54.975 5359-5359/? I/CmaSystemUpdateService: receiver: Intent { act=android.os.UpdateLock.UPDATE_LOCK_CHANGED flg=0x4000010 cmp=com.google.android.gms/.update.SystemUpdateServiceActiveReceiver (has extras) }
07-06 12:48:55.004 213-5984/? D/hardware_info: hw_info_append_hw_type : device_name = voice-rec-dmic-ef-fluence
07-06 12:48:55.008 213-343/? D/audio_hw_primary: adev_close_input_stream: 0xb410f1e0
</code>```

答:
This issue has been opened in this google forum and the device was moto 360 as well. Here's the engineer's response:

There are many reasons why your Android Wear watch might show the
  message “Android Wear has stopped”.

Make sure you are on the latest Android Wear app update.

Make sure you are on the latest Android Wear watch update

Try restarting your watch

If none of this works, then try  unpairing and pairing again.

If none of this is not working, you might try other solutions users in
  this thread used succesfully.

Go to Settings > Apps > Android Wear - Clear Cache and Clear Data. See if this helps.

Update Google app on your Android phone or iPhone

Check 3rd party apps and watch faces recently installed. Try uninstalling from phone and then reboot both watch and phone.

From Settings, Device, Apps, use the Uninstall updates button to back out the latest changes to Google Play Services, Then Clear cache
  and Clear data. There could be a problem with the latest update of
  Google play Services.

If you have problem with some specific manufacturer or you suspect it might be a Hardware issue, please contact them

Check steps on how to fix an app that is not working.

Body:
I am working on wear application. Application is working fine in other watches but in Moto 360 it is getting crashed as we launch application.
Android wear 1.5.0, OS: 6.0.1,Google Play service 11.0.55.
Here is the logs.

--------- beginning of crash
07-06 12:48:54.471 5752-5752/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: com.google.android.wearable.app, PID: 5752
                                             java.lang.RuntimeException: Unable to destroy activity {com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
                                                 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3831)
                                                 at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
                                                 at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4053)
                                                 at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:148)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                              Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
                                                 at com.google.android.clockwork.home.cuecard.VoicePlateFragment.onCueCardClosed(VoicePlateFragment.java:1734)
                                                 at com.google.android.clockwork.home.cuecard.VoiceUiController.close(VoiceUiController.java:440)
                                                 at com.google.android.clockwork.home.HomeActivity.removeCueCard(HomeActivity.java:1720)
                                                 at com.google.android.clockwork.home.HomeActivity.destroyCueCard(HomeActivity.java:876)
                                                 at com.google.android.clockwork.home.HomeActivity.onDestroy(HomeActivity.java:908)
                                                 at android.app.Activity.performDestroy(Activity.java:6422)
                                                 at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1142)
                                                 at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3818)
                                                 at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
                                                 at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4053)
                                                 at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:148)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-06 12:48:54.480 467-933/? W/ActivityManager:   Force finishing activity com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity
07-06 12:48:54.745 467-508/? V/WindowManager: Layouts looping: On entry to LockedInner, mPendingLayoutChanges = 0x1
07-06 12:48:54.745 467-508/? V/WindowManager: Layouts looping: after finishPostLayoutPolicyLw, mPendingLayoutChanges = 0x0
07-06 12:48:54.746 467-508/? V/WindowManager: Layouts looping: mLayoutNeeded, mPendingLayoutChanges = 0x1
07-06 12:48:54.746 467-508/? V/WindowManager: Layouts looping: On entry to LockedInner, mPendingLayoutChanges = 0x1
07-06 12:48:54.747 467-508/? V/WindowManager: Layouts looping: after finishPostLayoutPolicyLw, mPendingLayoutChanges = 0x0
07-06 12:48:54.753 467-508/? V/WindowManager: Layouts looping: mLayoutNeeded, mPendingLayoutChanges = 0x1
07-06 12:48:54.754 467-508/? E/WindowManager: Performed 6 layouts in a row. Skipping
07-06 12:48:54.760 467-508/? I/ActivityManager: Displayed com.us.lexusenformremote/.Splash: +602ms
07-06 12:48:54.975 5359-5359/? I/CmaSystemUpdateService: ActiveReceiver: Intent { act=android.os.UpdateLock.UPDATE_LOCK_CHANGED flg=0x4000010 cmp=com.google.android.gms/.update.SystemUpdateServiceActiveReceiver (has extras) }
07-06 12:48:54.975 5359-5359/? I/CmaSystemUpdateService: receiver: Intent { act=android.os.UpdateLock.UPDATE_LOCK_CHANGED flg=0x4000010 cmp=com.google.android.gms/.update.SystemUpdateServiceActiveReceiver (has extras) }
07-06 12:48:55.004 213-5984/? D/hardware_info: hw_info_append_hw_type : device_name = voice-rec-dmic-ef-fluence
07-06 12:48:55.008 213-343/? D/audio_hw_primary: adev_close_input_stream: 0xb410f1e0


问:
Spoon - read SQL code from txt file and execute on DB
I'm learning to develop ETL using Pentaho Spoon, I'm pretty noob yet.

Instead of storing SQL operations inside its file, I'd like to have them on their own .sql files. It makes easier to track changes on Subversion, and in case of need I can just open the sql file on DB manager and execute it directly.

How could I do that? I suppose I could use some component to read a txt file into a variable, and another component to take that variable and execute it on DB.

How's the simplest way to achieve that?

答:
In the standard SQL Table input, you can define the query to be a parameter ${my_query} and this parameter has to be defined (without ${...} decoration) in the transformation properties: right-click anywhere, select Properties on the popup menu, the Parameter tab.

Each time you run the transformation, you'll presented the list of parameters, among which my_query which you can overwrite.

To automatize, follow the example which was shipped with the installation zip. In the same directory as you spoon.bat/spoon.sh, there is a folder named sample, in which you will find a job to read_all_files or read all_tables. Basically this job list the files in a directory, and for each one puts it in a variable and use it as a parameter to run the transformation. Much more easier to do than to explain.


问:
symfony: how to pass to uploaded bundle its own path
I am using symfony 3.3

I have created a bundle which I install via composer into vendor/ in my application. I have this bundle to require some yml files which I inject to it via dependency injection. So far everything is ok. But I also have  one yml file already inside this bundle and this bundle has to know this (his own) file's path.

Currently I have this in one of my bundle's classes

```<code>protected const LOCAL_FILE = __DIR__.'/../Resources/translations/ru.yml';
</code>```

It works just fine but I do not think it is a proper solution. I try to pass to this class a %kernel.root_dir% but from that I still can't guess the whole path.

How ought I to do it the best way?

UPDATE: having made what zerkms suggested I get the result invoking this method the following way:

```<code>  my.translator:
      ...
      calls:
          - method: configure
            arguments:
               ...
               - '@kernel'
</code>```

and the part with locateResource

```<code> protected const LOCAL_FILE = '@MyBundle/Resources/translations/ru.yml';
  ....
  ....
  $this->kernel->locateResource(self::LOCAL_FILE)
</code>```

答:
You might have used the Symfony\Component\HttpKernel::locateResource() method.

And the kernel object is available through the @kernel id in the container.

Body:
I am using symfony 3.3

I have created a bundle which I install via composer into vendor/ in my application. I have this bundle to require some yml files which I inject to it via dependency injection. So far everything is ok. But I also have  one yml file already inside this bundle and this bundle has to know this (his own) file's path.

Currently I have this in one of my bundle's classes

protected const LOCAL_FILE = __DIR__.'/../Resources/translations/ru.yml';

It works just fine but I do not think it is a proper solution. I try to pass to this class a %kernel.root_dir% but from that I still can't guess the whole path.

How ought I to do it the best way?

UPDATE: having made what zerkms suggested I get the result invoking this method the following way:

  my.translator:
      ...
      calls:
          - method: configure
            arguments:
               ...
               - '@kernel'

and the part with locateResource

 protected const LOCAL_FILE = '@MyBundle/Resources/translations/ru.yml';
  ....
  ....
  $this->kernel->locateResource(self::LOCAL_FILE)


问:
how to read .mat in fortran
can anyone tell me how to use fortran to read .mat?
I need to use fortran to process a 2d matrix from matlab.
I use

```<code>open(unit = 9006, file = 'zmatrix.mat',status = 'unknown', form = 'unformatted')
do i=1,296
    do j=1,278
    read(9006,*) zmatrix(i,j)
    end do
end do
</code>```

but it is said fortran runtime error:format present for unformatted data transfer.
  Appreciated for any suggestions!

答:
This little program reads a .mat file (name is first argument on exec line, i.e ./a.out Jet0500. The file contains a single two-dimensional variable,</p>

```<code>!compile with gfortran Read_mesh.f90

Module Mat_Read

  real, allocatable :: omega(:,:)
contains

  Subroutine Read_mesh
    implicit none
    integer :: unitno=10
    integer :: kx,ncolumn,nrow
    character (len=30) :: filename
    call getarg(1,filename)
    open(unit=unitno,file=filename,form="formatted",&
         &status="old",action="read")
    do kx=1,3                   ! read by 3 lines
       read(unitno,fmt="(A1)")
    end do
    read(unitno,fmt="(8x,i14)")nrow
    read(unitno,fmt="(10x,i14)")ncolumn
    allocate (omega(nrow,ncolumn))
    do kx=1,nrow
       read(unitno,*) omega(kx,:)
    end do
    close(unitno)
  End Subroutine Read_mesh
End Module Mat_Read

Program test_Read_mesh
  use Mat_Read
  call Read_mesh
  print *,omega(1,1)
End Program test_Read_mesh
</code>```

Title: how to read .mat in fortran

Body:
can anyone tell me how to use fortran to read .mat?
I need to use fortran to process a 2d matrix from matlab.
I use

open(unit = 9006, file = 'zmatrix.mat',status = 'unknown', form = 'unformatted')
do i=1,296
    do j=1,278
    read(9006,*) zmatrix(i,j)
    end do
end do

but it is said fortran runtime error:format present for unformatted data transfer.
  Appreciated for any suggestions!

Body:
This little program reads a .mat file (name is first argument on exec line, i.e ./a.out Jet0500. The file contains a single two-dimensional variable,

!compile with gfortran Read_mesh.f90

Module Mat_Read

  real, allocatable :: omega(:,:)
contains

  Subroutine Read_mesh
    implicit none
    integer :: unitno=10
    integer :: kx,ncolumn,nrow
    character (len=30) :: filename
    call getarg(1,filename)
    open(unit=unitno,file=filename,form="formatted",&
         &status="old",action="read")
    do kx=1,3                   ! read by 3 lines
       read(unitno,fmt="(A1)")
    end do
    read(unitno,fmt="(8x,i14)")nrow
    read(unitno,fmt="(10x,i14)")ncolumn
    allocate (omega(nrow,ncolumn))
    do kx=1,nrow
       read(unitno,*) omega(kx,:)
    end do
    close(unitno)
  End Subroutine Read_mesh
End Module Mat_Read

Program test_Read_mesh
  use Mat_Read
  call Read_mesh
  print *,omega(1,1)
End Program test_Read_mesh


问:
How to remove the email validation after submit using angular2/typescript

I have an add popup, after filling all fields and giving submit, the values are getting saved. If I open again and add popup to add new values without page refresh, in the email field without filling anything it is displaying Email is invalid. On pageload it is working fine. Please can anyone help to solve this issue.
I am here by sharing my code please help

HTML code

```<code>   <md-input-container>
   <input mdInput type="text" name="workEmail" [(ngModel)]="userDetails.workEmail" placeholder="WD Email" #email="ngModel" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" required>
   </md-input-container>
   <div style="font-size: 13px;text-align: left; padding: 8px 0px 8px 30px;" [hidden]="email.valid || email.pristine" class="error">
                                Email is invalid!
   </div>
</code>```

Thanks in advance.

答:
You can add untouched and check once.

```<code><md-input-container>
<input mdInput type="text" name="workEmail" [(ngModel)]="userDetails.workEmail" placeholder="WD Email" #email="ngModel" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" required>
</md-input-container>
<div style="font-size: 13px;text-align: left; padding: 8px 0px 8px 30px;" [hidden]="email.valid || email.pristine || email.untouched" class="error">
Email is invalid!
</div>
</code>```

Body:
I have an add popup, after filling all fields and giving submit, the values are getting saved. If I open again and add popup to add new values without page refresh, in the email field without filling anything it is displaying Email is invalid. On pageload it is working fine. Please can anyone help to solve this issue.
I am here by sharing my code please help

HTML code

   <md-input-container>
   <input mdInput type="text" name="workEmail" [(ngModel)]="userDetails.workEmail" placeholder="WD Email" #email="ngModel" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" required>
   </md-input-container>

                                Email is invalid!

Thanks in advance.

Body:
You can add untouched and check once.

<md-input-container>
<input mdInput type="text" name="workEmail" [(ngModel)]="userDetails.workEmail" placeholder="WD Email" #email="ngModel" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" required>
</md-input-container>
<div style="font-size: 13px;text-align: left; padding: 8px 0px 8px 30px;" [hidden]="email.valid || email.pristine || email.untouched" class="error">
Email is invalid!
</div>


问:
Unparseable Number in Google Analytics Talend Pull
I'm using the tGoogleAnalyticsInput component to extract some basic Google Analytics dimensions and metrics and write them to a sql database.

However, I keep getting a java error when it tries to pull the source "(direct)" it flags it as an unparseable number. Everywhere in my ETL I have the source set as a string, so I'm not sure what's tripping it up. Attached are some relevant screenshots:

tGoogleAnalyticsInput component setup:

Schema with everything but sessions as a string:

And here is the specific language of the error:

```<code>Exception in component tGoogleAnalyticsInput_1
java.lang.Exception: Convert field: row1.gasessions value=[(direct)] countLines=1 failed:Unparseable number: "(direct)"
</code>```

Ideally it should output the dimensions and metrics to the table for a single day specified by the context.

答:
The schema you defined seems to be wrong. According to this tutorial the schema in their case looks like:

source (String)

medium (String)

date (Date)

visits (String)

continent (String)

Your first column is Sessions (Integer). Since a number conversion error is thrown I suppose this is the culprit. Try changing the type to String.

Also I am not sure if the Metrics entries come first in the response or last. You might want to change all data types to String to be able to consume the data and analyze it and later change data types accordingly.

Body:
I'm using the tGoogleAnalyticsInput component to extract some basic Google Analytics dimensions and metrics and write them to a sql database.

However, I keep getting a java error when it tries to pull the source "(direct)" it flags it as an unparseable number. Everywhere in my ETL I have the source set as a string, so I'm not sure what's tripping it up. Attached are some relevant screenshots:

tGoogleAnalyticsInput component setup:

Schema with everything but sessions as a string:

And here is the specific language of the error:

Exception in component tGoogleAnalyticsInput_1
java.lang.Exception: Convert field: row1.gasessions value=[(direct)] countLines=1 failed:Unparseable number: "(direct)"

Ideally it should output the dimensions and metrics to the table for a single day specified by the context.


问:
Selenium: Opening a Downloaded File in Java
I need to open and read a downloaded file using selenium and I'm not quite sure how to do it. I see answers that suggests to download the file in a selected location. Does my code really need to start from downloading the file to selected location or can it start directly after downloading?

After opening the file I must also read it. Can anyone give me an idea on how to do this? Thank you!

答:
You can use this line of code to handel download a file from chrome and forefox browser.</p>

```<code>public static File waitForDownloadToComplete(File downloadPath, String fileName) throws Exception {
        boolean isFileFound = false;
        int waitCounter = 0;
        while (!isFileFound) {
            logger.info("Waiting For Download To Complete....");
            for (File tempFile : downloadPath.listFiles()) {
                if (tempFile.getName().contains(fileName)) {
                    String tempEx = FilenameUtils.getExtension(tempFile.getName());
                    // crdownload - For Chrome, part - For Firefox
                    if (tempEx.equalsIgnoreCase("crdownload") || tempEx.equalsIgnoreCase("part")) {
                        Thread.sleep(1000);
                    } else {
                        isFileFound = true;
                        logger.info("Download To Completed....");
                        return tempFile;
                    }
                }
            }
            Thread.sleep(1000);
            waitCounter++;
            if (waitCounter > 25) {
                isFileFound = true;
            }
        }
        throw new Exception("File Not Downloaded");
    }
}
</code>```

Body:
You can use this line of code to handel download a file from chrome and forefox browser.

public static File waitForDownloadToComplete(File downloadPath, String fileName) throws Exception {
        boolean isFileFound = false;
        int waitCounter = 0;
        while (!isFileFound) {
            logger.info("Waiting For Download To Complete....");
            for (File tempFile : downloadPath.listFiles()) {
                if (tempFile.getName().contains(fileName)) {
                    String tempEx = FilenameUtils.getExtension(tempFile.getName());
                    // crdownload - For Chrome, part - For Firefox
                    if (tempEx.equalsIgnoreCase("crdownload") || tempEx.equalsIgnoreCase("part")) {
                        Thread.sleep(1000);
                    } else {
                        isFileFound = true;
                        logger.info("Download To Completed....");
                        return tempFile;
                    }
                }
            }
            Thread.sleep(1000);
            waitCounter++;
            if (waitCounter > 25) {
                isFileFound = true;
            }
        }
        throw new Exception("File Not Downloaded");
    }
}


问:
How to use insert and update query with in the same stored procedure using mysql?
In my project i'm using stored procedure. Here i already wrote query for inserting the data. That is,

```<code>CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_studentdetails`(
in inputStream mediumblob,
in salutation varchar(50),
in fname varchar(50),
in mname varchar(50),
in lname varchar(50),
in dob varchar(50),
in gender varchar(50),
in identify varchar(50),
in nationality varchar(50),
in blood varchar(50),
in physical varchar(50),
in health varchar(50),
in nationalid varchar(50),
in mtongue varchar(50)
)
BEGIN
INSERT INTO
tbl_student_details(studentpic,salutation,fname,mname,lname,
dob,gender,identify,nationality,blood,physical,health,nationalid,mtongue)
values (inputStream,salutation,fname,mname,lname,
dob,gender,identify,nationality,blood,physical,health,nationalid,mtongue);
END
</code>```

Here I want to add one more update query for this same table. I don't know how to do.

答:
You could use

```<code>INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
</code>```

see https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html

of course you have to build it for you procedure

In your case this should look like

```<code>INSERT INTO
    tbl_student_details
        (
          studentpic,salutation,fname,mname,lname,
          dob,gender,identify,nationality,blood,physical,
          health,nationalid,mtongue
        )
    values
        (
          inputStream,salutation,fname,mname,lname,
          dob,gender,identify,nationality,blood,physical,
          health,nationalid,mtongue
        )
ON DUPLICATE KEY UPDATE
        (
          studentpic=inputStream,salutation=salutation,fname=fname,....
          -- go with rest of your variables...
          -- you should consider to use diffrent name or quote them right
        );
</code>```

Here for you need some unique columns in your db that causes the duplicate effekt. And you may add a ID column as primary key to your create.

Edit: According to your comment

It's still the same thing you do... you will update existing data, including new data for this row or only new data when you can seperate it.

E.g.

```<code>insert into tbl(a,b,c) values ('aaa','bbb','ccc')
ON DUPLICATE KEY UPDATE b='bbb', c='ccc', d='ddd', e='eee', f='fff';
</code>```

Body:
In my project i'm using stored procedure. Here i already wrote query for inserting the data. That is,

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_studentdetails`(
in inputStream mediumblob,
in salutation varchar(50),
in fname varchar(50),
in mname varchar(50),
in lname varchar(50),
in dob varchar(50),
in gender varchar(50),
in identify varchar(50),
in nationality varchar(50),
in blood varchar(50),
in physical varchar(50),
in health varchar(50),
in nationalid varchar(50),
in mtongue varchar(50)
)
BEGIN
INSERT INTO
tbl_student_details(studentpic,salutation,fname,mname,lname,
dob,gender,identify,nationality,blood,physical,health,nationalid,mtongue)
values (inputStream,salutation,fname,mname,lname,
dob,gender,identify,nationality,blood,physical,health,nationalid,mtongue);
END

Here I want to add one more update query for this same table. I don't know how to do.

Body:
You could use

INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;

see https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html

of course you have to build it for you procedure

In your case this should look like

INSERT INTO
    tbl_student_details
        (
          studentpic,salutation,fname,mname,lname,
          dob,gender,identify,nationality,blood,physical,
          health,nationalid,mtongue
        )
    values
        (
          inputStream,salutation,fname,mname,lname,
          dob,gender,identify,nationality,blood,physical,
          health,nationalid,mtongue
        )
ON DUPLICATE KEY UPDATE
        (
          studentpic=inputStream,salutation=salutation,fname=fname,....
          -- go with rest of your variables...
          -- you should consider to use diffrent name or quote them right
        );

Here for you need some unique columns in your db that causes the duplicate effekt. And you may add a ID column as primary key to your create.

Edit: According to your comment

It's still the same thing you do... you will update existing data, including new data for this row or only new data when you can seperate it.

E.g.

insert into tbl(a,b,c) values ('aaa','bbb','ccc')
ON DUPLICATE KEY UPDATE b='bbb', c='ccc', d='ddd', e='eee', f='fff';


问:
why not display in jsp page
Item's Path doesn't display in jsp page,I want to export this sentence   ${pageContext.request.contextPath}

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
        <c:set var="basePath" scope="request">${pageContext.request.contextPath}</c:set>
        <%
            response.setHeader("Cache-Control","no-catch");
            response.setHeader("Pragma","no-catch");
            response.setDateHeader("Expires",0);
            String a=request.getContextPath();
            System.out.println(a);
             %>
    <html>
        <head>
            <meta charset="utf-8"/>
            <title>code-serv-web</title>
        </head>
        <body>
            <h1>code-serv-web</h1>
            <button id="but">点击</button>

        </body>

    </html>
</code>```

why not display in jsp page  ${pageContext.request.contextPath}

答:
The El expression should be writen in JSP pages.

${pageContext. Request. ContextPath} is through the get method to get samples, first pageContext. GetRequest () to get it, and then call it getContextPath method
< % % > you have to use pageContext. GetRequest (), the point must not come out, and it doesn't have this property.
The role is to remove the deployed application name so that the path is correct regardless of how it is deployed.

The El expression method: ${pageContext. Request. ContextPath}

The JSP is written in: < % = request.getcontextpath () % >

Title: why not display in jsp page

Body:
Item's Path doesn't display in jsp page,I want to export this sentence   ${pageContext.request.contextPath}

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
        <c:set var="basePath" scope="request">${pageContext.request.contextPath}</c:set>
        <%
            response.setHeader("Cache-Control","no-catch");
            response.setHeader("Pragma","no-catch");
            response.setDateHeader("Expires",0);
            String a=request.getContextPath();
            System.out.println(a);
             %>

            <meta charset="utf-8"/>
            <title>code-serv-web</title>

code-serv-web

            <button id="but">点击</button>

why not display in jsp page  ${pageContext.request.contextPath}


问:
PostgreSQL: find out if a row has been created by the current transaction
Is it possible to find out if a row in a table has been created by the current transaction (and therefore is not yet visible for other transactions, because the current transaction is still active)?

My use case: I am adding event logging to the database. This is done in plpgsql triggers. A row in the event table looks like this: (event id:serial, event action:text, count:integer:default 1).

Now, the reasoning behind my question: If a certain row has been created by this transaction (most likely in another trigger), I could increment the count instead of creating a new row in the event table.

答:
You might consider something like this:

```<code>create table ConnectionCurrentAction (
     connectionID int primary key,
     currentActionID uuid
)
</code>```

then at the beginning of the transaction:

```<code>delete ConnectionCurrentAction where connectionID = pg_backend_pid()
insert ConnectionCurrentAction(connectionID, currentActionID)
select pg_backend_pid(), uuid_generate_v4()
</code>```

You can wrap this in a proc called say, audit_action_begin

Note: You may instead choose to enforce the requirement that an "action" be created explicitly by removing the delete here.

At the end of a transaction, do audit_action_end:

```<code>delete ConnectionCurrentAction where connectionID = pg_backend_pid()
</code>```

Whenever you want to know the current transaction:

```<code>(select currentActionID from ConnectionCurrentAction where connectionID - pg_backend_pid()(
</code>```

You can wrap that in a function audit_action_current()

You can then put the currentActionID into your log which will enable you to identify whether a row was created in the current action or not. This will also allow you to identify where rows in different audit tables were created in the current logical action.

If you don't want to use a uuid a sequence would do just as well here. I like uuids.

Body:
You might consider something like this:

create table ConnectionCurrentAction (
     connectionID int primary key,
     currentActionID uuid
)

then at the beginning of the transaction:

delete ConnectionCurrentAction where connectionID = pg_backend_pid()
insert ConnectionCurrentAction(connectionID, currentActionID)
select pg_backend_pid(), uuid_generate_v4()

You can wrap this in a proc called say, audit_action_begin

Note: You may instead choose to enforce the requirement that an "action" be created explicitly by removing the delete here.

At the end of a transaction, do audit_action_end:

delete ConnectionCurrentAction where connectionID = pg_backend_pid()

Whenever you want to know the current transaction:

(select currentActionID from ConnectionCurrentAction where connectionID - pg_backend_pid()(

You can wrap that in a function audit_action_current()

You can then put the currentActionID into your log which will enable you to identify whether a row was created in the current action or not. This will also allow you to identify where rows in different audit tables were created in the current logical action.

If you don't want to use a uuid a sequence would do just as well here. I like uuids.