问:
Convert amount into words with JavaScript
I need convert the total amount in to words with jquery in a script file.

I have the total value calculated and put int to id=(#grandT) and the same value should be converted in to words(Rupees/Indian numbering system) in textarea (#word)
https://en.wikipedia.org/wiki/Indian_numbering_system

Script File

$(document).ready(function() {

  $(".input").keyup(function() {
    var valp1 = +$(".prec1").val();
    var valr1 = +$(".rate1").val();
    var valq1 = +$(".qty1").val();

    var valp2 = +$(".prec2").val();
    var valr2 = +$(".rate2").val();
    var valq2 = +$(".qty2").val();

    $("#Gst1").val((valr1 * valq1) * valp1 / 100);
    $("#Gst2").val((valr2 * valq2) * valp2 / 100);

  });

  $(".input").keyup(function() {

    var val1 = +$(".rate1").val();
    var val2 = +$(".qty1").val();

    var val3 = +$(".rate2").val();
    var val4 = +$(".qty2").val();

    var valp1 = +$(".prec1").val();
    var valp2 = +$(".prec2").val();

    var valr1 = +$(".rate1").val();
    var valr2 = +$(".rate2").val();

    var valq1 = +$(".qty1").val();
    var valq2 = +$(".qty2").val();

    $("#result1").val(val1 * val2);
    $("#result2").val(val3 * val4);

    $("#grandT").val(((val1 * val2) + (val3 * val4)) + ("/-"));

  });

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>

<head>
  <meta charset="ISO-8859-1">
  <script type="text/javascript" src="jquery-1.9.1.js"></script>
  <script type="text/javascript" src="Script.js"></script>
  <link rel="stylesheet" href="StyleSheet.css">

</head>

<body>
  <page size="A4">

    <div class="rowmain">
      <table>
        <thead class="th1">
          <tr>
            <th>PRECENTAGE</th>
            <th>RATE</th>
            <th>QTY</th>
            <th>GST <br> AMOUNT
            </th>
            <th>AMOUNT</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td valign="middle"><input type="number" class="input prec1" value="" style="width: 3em" name="pre"></td>
            <td valign="middle"><input type="number" name="rate" class="input rate1" value="" style="width: 5em"></td>
            <td valign="middle"><input type="number" name="qty" class="input qty1" value="" style="width: 5em"></td>
            <td valign="middle"><input disabled="disabled" id="Gst1" style="width: 6.5em" name="gst"></td>
            <td valign="middle"><input disabled="disabled" class="text-right" id="result1" name="result1" class="input result1" value="" style="width: 7.4em"></td>
          </tr>

          <tr>
            <td valign="middle"><input type="number" class="input prec2" value="" style="width: 3em" name="pre"></td>
            <td valign="middle"><input type="number" name="rate" class="input rate2" value="" style="width: 5em"></td>
            <td valign="middle"><input type="number" name="qty" class="input qty2" value="" style="width: 5em"></td>
            <td valign="middle"><input disabled="disabled" id="Gst2" style="width: 6.5em" name="gst2"></td>
            <td valign="middle"><input disabled="disabled" class="text-right" id="result2" name="result2" class="input result2" style="width: 7.4em"></td>
          </tr>

        </tbody>
      </table>
    </div>
    <div class="rowmain">

      <div class="leftttext">
        <table class="th1">
          <tr>
            <th>Rupees in Words</th>
            <td><textarea id="word" rows="2" cols="60"></textarea></td>
          </tr>
        </table>
      </div>

      <div class="righttext">
        <table>

          <tr>
            <th class="thG">Grand Total</th>
            <td><input disabled="disabled" class="text1" id="grandT" value="" style="width: 8em"></td>
          </tr>
        </table>
      </div>
    </div>

  </page>
</body>

</html></code>```

答:
Here's a working snippet of what you wanted to achieve, as already suggested the conversion to word is done by the snippet in answer here: Convert digits into words with JavaScript, I recommend you read and look at the published package if that's more useful for you.

/*
 * taken from
 * https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript
*/
var a = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen '];
var b = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];

function inWords(num) {
    if ((num = num.toString()).length > 9) return 'overflow';
    n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
    if (!n) return;
    var str = '';
    str += (n[1] != 0) ? (a[Number(n[1])] || b[n[1][0]] + ' ' + a[n[1][1]]) + 'crore ' : '';
    str += (n[2] != 0) ? (a[Number(n[2])] || b[n[2][0]] + ' ' + a[n[2][1]]) + 'lakh ' : '';
    str += (n[3] != 0) ? (a[Number(n[3])] || b[n[3][0]] + ' ' + a[n[3][1]]) + 'thousand ' : '';
    str += (n[4] != 0) ? (a[Number(n[4])] || b[n[4][0]] + ' ' + a[n[4][1]]) + 'hundred ' : '';
    str += (n[5] != 0) ? ((str != '') ? 'and ' : '') + (a[Number(n[5])] || b[n[5][0]] + ' ' + a[n[5][1]]) + 'only ' : '';
    return str;
}

$(document).ready(function() {

    $(".input").keyup(function() {
        var valp1 = +$(".prec1").val();
        var valr1 = +$(".rate1").val();
        var valq1 = +$(".qty1").val();

        var valp2 = +$(".prec2").val();
        var valr2 = +$(".rate2").val();
        var valq2 = +$(".qty2").val();

        $("#Gst1").val((valr1 * valq1) * valp1 / 100);
        $("#Gst2").val((valr2 * valq2) * valp2 / 100);

    });

    $(".input").keyup(function() {

            var val1 = +$(".rate1").val();
            var val2 = +$(".qty1").val();

            var val3 = +$(".rate2").val();
            var val4 = +$(".qty2").val();

            var valp1 = +$(".prec1").val();
            var valp2 = +$(".prec2").val();

            var valr1 = +$(".rate1").val();
            var valr2 = +$(".rate2").val();

            var valq1 = +$(".qty1").val();
            var valq2 = +$(".qty2").val();

            $("#result1").val(val1 * val2);
            $("#result2").val(val3 * val4);

            var total = (val1 * val2) + (val3 * val4);

            $("#grandT").val(total + "/-");

            $("#word").val(inWords(total));
    });

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>

<head>
  <meta charset="ISO-8859-1">
  <script type="text/javascript" src="jquery-1.9.1.js"></script>
  <script type="text/javascript" src="Script.js"></script>
  <link rel="stylesheet" href="StyleSheet.css">

</head>

<body>
  <page size="A4">

    <div class="rowmain">
      <table>
        <thead class="th1">
          <tr>
            <th>PRECENTAGE</th>
            <th>RATE</th>
            <th>QTY</th>
            <th>GST <br> AMOUNT
            </th>
            <th>AMOUNT</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td valign="middle"><input type="number" class="input prec1" value="" style="width: 3em" name="pre"></td>
            <td valign="middle"><input type="number" name="rate" class="input rate1" value="" style="width: 5em"></td>
            <td valign="middle"><input type="number" name="qty" class="input qty1" value="" style="width: 5em"></td>
            <td valign="middle"><input disabled="disabled" id="Gst1" style="width: 6.5em" name="gst"></td>
            <td valign="middle"><input disabled="disabled" class="text-right" id="result1" name="result1" class="input result1" value="" style="width: 7.4em"></td>
          </tr>

          <tr>
            <td valign="middle"><input type="number" class="input prec2" value="" style="width: 3em" name="pre"></td>
            <td valign="middle"><input type="number" name="rate" class="input rate2" value="" style="width: 5em"></td>
            <td valign="middle"><input type="number" name="qty" class="input qty2" value="" style="width: 5em"></td>
            <td valign="middle"><input disabled="disabled" id="Gst2" style="width: 6.5em" name="gst2"></td>
            <td valign="middle"><input disabled="disabled" class="text-right" id="result2" name="result2" class="input result2" style="width: 7.4em"></td>
          </tr>

        </tbody>
      </table>
    </div>
    <div class="rowmain">

      <div class="leftttext">
        <table class="th1">
          <tr>
            <th>Rupees in Words</th>
            <td><textarea id="word" rows="2" cols="60"></textarea></td>
          </tr>
        </table>
      </div>

      <div class="righttext">
        <table>

          <tr>
            <th class="thG">Grand Total</th>
            <td><input disabled="disabled" class="text1" id="grandT" value="" style="width: 8em"></td>
          </tr>
        </table>
      </div>
    </div>

  </page>
</body>

</html></code>```

Body:
I need convert the total amount in to words with jquery in a script file.

I have the total value calculated and put int to id=(#grandT) and the same value should be converted in to words(Rupees/Indian numbering system) in textarea (#word)
https://en.wikipedia.org/wiki/Indian_numbering_system

Script File

$(document).ready(function() {

  $(".input").keyup(function() {
    var valp1 = +$(".prec1").val();
    var valr1 = +$(".rate1").val();
    var valq1 = +$(".qty1").val();

    var valp2 = +$(".prec2").val();
    var valr2 = +$(".rate2").val();
    var valq2 = +$(".qty2").val();

    $("#Gst1").val((valr1 * valq1) * valp1 / 100);
    $("#Gst2").val((valr2 * valq2) * valp2 / 100);

  });

  $(".input").keyup(function() {

    var val1 = +$(".rate1").val();
    var val2 = +$(".qty1").val();

    var val3 = +$(".rate2").val();
    var val4 = +$(".qty2").val();

    var valp1 = +$(".prec1").val();
    var valp2 = +$(".prec2").val();

    var valr1 = +$(".rate1").val();
    var valr2 = +$(".rate2").val();

    var valq1 = +$(".qty1").val();
    var valq2 = +$(".qty2").val();

    $("#result1").val(val1 * val2);
    $("#result2").val(val3 * val4);

    $("#grandT").val(((val1 * val2) + (val3 * val4)) + ("/-"));

  });

});

<!DOCTYPE html>

  <meta charset="ISO-8859-1">

  <link rel="stylesheet" href="StyleSheet.css">

  <page size="A4">

            PRECENTAGE
            RATE
            QTY
            GST
 AMOUNT

            AMOUNT

            <input type="number" class="input prec1" value="" style="width: 3em" name="pre">
            <input type="number" name="rate" class="input rate1" value="" style="width: 5em">
            <input type="number" name="qty" class="input qty1" value="" style="width: 5em">
            <input disabled="disabled" id="Gst1" style="width: 6.5em" name="gst">
            <input disabled="disabled" class="text-right" id="result1" name="result1" class="input result1" value="" style="width: 7.4em">

            <input type="number" class="input prec2" value="" style="width: 3em" name="pre">
            <input type="number" name="rate" class="input rate2" value="" style="width: 5em">
            <input type="number" name="qty" class="input qty2" value="" style="width: 5em">
            <input disabled="disabled" id="Gst2" style="width: 6.5em" name="gst2">
            <input disabled="disabled" class="text-right" id="result2" name="result2" class="input result2" style="width: 7.4em">

            Rupees in Words
            <textarea id="word" rows="2" cols="60"></textarea>

            Grand Total
            <input disabled="disabled" class="text1" id="grandT" value="" style="width: 8em">

  </page>

Body:
Here's a working snippet of what you wanted to achieve, as already suggested the conversion to word is done by the snippet in answer here: Convert digits into words with JavaScript, I recommend you read and look at the published package if that's more useful for you.

/*
 * taken from
 * https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript
*/
var a = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen '];
var b = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];

function inWords(num) {
    if ((num = num.toString()).length > 9) return 'overflow';
    n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
    if (!n) return;
    var str = '';
    str += (n[1] != 0) ? (a[Number(n[1])] || b[n[1][0]] + ' ' + a[n[1][1]]) + 'crore ' : '';
    str += (n[2] != 0) ? (a[Number(n[2])] || b[n[2][0]] + ' ' + a[n[2][1]]) + 'lakh ' : '';
    str += (n[3] != 0) ? (a[Number(n[3])] || b[n[3][0]] + ' ' + a[n[3][1]]) + 'thousand ' : '';
    str += (n[4] != 0) ? (a[Number(n[4])] || b[n[4][0]] + ' ' + a[n[4][1]]) + 'hundred ' : '';
    str += (n[5] != 0) ? ((str != '') ? 'and ' : '') + (a[Number(n[5])] || b[n[5][0]] + ' ' + a[n[5][1]]) + 'only ' : '';
    return str;
}

$(document).ready(function() {

    $(".input").keyup(function() {
        var valp1 = +$(".prec1").val();
        var valr1 = +$(".rate1").val();
        var valq1 = +$(".qty1").val();

        var valp2 = +$(".prec2").val();
        var valr2 = +$(".rate2").val();
        var valq2 = +$(".qty2").val();

        $("#Gst1").val((valr1 * valq1) * valp1 / 100);
        $("#Gst2").val((valr2 * valq2) * valp2 / 100);

    });

    $(".input").keyup(function() {

            var val1 = +$(".rate1").val();
            var val2 = +$(".qty1").val();

            var val3 = +$(".rate2").val();
            var val4 = +$(".qty2").val();

            var valp1 = +$(".prec1").val();
            var valp2 = +$(".prec2").val();

            var valr1 = +$(".rate1").val();
            var valr2 = +$(".rate2").val();

            var valq1 = +$(".qty1").val();
            var valq2 = +$(".qty2").val();

            $("#result1").val(val1 * val2);
            $("#result2").val(val3 * val4);

            var total = (val1 * val2) + (val3 * val4);

            $("#grandT").val(total + "/-");

            $("#word").val(inWords(total));
    });

});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>

<head>
  <meta charset="ISO-8859-1">
  <script type="text/javascript" src="jquery-1.9.1.js"></script>
  <script type="text/javascript" src="Script.js"></script>
  <link rel="stylesheet" href="StyleSheet.css">

</head>

<body>
  <page size="A4">

    <div class="rowmain">
      <table>
        <thead class="th1">
          <tr>
            <th>PRECENTAGE</th>
            <th>RATE</th>
            <th>QTY</th>
            <th>GST <br> AMOUNT
            </th>
            <th>AMOUNT</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td valign="middle"><input type="number" class="input prec1" value="" style="width: 3em" name="pre"></td>
            <td valign="middle"><input type="number" name="rate" class="input rate1" value="" style="width: 5em"></td>
            <td valign="middle"><input type="number" name="qty" class="input qty1" value="" style="width: 5em"></td>
            <td valign="middle"><input disabled="disabled" id="Gst1" style="width: 6.5em" name="gst"></td>
            <td valign="middle"><input disabled="disabled" class="text-right" id="result1" name="result1" class="input result1" value="" style="width: 7.4em"></td>
          </tr>

          <tr>
            <td valign="middle"><input type="number" class="input prec2" value="" style="width: 3em" name="pre"></td>
            <td valign="middle"><input type="number" name="rate" class="input rate2" value="" style="width: 5em"></td>
            <td valign="middle"><input type="number" name="qty" class="input qty2" value="" style="width: 5em"></td>
            <td valign="middle"><input disabled="disabled" id="Gst2" style="width: 6.5em" name="gst2"></td>
            <td valign="middle"><input disabled="disabled" class="text-right" id="result2" name="result2" class="input result2" style="width: 7.4em"></td>
          </tr>

        </tbody>
      </table>
    </div>
    <div class="rowmain">

      <div class="leftttext">
        <table class="th1">
          <tr>
            <th>Rupees in Words</th>
            <td><textarea id="word" rows="2" cols="60"></textarea></td>
          </tr>
        </table>
      </div>

      <div class="righttext">
        <table>

          <tr>
            <th class="thG">Grand Total</th>
            <td><input disabled="disabled" class="text1" id="grandT" value="" style="width: 8em"></td>
          </tr>
        </table>
      </div>
    </div>

  </page>
</body>

</html>


来源: stackexchange

问:
store input value which is in loop with javascript
I have a column input field in  which is in the loop due to this each Row has input field I got a javascript from which it storing local storage for input field but the issue is this javascript is working only for one input For Example :

I have five rows and due to loop input field generated for 5 rows automatically

What I am looking for is to store different values for each row..due to this script its not implementing for each row individually

Code

```<code><input type="text" id="txt_1" onkeyup='saveValue(this);'/>
</code>```

Javascript

```<code><script type="text/javascript">
        document.getElementById("txt_1").value = getSavedValue("txt_1");    // set the value to this input
        document.getElementById("txt_2").value = getSavedValue("txt_2");   // set the value to this input
        /* Here you can add more inputs to set value. if it's saved */

        //Save the value function - save it to localStorage as (ID, VALUE)
        function saveValue(e){
            var id = e.id;  // get the sender's id to save it .
            var val = e.value; // get the value.
            localStorage.setItem(id, val);// Every time user writing something, the localStorage's value will override .
        }

        //get the saved value function - return the value of "v" from localStorage.
        function getSavedValue  (v){
            if (!localStorage.getItem(v)) {
                return "";// You can change this to your defualt value.
            }
            return localStorage.getItem(v);
        }
</script>
</code>```

Image Showing

COde

```<code><table class="table table-hover table-striped table-bordered" id="input-group">
<thead ><tr >
 <th class="text-right"><?php echo "Contact No."; ?></th>
  <th><?php echo "Followup 1 Date"; ?>
    </th></tr></thead>
    <tbody>
    <?php
      if (empty($enquiry_list)) {
       ?>
       <?php
        } else {
        foreach ($enquiry_list as $key => $value) {
         $current_date = date("d/m/Y");
         $next_date = $value["next_date"];
         if (empty($next_date)) { $next_date = $value["follow_up_date"];
          }if ($next_date < $current_date) {
          $class = "class='danger'";} else {
           $class = ""; } ?>
           <td class="mailbox-name"><?php echo $value['contact']; ?> </td>
   <td class="mailbox-name" >
    <div  style="width:200px" style="height:200px" >
     <input id="txt_<?= $row[id] ?>" onkeyup='saveValue(this);'
      autocomplete="off" type="text" class="form-control"   /></div></td>
      </tr> </tr>
      <?php }}?> </tbody> </table>
</code>```

答:
Html is not reliable. You can use pure javascript code for cleaner way. Here is the working sample. Slackblitz https://stackblitz.com/edit/js-xycijp

function saveValue({ target }, index) {
  localStorage.setItem(target.id, target.value); // Every time user writing
  // OR
  localStorage.setItem("target.id"+index, target.value); // Every time user writing something, the localStorage's value will override .
}

//get the saved value function - return the value of "v" from localStorage.
function getSavedValue(v) {
  if (!localStorage.getItem(v)) {
    return ""; // You can change this to your defualt value.
  }
  return localStorage.getItem(v);
}
document.querySelectorAll(".textField").forEach((elm, index) => {
  elm.addEventListener("input", (e) => saveValue(e, index), false);
});

// Can ignore
window.saveValue = saveValue;
window.getSavedValue = getSavedValue;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input class='textField' type="text" id="txt_1" />
<input class='textField' type="text" id="txt_2" /> </code>```

ContentLicense: CC BY-SA 4.0

Body:
I have a column input field in  which is in the loop due to this each Row has input field I got a javascript from which it storing local storage for input field but the issue is this javascript is working only for one input For Example :

I have five rows and due to loop input field generated for 5 rows automatically

What I am looking for is to store different values for each row..due to this script its not implementing for each row individually

Code

<input type="text" id="txt_1" onkeyup='saveValue(this);'/>

Javascript

Image Showing

COde

 <?php echo "Contact No."; ?>
  <?php echo "Followup 1 Date"; ?>

    <?php
      if (empty($enquiry_list)) {
       ?>
       <?php
        } else {
        foreach ($enquiry_list as $key => $value) {
         $current_date = date("d/m/Y");
         $next_date = $value["next_date"];
         if (empty($next_date)) { $next_date = $value["follow_up_date"];
          }if ($next_date < $current_date) {
          $class = "class='danger'";} else {
           $class = ""; } ?>
           <?php echo $value['contact']; ?>

     <input id="txt_<?= $row[id] ?>" onkeyup='saveValue(this);'
      autocomplete="off" type="text" class="form-control"   />

      <?php }}?>

Body:
Html is not reliable. You can use pure javascript code for cleaner way. Here is the working sample. Slackblitz https://stackblitz.com/edit/js-xycijp

function saveValue({ target }, index) {
  localStorage.setItem(target.id, target.value); // Every time user writing
  // OR
  localStorage.setItem("target.id"+index, target.value); // Every time user writing something, the localStorage's value will override .
}

//get the saved value function - return the value of "v" from localStorage.
function getSavedValue(v) {
  if (!localStorage.getItem(v)) {
    return ""; // You can change this to your defualt value.
  }
  return localStorage.getItem(v);
}
document.querySelectorAll(".textField").forEach((elm, index) => {
  elm.addEventListener("input", (e) => saveValue(e, index), false);
});

// Can ignore
window.saveValue = saveValue;
window.getSavedValue = getSavedValue;

<input class='textField' type="text" id="txt_1" />
<input class='textField' type="text" id="txt_2" />


问:
How can I build a condition based query in Laravel 6.x?
```<code>public function test(Request $request){
    $apartments = DB::table('apartments');
    if ($request->filled('bathrooms')) {
        $apartments->where('bathrooms', '=' ,$request->input('bathrooms'));
    }
    if ($request->filled('rooms_number')) {
        $apartments->where('rooms_number', '=', $request->input('rooms_number'));
    }
    $apartments->get();
    return view('pages.test2' , compact('apartments'));
}
</code>```

How can this code be translated so that it works in Laravel?

答:
You can use when as a conditional clause:

public function test (Request $request)
{
    $apartments = DB::table('apartments')
        ->when($request->filled('bathrooms'), function ($query) use ($request) {
            return $query->where('bathrooms', '=', $request->input('bathrooms'));
        })
        ->when($request->filled('rooms_number'), function ($query) use ($request) {
            return $query->where('rooms_number', '=', $request->input('rooms_number'));
        })
        ->get();

    return view('pages.test2' , compact('apartments'));
}
```

Body:
public function test(Request $request){
    $apartments = DB::table('apartments');
    if ($request->filled('bathrooms')) {
        $apartments->where('bathrooms', '=' ,$request->input('bathrooms'));
    }
    if ($request->filled('rooms_number')) {
        $apartments->where('rooms_number', '=', $request->input('rooms_number'));
    }
    $apartments->get();
    return view('pages.test2' , compact('apartments'));
}

How can this code be translated so that it works in Laravel?


问:
antd SubMenu "TypeError: Cannot read property 'isRootMenu' of undefined"
I use antd 3.15 and GraphQL to fetch data and generate a list of SubMenu and Menu.Item inside of Menu. However, I got the error message like this Uncaught TypeError: Cannot read property 'isRootMenu' of undefined I have no idea what is wrong with my code. isRootMenu is not a prop listed anywhere on the doc. ant.design/components/menu/#header and when I hardcoded all the SubMenu and Menu.List there is no problem. Can I iterate data from GraphQL to generate the  SubMenu and Menu.List?

Can someone help me with this issue, please? Thank you! Here is my code:

```<code>import * as React from 'react';
import './SideNav.scss';
import { Menu, Icon } from 'antd';
import gql from 'graphql-tag';
import { Query } from 'react-apollo';

const FLOORS_QUERY = gql`
  query {
    getAllFloors {
      id
      floorName
      rooms {
        id
        roomName
        roomNumber
        roomDescription
      }
    }
  }
`;

export default class SideNav extends React.Component {
  render() {
    return (
      <Menu theme="light" defaultSelectedKeys={['1']} mode="inline">
        <Query query={FLOORS_QUERY}>
          {({ loading, error, data }) => {
            if (loading) return <h4> loading... </h4>;
            if (error) console.log(error);
            console.log(data);
            return (
              <React.Fragment>
                {data.getAllFloors.map((floor) => (
                  <SubMenu
                    key={floor.id}
                    title={
                      <span>
                        <Icon type="plus" />
                        <span>{floor.floorName}</span>
                      </span>
                    }
                  >
                    <React.Fragment>
                      {floor.rooms.map((room) => (
                        <Menu.Item key={room.id}>{room.roomNumber}</Menu.Item>
                      ))}
                    </React.Fragment>
                  </SubMenu>
                ))}
              </React.Fragment>
            );
          }}
        </Query>
      </Menu>
    );
  }
}
</code>```

答:
I found out the Ant design SubMenu needs to use the parent to check some properties like isRootMenu at

SubMenu.js:260

getPopupContainer = props.parentMenu.isRootMenu ? props.parentMenu.props.getPopupContainer : function (triggerNode) {
     return triggerNode.parentNode;
}
```

<p>In order to solve it you need to manually pass parent props into SubMenu like </p>

```<Menu.SubMenu {...this.props}/>
```

to solve the problem. Hope this helps u

Related Github issue item https://github.com/react-component/menu/issues/255

Body:
I use antd 3.15 and GraphQL to fetch data and generate a list of SubMenu and Menu.Item inside of Menu. However, I got the error message like this Uncaught TypeError: Cannot read property 'isRootMenu' of undefined I have no idea what is wrong with my code. isRootMenu is not a prop listed anywhere on the doc. ant.design/components/menu/#header and when I hardcoded all the SubMenu and Menu.List there is no problem. Can I iterate data from GraphQL to generate the  SubMenu and Menu.List?

Can someone help me with this issue, please? Thank you! Here is my code:

import * as React from 'react';
import './SideNav.scss';
import { Menu, Icon } from 'antd';
import gql from 'graphql-tag';
import { Query } from 'react-apollo';

const FLOORS_QUERY = gql`
  query {
    getAllFloors {
      id
      floorName
      rooms {
        id
        roomName
        roomNumber
        roomDescription
      }
    }
  }
`;

export default class SideNav extends React.Component {
  render() {
    return (
      <Menu theme="light" defaultSelectedKeys={['1']} mode="inline">
        <Query query={FLOORS_QUERY}>
          {({ loading, error, data }) => {
            if (loading) return
 loading...
;
            if (error) console.log(error);
            console.log(data);
            return (
              <React.Fragment>
                {data.getAllFloors.map((floor) => (
                  <SubMenu
                    key={floor.id}
                    title={

                        <Icon type="plus" />
                        {floor.floorName}

                    }
                  >
                    <React.Fragment>
                      {floor.rooms.map((room) => (
                        <Menu.Item key={room.id}>{room.roomNumber}</Menu.Item>
                      ))}
                    </React.Fragment>
                  </SubMenu>
                ))}
              </React.Fragment>
            );
          }}
        </Query>
      </Menu>
    );
  }
}

Body:
I found out the Ant design SubMenu needs to use the parent to check some properties like isRootMenu at

SubMenu.js:260

getPopupContainer = props.parentMenu.isRootMenu ? props.parentMenu.props.getPopupContainer : function (triggerNode) {
     return triggerNode.parentNode;
}

In order to solve it you need to manually pass parent props into SubMenu like

<Menu.SubMenu {...this.props}/>

to solve the problem. Hope this helps u

Related Github issue item https://github.com/react-component/menu/issues/255


问:
Display XML Schema in SQL Query Result
I'm brand new to SQL and SQL Server Management Studio, so bear with me. Here's a shortened version of my query:

```<code>SELECT *
FROM [dbo].[BranchLocations] WHERE NOT (PropertyOwnerType IS NULL)
FOR XML PATH('LocationData'), ROOT('MainRoot')
</code>```

This gives me exactly what I need except for the schema. I don't want to automatically generate a schema because the service to which I upload the XML data only accepts a specific schema structure, and I would prefer to control it.

My schema looks similar to this:

```<code><xs:schema id="LocationData_ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="LocationData_ds" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
        <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="LocationData">
            <xs:complexType>
                <xs:sequence>
                <xs:element name="EntityID" type="xs:string" />
                <xs:element name="AddressLine" type="xs:string" minOccurs="0" />
                <xs:element name="Locality" type="xs:string" minOccurs="0" />
                <xs:element name="AdminDistrict" type="xs:string" minOccurs="0" />
                <xs:element name="PostalCode" type="xs:string" minOccurs="0" />
                <xs:element name="CountryRegion" type="xs:string" minOccurs="0" />
                <xs:element name="Latitude" type="xs:double" minOccurs="0" />
                <xs:element name="Longitude" type="xs:double" minOccurs="0" />
                </xs:sequence>
            </xs:complexType>
            </xs:element>
        </xs:choice>
        </xs:complexType>
        <xs:unique name="Constraint1" msdata:PrimaryKey="true">
        <xs:selector xpath=".//LocationData" />
        <xs:field xpath="EntityID" />
        </xs:unique>
    </xs:element>
</xs:schema>
</code>```

My query returns this:

```<code><MainRoot>
  <LocationData>
    <EntityID>10010000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Converse</Locality>
    <AdminDistrict>TX</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
  <LocationData>
    <EntityID>70390000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Denver</Locality>
    <AdminDistrict>CO</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
...
<MainRoot>
</code>```

And what I need is this:

(and I need ti include<?xml version="1.0" encoding="utf-8" standalone="yes"?> at the top as well)

```<code><?xml version="1.0" encoding="utf-8" standalone="yes"?>
<MainRoot>
    <xs:schema id="LocationData_ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
        <xs:element name="LocationData_ds" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
            <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="LocationData">
                <xs:complexType>
                    <xs:sequence>
                    <xs:element name="EntityID" type="xs:string" />
                    <xs:element name="AddressLine" type="xs:string" minOccurs="0" />
                    <xs:element name="Locality" type="xs:string" minOccurs="0" />
                    <xs:element name="AdminDistrict" type="xs:string" minOccurs="0" />
                    <xs:element name="PostalCode" type="xs:string" minOccurs="0" />
                    <xs:element name="CountryRegion" type="xs:string" minOccurs="0" />
                    <xs:element name="Latitude" type="xs:double" minOccurs="0" />
                    <xs:element name="Longitude" type="xs:double" minOccurs="0" />
                    </xs:sequence>
                </xs:complexType>
                </xs:element>
            </xs:choice>
            </xs:complexType>
            <xs:unique name="Constraint1" msdata:PrimaryKey="true">
            <xs:selector xpath=".//LocationData" />
            <xs:field xpath="EntityID" />
            </xs:unique>
        </xs:element>
    </xs:schema>
<LocationData>
    <EntityID>10010000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Converse</Locality>
    <AdminDistrict>TX</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
  <LocationData>
    <EntityID>70390000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Denver</Locality>
    <AdminDistrict>CO</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
...
<MainRoot>
</code>```

Looking through the documentation has led me here:

https://learn.microsoft.com/en-us/sql/t-sql/xml/insert-xml-dml?view=sql-server-ver15

It isn't working, but I think I might be on the right track.

These answers only relate to generating a schema:

convert database table into XML schema file
how to create XML schema from an existing database in SQL Server 2008

答:
```<code>declare @BranchLocations table
(
EntityId varchar(20),
AddressLine varchar(20),
Locality varchar(20),
AdminDistrict varchar(20),
PostalCode varchar(20),
CountryRegion varchar(20),
PropertyOwnerType varchar(20)
);

insert into @BranchLocations(EntityId, AddressLine, Locality, AdminDistrict, PostalCode, CountryRegion, PropertyOwnerType)
values
('10010000', '1234 address', 'Converse', 'TX', '12345', 'US', 'x'),
('70390000', '1234 address', 'Denver', 'CO', '12345', 'US', 'x');

declare @myschema xml = N'<xs:schema id="LocationData_ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="LocationData_ds" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
        <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="LocationData">
            <xs:complexType>
                <xs:sequence>
                <xs:element name="EntityID" type="xs:string" />
                <xs:element name="AddressLine" type="xs:string" minOccurs="0" />
                <xs:element name="Locality" type="xs:string" minOccurs="0" />
                <xs:element name="AdminDistrict" type="xs:string" minOccurs="0" />
                <xs:element name="PostalCode" type="xs:string" minOccurs="0" />
                <xs:element name="CountryRegion" type="xs:string" minOccurs="0" />
                <xs:element name="Latitude" type="xs:double" minOccurs="0" />
                <xs:element name="Longitude" type="xs:double" minOccurs="0" />
                </xs:sequence>
            </xs:complexType>
            </xs:element>
        </xs:choice>
        </xs:complexType>
        <xs:unique name="Constraint1" msdata:PrimaryKey="true">
        <xs:selector xpath=".//LocationData" />
        <xs:field xpath="EntityID" />
        </xs:unique>
    </xs:element>
</xs:schema>';

declare @res nvarchar(max);
select @res = N'<?xml version="1.0" encoding="utf-8" standalone="yes"?>' +
(
select *
from
(
    select @myschema as '*'
    union all
    select
    (
    select *
    FROM @BranchLocations
    WHERE PropertyOwnerType is not null
    FOR XML PATH('LocationData')
    )
) as src
for xml path(''), root('Mainroot')
);

--test, show result
select 1 as tag, 0 as parent,
        @res+'</foo>' as 'test!1!!xmltext'
for xml explicit;

--or
select @res = null;
declare @myxml xml = (  select *
    FROM @BranchLocations
    WHERE PropertyOwnerType is not null
    and 1=2
    FOR XML PATH('LocationData'));

--null result when empty resultset from table
select @res =
N'<?xml version="1.0" encoding="utf-8" standalone="yes"?>'
+(select @myschema,@myxml for xml path(''), root('Mainroot'))
where @myxml is not null;

select @res;
</code>```

Title: Display XML Schema in SQL Query Result

Body:
I'm brand new to SQL and SQL Server Management Studio, so bear with me. Here's a shortened version of my query:

SELECT *
FROM [dbo].[BranchLocations] WHERE NOT (PropertyOwnerType IS NULL)
FOR XML PATH('LocationData'), ROOT('MainRoot')

This gives me exactly what I need except for the schema. I don't want to automatically generate a schema because the service to which I upload the XML data only accepts a specific schema structure, and I would prefer to control it.

My schema looks similar to this:

<xs:schema id="LocationData_ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="LocationData_ds" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
        <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="LocationData">
            <xs:complexType>
                <xs:sequence>
                <xs:element name="EntityID" type="xs:string" />
                <xs:element name="AddressLine" type="xs:string" minOccurs="0" />
                <xs:element name="Locality" type="xs:string" minOccurs="0" />
                <xs:element name="AdminDistrict" type="xs:string" minOccurs="0" />
                <xs:element name="PostalCode" type="xs:string" minOccurs="0" />
                <xs:element name="CountryRegion" type="xs:string" minOccurs="0" />
                <xs:element name="Latitude" type="xs:double" minOccurs="0" />
                <xs:element name="Longitude" type="xs:double" minOccurs="0" />
                </xs:sequence>
            </xs:complexType>
            </xs:element>
        </xs:choice>
        </xs:complexType>
        <xs:unique name="Constraint1" msdata:PrimaryKey="true">
        <xs:selector xpath=".//LocationData" />
        <xs:field xpath="EntityID" />
        </xs:unique>
    </xs:element>
</xs:schema>

My query returns this:

<MainRoot>
  <LocationData>
    <EntityID>10010000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Converse</Locality>
    <AdminDistrict>TX</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
  <LocationData>
    <EntityID>70390000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Denver</Locality>
    <AdminDistrict>CO</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
...
<MainRoot>

And what I need is this:

(and I need ti include<?xml version="1.0" encoding="utf-8" standalone="yes"?> at the top as well)

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<MainRoot>
    <xs:schema id="LocationData_ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
        <xs:element name="LocationData_ds" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
            <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="LocationData">
                <xs:complexType>
                    <xs:sequence>
                    <xs:element name="EntityID" type="xs:string" />
                    <xs:element name="AddressLine" type="xs:string" minOccurs="0" />
                    <xs:element name="Locality" type="xs:string" minOccurs="0" />
                    <xs:element name="AdminDistrict" type="xs:string" minOccurs="0" />
                    <xs:element name="PostalCode" type="xs:string" minOccurs="0" />
                    <xs:element name="CountryRegion" type="xs:string" minOccurs="0" />
                    <xs:element name="Latitude" type="xs:double" minOccurs="0" />
                    <xs:element name="Longitude" type="xs:double" minOccurs="0" />
                    </xs:sequence>
                </xs:complexType>
                </xs:element>
            </xs:choice>
            </xs:complexType>
            <xs:unique name="Constraint1" msdata:PrimaryKey="true">
            <xs:selector xpath=".//LocationData" />
            <xs:field xpath="EntityID" />
            </xs:unique>
        </xs:element>
    </xs:schema>
<LocationData>
    <EntityID>10010000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Converse</Locality>
    <AdminDistrict>TX</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
  <LocationData>
    <EntityID>70390000</EntityID>
    <AddressLine>1234 address<\/AddressLine>
    <Locality>Denver</Locality>
    <AdminDistrict>CO</AdminDistrict>
    <PostalCode>12345</PostalCode>
    <CountryRegion>US</CountryRegion>
  </LocationData>
...
<MainRoot>

Looking through the documentation has led me here:

https://learn.microsoft.com/en-us/sql/t-sql/xml/insert-xml-dml?view=sql-server-ver15

It isn't working, but I think I might be on the right track.

These answers only relate to generating a schema:

convert database table into XML schema file
how to create XML schema from an existing database in SQL Server 2008


问:
javascript - if and or (||) statement
```<code>if (window.location.pathname == "/" || window.location.pathname == "/yyy.asp") {
  runSlideShow();
}
if (
  window.location.pathname == "zzzz.html" ||
  window.location.pathname == "/xxx.html"
) {
  runSlideShow();
}
</code>```

How do I merge the if statements so there is only one {runSlideShow();} rather than two;

currently I cant seem to have more than two window.location.pathname statements with an || in between.

答:
You can do it in this way:

```<code>if (["/", "/yyy.asp", "zzzz.html", "/xxx.html"].includes(window.location.pathname)) {
  runSlideShow();
}
</code>```

Or

```<code>if (window.location.pathname == "/" || window.location.pathname == "/yyy.asp" ||
window.location.pathname == "zzzz.html" || window.location.pathname == "/xxx.html")
{
  runSlideShow();
}
</code>```

Title: javascript - if and or (||) statement

Body:
if (window.location.pathname == "/" || window.location.pathname == "/yyy.asp") {
  runSlideShow();
}
if (
  window.location.pathname == "zzzz.html" ||
  window.location.pathname == "/xxx.html"
) {
  runSlideShow();
}

How do I merge the if statements so there is only one {runSlideShow();} rather than two;

currently I cant seem to have more than two window.location.pathname statements with an || in between.

Body:
You can do it in this way:

if (["/", "/yyy.asp", "zzzz.html", "/xxx.html"].includes(window.location.pathname)) {
  runSlideShow();
}

Or

if (window.location.pathname == "/" || window.location.pathname == "/yyy.asp" ||
window.location.pathname == "zzzz.html" || window.location.pathname == "/xxx.html")
{
  runSlideShow();
}


问:
Receiving an error in BS4 while amazon web scraping : AttributeError: 'NoneType' object has no attribute 'get_text'
```<code>!pip install requests
!pip install bs4

import requests
from bs4 import BeautifulSoup

url = "https://www.amazon.in/Apple-iPhone-Pro-Max-256GB/dp/B07XVLH744/ref=sr_1_1_sspa?crid=2VCKZNOH3H6SR&keywords=apple+iphone+11+pro+max&qid=1582043410&sprefix=apple+iphone%2Caps%2C388&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyVjdZSE83TzU4UUMmZW5jcnlwdGVkSWQ9QTAyNTI1ODZJUzZOVUwxWDNIUlAmZW5jcnlwdGVkQWRJZD1BMDkxNDg4MzFLMFpVT1M5OFM5Q0smd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl"

headers = {"User-Agent": "in this section im adding my user agent after typing my user agent in google search"}

page = requests.get(url, headers=headers)

soup = BeautifulSoup(page.content, "html.parser")

print(soup.prettify())

title = soup.find(id = "productTitle").get_text()
price = soup.find(id = "priceblock_ourprice").get_text()

converted_price = price[0:8]

print(converted_price)
print(titles)
</code>```

i am working on google colab when i run this code  i get this error

```<code>AttributeError   Traceback (most recent call last)
<ipython-input-15-14696d9dc778> in <module>()
     16 print(soup.prettify())
     17
---> 18 title = soup.find(id = "productTitle").get_text()
     19 price = soup.find(id = "priceblock_ourprice").get_text()
     20

AttributeError: 'NoneType' object has no attribute 'get_text'
</code>```

i have tried searching all over internet but have not found answer addressing my question. i am trying to get iPhone 11 pro max price. when i run this code i get the error mentioned above.

答:
You get that error when you're trying to pull data out of an object whose value is None.  If you're seeing that on line 18, it means your soup.find(id = "productTitle") did not match anything and returned None.

You need to break down your processing into steps. Check for the return value first before accessing it. So...

```<code>title_info = soup.find(id = "productTitle")
if title_info:
    title = title_info.text
else:
    'handle the situation'
</code>```

Body:
!pip install requests
!pip install bs4

import requests
from bs4 import BeautifulSoup

url = "https://www.amazon.in/Apple-iPhone-Pro-Max-256GB/dp/B07XVLH744/ref=sr_1_1_sspa?crid=2VCKZNOH3H6SR&keywords=apple+iphone+11+pro+max&qid=1582043410&sprefix=apple+iphone%2Caps%2C388&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyVjdZSE83TzU4UUMmZW5jcnlwdGVkSWQ9QTAyNTI1ODZJUzZOVUwxWDNIUlAmZW5jcnlwdGVkQWRJZD1BMDkxNDg4MzFLMFpVT1M5OFM5Q0smd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl"

headers = {"User-Agent": "in this section im adding my user agent after typing my user agent in google search"}

page = requests.get(url, headers=headers)

soup = BeautifulSoup(page.content, "html.parser")

print(soup.prettify())

title = soup.find(id = "productTitle").get_text()
price = soup.find(id = "priceblock_ourprice").get_text()

converted_price = price[0:8]

print(converted_price)
print(titles)

i am working on google colab when i run this code  i get this error

AttributeError   Traceback (most recent call last)
<ipython-input-15-14696d9dc778> in <module>()
     16 print(soup.prettify())
     17
---> 18 title = soup.find(id = "productTitle").get_text()
     19 price = soup.find(id = "priceblock_ourprice").get_text()
     20

AttributeError: 'NoneType' object has no attribute 'get_text'

i have tried searching all over internet but have not found answer addressing my question. i am trying to get iPhone 11 pro max price. when i run this code i get the error mentioned above.

Body:
You get that error when you're trying to pull data out of an object whose value is None.  If you're seeing that on line 18, it means your soup.find(id = "productTitle") did not match anything and returned None.

You need to break down your processing into steps. Check for the return value first before accessing it. So...

title_info = soup.find(id = "productTitle")
if title_info:
    title = title_info.text
else:
    'handle the situation'


问:
CrudRepository and Hibernate: save(List<S>) vs save(Entity) in transaction
Would it make any difference if I do:

```<code>@Transactional
public void processData() {
    List<MyEntity> entities = ....;
    MyEntityRepository.save(entities);
}
</code>```

vs.

```<code>@Transactional
public void processData() {
    List<MyEntity> entities = ....;
    for (MyEntity entity : entities) {
        MyEntityRepository.save(entity);
    }
}
</code>```

What is the difference in terms of the underlying queries and performance?

答:
For SpringData Jpa, a cleaner approach will be to use repository.saveAll instead of a forloop with repository.save. saveAll will automatically iterate through the list and save it.

saveAll is a part of JpaRepository, so no need to define any method.

ContentLicense: CC BY-SA 3.0

Body:
Would it make any difference if I do:

@Transactional
public void processData() {
    List<MyEntity> entities = ....;
    MyEntityRepository.save(entities);
}

vs.

@Transactional
public void processData() {
    List<MyEntity> entities = ....;
    for (MyEntity entity : entities) {
        MyEntityRepository.save(entity);
    }
}

What is the difference in terms of the underlying queries and performance?


问:
Allow resize to ignore max-height?
I have some code like the first snippet - I am curious if there is a way to use resize and allow it to ignore max-height?

The reason I don't just use height is I want the div to fit the first piece of content without white space. I included that at the end if you want to check it out.

Basically I am trying to get something that looks like the first one, but functions like the second one.

Thanks!

.content {
  max-height: 5em;
 overflow-y: auto;
 resize: vertical;
  white-space: pre-wrap;
 }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="content">One line</div>
<div class="content">Multi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
line</div></code>```

This doesn't work for what I'm trying to do due to the excess whitespace:

.content {
  height: 5em;
 overflow-y: auto;
 resize: vertical;
  white-space: pre-wrap;
 }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="content">One line</div>
<div class="content">Multi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
line</div></code>```

In response to the first answer, the content is dynamic. I have provided a dynamic example

rand1 = Math.floor((Math.random() * 10) + 1);
rand2 = Math.floor((Math.random() * 10) + 1);
document.getElementById("1").innerHTML = "Start"
for (var i = 0; i < rand1; i++) {
  document.getElementById("1").innerHTML += ".\n"
}
document.getElementById("2").innerHTML = "Start"
for (var i = 0; i < rand2; i++) {
  document.getElementById("2").innerHTML += ".\n"
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.content {
  max-height: 5em;
  overflow-y: auto;
  resize: vertical;
  white-space: pre-wrap;
}</code>```

```

答:
You can do it with pure css. When you resize an element, a height property is automatically generated within the style tag of the html element.

If you make a css selector that references that attribute and cancels the max-height in case "height" exists, you get the effect you want.

.content {
  max-height: 5em;
  overflow-y: auto;
  resize: vertical;
  white-space: pre-wrap;
 }
.content[style*="height"] {
  max-height: unset;
} ```

Title: Allow resize to ignore max-height?

Body:
I have some code like the first snippet - I am curious if there is a way to use resize and allow it to ignore max-height?

The reason I don't just use height is I want the div to fit the first piece of content without white space. I included that at the end if you want to check it out.

Basically I am trying to get something that looks like the first one, but functions like the second one.

Thanks!

.content {
  max-height: 5em;
 overflow-y: auto;
 resize: vertical;
  white-space: pre-wrap;
 }

One line

Multi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
line

This doesn't work for what I'm trying to do due to the excess whitespace:

.content {
  height: 5em;
 overflow-y: auto;
 resize: vertical;
  white-space: pre-wrap;
 }

One line

Multi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
line

In response to the first answer, the content is dynamic. I have provided a dynamic example

rand1 = Math.floor((Math.random() * 10) + 1);
rand2 = Math.floor((Math.random() * 10) + 1);
document.getElementById("1").innerHTML = "Start"
for (var i = 0; i < rand1; i++) {
  document.getElementById("1").innerHTML += ".\n"
}
document.getElementById("2").innerHTML = "Start"
for (var i = 0; i < rand2; i++) {
  document.getElementById("2").innerHTML += ".\n"
}

.content {
  max-height: 5em;
  overflow-y: auto;
  resize: vertical;
  white-space: pre-wrap;
}


问:
Problem reference converter from an external assembly
I am creating a Resource Dictionary, where I reference all my converters, so there is no need to reference each individual converter.
My converters are in the different assembly, to import them I do the following:

Add reference to external assembly

Create a Resource Dictionary

Add xml namespace referencing Converters assembly

Reference converters

So my Dictionary looks like:

```<code>    <ResourceDictionary xmlns:Converters="clr-namespace:Client.Utilities.Converters;assembly=Client.Utilities">

    <Converters:BoolToBrushConverter x:Key="boolToBrush"/>

</ResourceDictionary>
</code>```

However I get the following exception when trying to build:

```<code>Error   18  The tag 'BoolToBrushConverter' does not exist in XML namespace 'clr-namespace:Client.Utilities.Converters;assembly=.Client.Utilities'. Line 12 Position 6.  C:\Resources.Tests\Resources\ResourceDictionaries\Converters\ConvertersResources.xaml   12  6   Client.eZenith.Resources.Tests
</code>```

Any ideas why that is happening?

Note: From intellisense it seems that namespace for Converters assembly is correct, as all converters show up in the suggestion list after typing <Converter:

Edit: VS and blend designer both are able to find that converter, when rendering control preview.

Edit: I have figured out, that it is nothing to do with dictionaries being merged. The same issue appears, when adding a converter to Window's Resources.

答:
Try using

```<code><ResourceDictionary xmlns:Converters="clr-namespace:Client.Utilities.Converters;assembly=Client.Utilities">
</code>```

instead.

Change: clr-namespace instead of namespace.

Body:
I am creating a Resource Dictionary, where I reference all my converters, so there is no need to reference each individual converter.
My converters are in the different assembly, to import them I do the following:

Add reference to external assembly

Create a Resource Dictionary

Add xml namespace referencing Converters assembly

Reference converters

So my Dictionary looks like:

    <ResourceDictionary xmlns:Converters="clr-namespace:Client.Utilities.Converters;assembly=Client.Utilities">

    <Converters:BoolToBrushConverter x:Key="boolToBrush"/>

</ResourceDictionary>

However I get the following exception when trying to build:

Error   18  The tag 'BoolToBrushConverter' does not exist in XML namespace 'clr-namespace:Client.Utilities.Converters;assembly=.Client.Utilities'. Line 12 Position 6.  C:\Resources.Tests\Resources\ResourceDictionaries\Converters\ConvertersResources.xaml   12  6   Client.eZenith.Resources.Tests

Any ideas why that is happening?

Note: From intellisense it seems that namespace for Converters assembly is correct, as all converters show up in the suggestion list after typing <Converter:

Edit: VS and blend designer both are able to find that converter, when rendering control preview.

Edit: I have figured out, that it is nothing to do with dictionaries being merged. The same issue appears, when adding a converter to Window's Resources.

Body:
Try using

<ResourceDictionary xmlns:Converters="clr-namespace:Client.Utilities.Converters;assembly=Client.Utilities">

instead.

Change: clr-namespace instead of namespace.


问:
Write a class that draws an image in the center of the screen in PyGame
The following question is from chapter 12 of the book:
"Python Crash Course".

I need to write a class that draws a *.bmp image at the center of the screen.

I had a look here and here, which is a very specific case.

My class, which didn't raise much success, is:

```<code>import pygame, sys

class Lion():

    def __init__(self, screen):
        self.screen = screen

        self.screen_width = 1000
        self.screen_height = 500
        self.bg_color = (230, 230, 230)

        self.image = pygame.image.load('C:/Users/yoelp/Desktop/Python Works/lion.bmp')

        self.rect = self.image.get_rect()

        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery

        # Creating an instance of Lion.
        lion = Lion(screen)

        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

            self.screen.blit(self.image, self.rect)
            pygame.display.flip()
</code>```

Any ideas?

Thank you.

答:
you don't have pygame.init()

you don't create screen but your class get screen as argument

you create instance of Lion() inside Lion.__init__() which is big mistake

I would write it this way.

```<code>import pygame
import sys

# --- constants --- (UPPER_CASE_NAMES)

SCREEN_WIDTH = 1000
SCREEN_HEIGHT = 500

# --- classes --- (CamelCaseNames)

class Lion():

    def __init__(self, screen):

        # get screen
        self.screen = screen

        # get rect from screen
        self.screen_rect = self.screen.get_rect()

        self.bg_color = (230, 230, 230)

        self.image = pygame.image.load('C:/Users/yoelp/Desktop/Python Works/lion.bmp')

        self.rect = self.image.get_rect()

        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery

    def run(self):
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()  # close Pygame's window on some systems
                    sys.exit()

            self.screen.blit(self.image, self.rect)
            pygame.display.flip()

# --- functions --- (lower_case_names)

# empty

# --- main ---

pygame.init()

# create screen
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

# send screen to class instance
lion = Lion(screen)
lion.run()

#pygame.quit()
</code>```

If you want all in one method in class then

```<code>import pygame
import sys

# --- classes ---

class Lion():

    def __init__(self): # without `screen` as argument

        pygame.init()

        # create screen
        self.screen = pygame.display.set_mode((1000, 500))

        # get rect from screen
        self.screen_rect = self.screen.get_rect()

        self.bg_color = (230, 230, 230)

        self.image = pygame.image.load('C:/Users/yoelp/Desktop/Python Works/lion.bmp')

        self.rect = self.image.get_rect()

        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery

        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()

            self.screen.blit(self.image, self.rect)
            pygame.display.flip()

# --- main ---

lion = Lion() # without `screen` as argument
</code>```

Body:
The following question is from chapter 12 of the book:
"Python Crash Course".

I need to write a class that draws a *.bmp image at the center of the screen.

I had a look here and here, which is a very specific case.

My class, which didn't raise much success, is:

import pygame, sys

class Lion():

    def __init__(self, screen):
        self.screen = screen

        self.screen_width = 1000
        self.screen_height = 500
        self.bg_color = (230, 230, 230)

        self.image = pygame.image.load('C:/Users/yoelp/Desktop/Python Works/lion.bmp')

        self.rect = self.image.get_rect()

        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery

        # Creating an instance of Lion.
        lion = Lion(screen)

        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

            self.screen.blit(self.image, self.rect)
            pygame.display.flip()

Any ideas?

Thank you.

Body:
you don't have pygame.init()

you don't create screen but your class get screen as argument

you create instance of Lion() inside Lion.__init__() which is big mistake

I would write it this way.

import pygame
import sys

# --- constants --- (UPPER_CASE_NAMES)

SCREEN_WIDTH = 1000
SCREEN_HEIGHT = 500

# --- classes --- (CamelCaseNames)

class Lion():

    def __init__(self, screen):

        # get screen
        self.screen = screen

        # get rect from screen
        self.screen_rect = self.screen.get_rect()

        self.bg_color = (230, 230, 230)

        self.image = pygame.image.load('C:/Users/yoelp/Desktop/Python Works/lion.bmp')

        self.rect = self.image.get_rect()

        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery

    def run(self):
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()  # close Pygame's window on some systems
                    sys.exit()

            self.screen.blit(self.image, self.rect)
            pygame.display.flip()

# --- functions --- (lower_case_names)

# empty

# --- main ---

pygame.init()

# create screen
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

# send screen to class instance
lion = Lion(screen)
lion.run()

#pygame.quit()

If you want all in one method in class then

import pygame
import sys

# --- classes ---

class Lion():

    def __init__(self): # without `screen` as argument

        pygame.init()

        # create screen
        self.screen = pygame.display.set_mode((1000, 500))

        # get rect from screen
        self.screen_rect = self.screen.get_rect()

        self.bg_color = (230, 230, 230)

        self.image = pygame.image.load('C:/Users/yoelp/Desktop/Python Works/lion.bmp')

        self.rect = self.image.get_rect()

        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery

        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()

            self.screen.blit(self.image, self.rect)
            pygame.display.flip()

# --- main ---

lion = Lion() # without `screen` as argument


问:
Dart: cannot convert List<dynamic> to List<Map<String, dynamic>> despite cast
I am trying to parse data from a Rest API inside a Dart/Flutter application. The JSON contains a field called data at the root, which contains a list of Words. I want to get a List<Word> from this JSON. I already have the following code:

```<code>Map<String, dynamic> jsonMap = json.decode(jsonString);

List<Word> temp = jsonMap['data']
    .map((map) => map as Map<String, dynamic>)
    .map((Map<String, dynamic> map) => Word.fromJson(map)).toList(); // map to List<Word>
</code>```

Word.fromJson has the following signature:

```<code>Word.fromJson(Map<String, dynamic> json)
</code>```

The final call to map gives the following error:

```<code>type 'List<dynamic>' is not a subtype of type 'List<Map<String, dynamic>>'
</code>```

From my understanding, the call to map((map) => map as Map<String, dynamic>) should convert the List<dynamic> to a List<Map<String, dynamic>>, so I am confused as to why I get the error.

Any advice appreciated.

答:
If data is a List of words, you can "cast" to generic List and iterate each item to cast into a new Word object,

```<code>List<Word> temp = (jsonMap['data'] as List).map((itemWord) => Word.fromJson(itemWord)).toList();
</code>```

The key is String, and data is Dynamic, if jsonMap['data'] is a List on jsonString, it's not a Map<String,dynamic> and can not cast direct to map.

Sample of jsonString and convert:

```<code>final jsonString = '''
{
  "field": "titulo",
  "data": [{"teste":1},{"teste":2},{"teste":3},{"teste":4}]
}
''';

final jsonMap = json.decode(jsonString);
    List<Word> temp = (jsonMap['data'] as List)
        .map((itemWord) => Word.fromJson(itemWord))
        .toList();
</code>```

Word Class

```<code>class Word {
  int teste;

  Word({this.teste});

  Word.fromJson(Map<String, dynamic> json) {
    teste = json['teste'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['teste'] = this.teste;
    return data;
  }
}
</code>```

Generated classs using JSON to Dart
https://javiercbk.github.io/json_to_dart/

Body:
I am trying to parse data from a Rest API inside a Dart/Flutter application. The JSON contains a field called data at the root, which contains a list of Words. I want to get a List<Word> from this JSON. I already have the following code:

Map<String, dynamic> jsonMap = json.decode(jsonString);

List<Word> temp = jsonMap['data']
    .map((map) => map as Map<String, dynamic>)
    .map((Map<String, dynamic> map) => Word.fromJson(map)).toList(); // map to List<Word>

Word.fromJson has the following signature:

Word.fromJson(Map<String, dynamic> json)

The final call to map gives the following error:

type 'List<dynamic>' is not a subtype of type 'List<Map<String, dynamic>>'

From my understanding, the call to map((map) => map as Map<String, dynamic>) should convert the List<dynamic> to a List<Map<String, dynamic>>, so I am confused as to why I get the error.

Any advice appreciated.

Body:
If data is a List of words, you can "cast" to generic List and iterate each item to cast into a new Word object,

List<Word> temp = (jsonMap['data'] as List).map((itemWord) => Word.fromJson(itemWord)).toList();

The key is String, and data is Dynamic, if jsonMap['data'] is a List on jsonString, it's not a Map<String,dynamic> and can not cast direct to map.

Sample of jsonString and convert:

final jsonString = '''
{
  "field": "titulo",
  "data": [{"teste":1},{"teste":2},{"teste":3},{"teste":4}]
}
''';

final jsonMap = json.decode(jsonString);
    List<Word> temp = (jsonMap['data'] as List)
        .map((itemWord) => Word.fromJson(itemWord))
        .toList();

Word Class

class Word {
  int teste;

  Word({this.teste});

  Word.fromJson(Map<String, dynamic> json) {
    teste = json['teste'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['teste'] = this.teste;
    return data;
  }
}

Generated classs using JSON to Dart
https://javiercbk.github.io/json_to_dart/


答:
Well, I tested your code here it is working normally. However Amazon gives you a 503 code when you try to access the same link in a short time ...

```<code><html>
 <head>
  <title>
   503 - Service Unavailable Error
  </title>
 </head>
 <body bgcolor="#FFFFFF" text="#000000">
  <!--
        To discuss automated access to Amazon data please contact api-services-support@amazon.com.
        For information about migrating to our APIs refer to our Marketplace APIs at https://developer.amazonservices.in/ref=rm_5_sv, or our Product Advertising API at https://affiliate-program.amazon.in/gp/advertising/api/detail/main.html/ref=rm_5_ac for advertising use cases.
-->
  <center>
   <a href="https://www.amazon.in/ref=cs_503_logo/">
    <img alt="Amazon.in" border="0" height="45" src="https://images-eu.ssl-images-amazon.com/images/G/31/x-locale/communities/people/logo.gif" width="200"/>
   </a>
   <p align="center">
    <font face="Verdana,Arial,Helvetica">
     <font color="#CC6600" size="+2">
      <b>
       Oops!
      </b>
     </font>
     <br/>
     <b>
      It's rush hour and traffic is piling up on that page. Please try again in a short while.
      <br/>
      If you were trying to place an order, it will not have been processed at this time.
     </b>
     <p>
      <img alt="*" border="0" height="9" src="https://images-eu.ssl-images-amazon.com/images/G/02/x-locale/common/orange-arrow.gif" width="10"/>
      <b>
       <a href="https://www.amazon.in/ref=cs_503_link/">
        Go to the Amazon.in home page to continue shopping
       </a>
      </b>
     </p>
    </font>
   </p>
  </center>
 </body>
</html>
</code>```

Wait a while before you can try again, or at least test with a longer time between requests ...

Title: Receiving an error in BS4 while amazon web scraping : AttributeError: 'NoneType' object has no attribute 'get_text'

Body:
Well, I tested your code here it is working normally. However Amazon gives you a 503 code when you try to access the same link in a short time ...

<html>
 <head>
  <title>
   503 - Service Unavailable Error
  </title>
 </head>
 <body bgcolor="#FFFFFF" text="#000000">
  <!--
        To discuss automated access to Amazon data please contact api-services-support@amazon.com.
        For information about migrating to our APIs refer to our Marketplace APIs at https://developer.amazonservices.in/ref=rm_5_sv, or our Product Advertising API at https://affiliate-program.amazon.in/gp/advertising/api/detail/main.html/ref=rm_5_ac for advertising use cases.
-->
  <center>
   <a href="https://www.amazon.in/ref=cs_503_logo/">
    <img alt="Amazon.in" border="0" height="45" src="https://images-eu.ssl-images-amazon.com/images/G/31/x-locale/communities/people/logo.gif" width="200"/>
   </a>
   <p align="center">
    <font face="Verdana,Arial,Helvetica">
     <font color="#CC6600" size="+2">
      <b>
       Oops!
      </b>
     </font>
     <br/>
     <b>
      It's rush hour and traffic is piling up on that page. Please try again in a short while.
      <br/>
      If you were trying to place an order, it will not have been processed at this time.
     </b>
     <p>
      <img alt="*" border="0" height="9" src="https://images-eu.ssl-images-amazon.com/images/G/02/x-locale/common/orange-arrow.gif" width="10"/>
      <b>
       <a href="https://www.amazon.in/ref=cs_503_link/">
        Go to the Amazon.in home page to continue shopping
       </a>
      </b>
     </p>
    </font>
   </p>
  </center>
 </body>
</html>

Wait a while before you can try again, or at least test with a longer time between requests ...


问:
Is there a way to prevent a query from setting the serial primary key?
I've got a bunch of tables with the 'serial' keyword on a primary key so that auto-increment will work. The problem is that I can make a query to insert a row using any id number which overrides the auto-increment. Is there a reason for this? Or, is there a way to prevent a user from adding/changing this value?

Here's an example of my table config:

```<code>create table if not exists departments (
    department_id serial primary key,
    name varchar(64) not null unique
);
</code>```

if I run the following query, I can add any number to primary key:

```<code>insert into departments (department_id, name) values (9001, 'FooBar')
</code>```

I think I want to prevent this from happening. I'd like to get some opinions.

答:
I'm using Microsoft sql server and you can control the insert of value in identity column by below sql command

SET IDENTITY_INSERT [ [ database_name . ] schema_name . ] table_name { ON | OFF }

By setting it to 'OFF' you cannot insert a value in identity column.

For more info refer: https://learn.microsoft.com/en-us/sql/t-sql/statements/set-identity-insert-transact-sql?view=sql-server-ver15

Body:
I've got a bunch of tables with the 'serial' keyword on a primary key so that auto-increment will work. The problem is that I can make a query to insert a row using any id number which overrides the auto-increment. Is there a reason for this? Or, is there a way to prevent a user from adding/changing this value?

Here's an example of my table config:

create table if not exists departments (
    department_id serial primary key,
    name varchar(64) not null unique
);

if I run the following query, I can add any number to primary key:

insert into departments (department_id, name) values (9001, 'FooBar')

I think I want to prevent this from happening. I'd like to get some opinions.


问:
Logic App Using Filter Query in Get Entities Action
I am new to logic app and try to build and logic app to check the records in Azure table. The PartitionKey is a string type of DateTime.utcNow().Ticks. I want to write a filter query to filter the records whose PartitionKey is less than or equals to current DateTime. My effort is shown in the screenshot:

It keeps telling me the expression is invalid. Can anyone give me some hints to write the correct query for my purpose? Many thanks. I am not sure why this expression is invalid.

答:
Thanks for George's hint, I just need to add single quote rather than using the string(). This will help me convert the ticks value to string so that I can compare it with the PartitionKey field.

In this way, it performs the same as this table query for me:

```<code>string currentDateTime = DateTime.UtcNow.Ticks.ToString();
TableQuery<EmailTableEntity> rangeQuery =
                                new TableQuery<EmailTableEntity>()
                                .Where(TableQuery.GenerateFilterCondition
                                ("PartitionKey", QueryComparisons.LessThanOrEqual, currentDateTime));
</code>```

Body:
Thanks for George's hint, I just need to add single quote rather than using the string(). This will help me convert the ticks value to string so that I can compare it with the PartitionKey field.

In this way, it performs the same as this table query for me:

string currentDateTime = DateTime.UtcNow.Ticks.ToString();
TableQuery<EmailTableEntity> rangeQuery =
                                new TableQuery<EmailTableEntity>()
                                .Where(TableQuery.GenerateFilterCondition
                                ("PartitionKey", QueryComparisons.LessThanOrEqual, currentDateTime));


问:
BCP in SQL Server 2008 : can not find stored procedure 'sp_describe_first_result_set'
My .bcp file was out from SQL Server 2016.

When I attempted bcp in SQL Server 2008 R2, an error occurred:

SQLState = 37000, NativeError = 2812

  Error = [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Could not find stored procedure 'sp_describe_first_result_set'

Can anyone give me some idea?

答:
I changed my location to bcp.exe at version 110 and ran ok</p>

```<code>cd  C:\Program Files\Microsoft SQL Server\110\Tools\Binn
cp <commands>
</code>```

Body:
I changed my location to bcp.exe at version 110 and ran ok

cd  C:\Program Files\Microsoft SQL Server\110\Tools\Binn
cp <commands>


问:
Remove a element from List of objects based on inner object list value in java
How can I remove the element from the list if some inner list attribute value fails to meet the condition.The trick here is that attribute is itself a list and comparison is based on some attribute of that inner list. Please refer the below sample and help out to fill the comment section in code:

Object :

```<code>Class product{
 private String productId;
 private String productName;
 private List<Attribute> attributeList;

    public static class Attribute{
        private Long attributeId;
    }
}
</code>```

Driver class :

```<code>Class Driver{
   List<product> productList = new ArrayList<product>();
   /*
   Remove the object from productList if attributeList doesn't contain attribute with attributeId = x;
*/
}
</code>```

答:
What you can do it to stream over original list, and leave only objects which satisfy the condition. It might look something like this:

```<code>List<Product> filtered = productList.stream()
      .filter( p -> p.attributeList().stream().anyMatch( a -> a.attributeId.equals(x))
      .collect(Collectors.toList())
</code>```

in this live we are actually checking if nested list contains at least one object with attributeId = x
p.attributeList().stream().anyMatch( a -> a.attributeId.equals(x)

Body:
How can I remove the element from the list if some inner list attribute value fails to meet the condition.The trick here is that attribute is itself a list and comparison is based on some attribute of that inner list. Please refer the below sample and help out to fill the comment section in code:

Object :

Class product{
 private String productId;
 private String productName;
 private List<Attribute> attributeList;

    public static class Attribute{
        private Long attributeId;
    }
}

Driver class :

Class Driver{
   List<product> productList = new ArrayList<product>();
   /*
   Remove the object from productList if attributeList doesn't contain attribute with attributeId = x;
*/
}

Body:
What you can do it to stream over original list, and leave only objects which satisfy the condition. It might look something like this:

List<Product> filtered = productList.stream()
      .filter( p -> p.attributeList().stream().anyMatch( a -> a.attributeId.equals(x))
      .collect(Collectors.toList())

in this live we are actually checking if nested list contains at least one object with attributeId = x
p.attributeList().stream().anyMatch( a -> a.attributeId.equals(x)


问:
How to update a notification scheduled in Azure Notification Hub?
Well, there is a scenario where I have to schedule the notification on azure notification hub using .net SDK.

This notification can be updated/cancelled before the schedule.

.Net SDK has a method CancelNotificationAsync to cancel the schedule, but how can I update it? Should I have to cancel and create another scheduled notification?

答:
You are right.

There is no way to update a scheduled notification. You would simply have to cancel it and resubmit it anew.