问:
mule code to add list in dataweave mule
I am trying to pull physical and mailing address from a JSON file. I am able to retrieve them separately but not able to merge them in the dataweave. The below dataweave code will provide physical address and mailing address list, but I want the one address list which contains both physical and mailing address.

Below is the dataweave code used:

```<code>    physicaladdress: payload01.attributes.PhysicalAddress map ((physicalAddress , indexOfPhysicalAddress) -> {
type: physicalAddress.value.AddressType.value ,
lineOne: physicalAddress.value.AddressLine1[0].value as :string ,
lineTwo: physicalAddress.value.AddressLine2[0].value as :string,
country: physicalAddress.value.Country[0].value as :string
}) when payload01.attributes.PhysicalAddress != null  otherwise null,
    mailingaddress: payload01.attributes.MailingAddress map ((mailingAddress , indexOfMailingAddress) -> {
type: mailingAddress.value.AddressType.value ,
lineOne: mailingAddress.value.AddressLine1[0].value as :string,
lineTwo: mailingAddress.value.AddressLine2[0].value as :string ,
country: mailingAddress.value.Country[0].value as :string
}) when payload01.attributes.MailingAddress != null otherwise null,
</code>```

Any help is greatly appreciated...

Current response using the dataweave code attached:

```<code>    "physicaladdress": [
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  }
],
"mailingaddress": [
  {
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  }
]
</code>```

Expected response:

```<code>    "address": [
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
{
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  }
]
</code>```

If i change the dataweave code to the one below, I will get only mailing address, think mailing address is overriding the physical address:

```<code>    address: payload01.attributes.PhysicalAddress map ((physicalAddress , indexOfPhysicalAddress) -> {
type: physicalAddress.value.AddressType.value ,
lineOne: physicalAddress.value.AddressLine1[0].value as :string ,
lineTwo: physicalAddress.value.AddressLine2[0].value as :string,
country: physicalAddress.value.Country[0].value as :string
}) when payload01.attributes.PhysicalAddress != null  otherwise null,
    address: payload01.attributes.MailingAddress map ((mailingAddress , indexOfMailingAddress) -> {
type: mailingAddress.value.AddressType.value ,
lineOne: mailingAddress.value.AddressLine1[0].value as :string,
lineTwo: mailingAddress.value.AddressLine2[0].value as :string ,
country: mailingAddress.value.Country[0].value as :string
}) when payload01.attributes.MailingAddress != null otherwise null,
</code>```

I am looking for address having both the list (physical and mailing) example attached, for reference.

答:
See if this can help you :</p>

```<code>Sample Input :

{

"physicaladdressList" : [
            "physicaladdress" : {
                "type":  "01" ,
                "lineOne": " 1st Address Line1(P)",
                "lineTwo": " 1st Address Line2 (P)",
                "country": "INDIA"
             },
         "physicaladdress" :{
            "type":  "02" ,
            "lineOne": "2nd Address Line1(P)",
            "lineTwo": "2nd Address Line2(P)",
            "country": "INDIA"
         },
          "physicaladdress" : {
            "type":  "03" ,
            "lineOne": "3rd Address Line1(P)",
            "lineTwo": "3rd Address Line2(P)",
            "country": "INDIA"
         }
 ],
 "mailingaddressList" : [
          "mailingaddress" :{
                "type":  "04" ,
                "lineOne": "1st Address Line1(M)",
                "lineTwo": "1st Address Line2(M)",
                "country": "INDIA"
             },
         "mailingaddress" : {
            "type":  "05" ,
            "lineOne": "2nd Address Line1(M)",
            "lineTwo": "2nd Address Line2(M)",
            "country": "INDIA"
         },
         "mailingaddress" : {
            "type":  "06" ,
            "lineOne": "3rd Address Line1(M)",
            "lineTwo": "3rd Address Line2(M)",
            "country": "INDIA"
         }]

 }

===============DataWeave===============================
%dw 1.0
%input payload application/json
%output application/json
%var phydata = payload.physicaladdressList.physicaladdress
%var mailddata = payload.mailingaddressList.mailingaddress
%var b = sizeOf (payload.physicaladdressList.physicaladdress)
%var a = 0
%var c= b - 1
---
   [[a][0] .. [c][0]] map {
        Address :
      {
          PhysicalAddress:
            {
                "Type" : phydata[$][0].type,
                "AddressLine1" : phydata[$][1].lineOne,
                "AddressLine2" : phydata[$][2].lineTwo,
                "Country" : phydata[$][3].country
            },
            MailingAddress:
            {
                "Type" : mailddata[$][0].type,
                "AddressLine1" : mailddata[$][1].lineOne,
                "AddressLine2" : mailddata[$][2].lineTwo,
                "Country" : mailddata[$][3].country
            }

       }
          }

==========OutPut============================
[
  {
    "Address": {
      "PhysicalAddress": {
        "Type": "01",
        "AddressLine1": " 1st Address Line1(P)",
        "AddressLine2": " 1st Address Line2 (P)",
        "Country": "INDIA"
      },
      "MailingAddress": {
        "Type": "04",
        "AddressLine1": "1st Address Line1(M)",
        "AddressLine2": "1st Address Line2(M)",
        "Country": "INDIA"
      }
    }
  },
  {
    "Address": {
      "PhysicalAddress": {
        "Type": "02",
        "AddressLine1": "2nd Address Line1(P)",
        "AddressLine2": "2nd Address Line2(P)",
        "Country": "INDIA"
      },
      "MailingAddress": {
        "Type": "05",
        "AddressLine1": "2nd Address Line1(M)",
        "AddressLine2": "2nd Address Line2(M)",
        "Country": "INDIA"
      }
    }
  },
  {
    "Address": {
      "PhysicalAddress": {
        "Type": "03",
        "AddressLine1": "3rd Address Line1(P)",
        "AddressLine2": "3rd Address Line2(P)",
        "Country": "INDIA"
      },
      "MailingAddress": {
        "Type": "06",
        "AddressLine1": "3rd Address Line1(M)",
        "AddressLine2": "3rd Address Line2(M)",
        "Country": "INDIA"
      }
    }
  }
]
</code>```

Title: mule code to add list in dataweave mule

Body:
I am trying to pull physical and mailing address from a JSON file. I am able to retrieve them separately but not able to merge them in the dataweave. The below dataweave code will provide physical address and mailing address list, but I want the one address list which contains both physical and mailing address.

Below is the dataweave code used:

    physicaladdress: payload01.attributes.PhysicalAddress map ((physicalAddress , indexOfPhysicalAddress) -> {
type: physicalAddress.value.AddressType.value ,
lineOne: physicalAddress.value.AddressLine1[0].value as :string ,
lineTwo: physicalAddress.value.AddressLine2[0].value as :string,
country: physicalAddress.value.Country[0].value as :string
}) when payload01.attributes.PhysicalAddress != null  otherwise null,
    mailingaddress: payload01.attributes.MailingAddress map ((mailingAddress , indexOfMailingAddress) -> {
type: mailingAddress.value.AddressType.value ,
lineOne: mailingAddress.value.AddressLine1[0].value as :string,
lineTwo: mailingAddress.value.AddressLine2[0].value as :string ,
country: mailingAddress.value.Country[0].value as :string
}) when payload01.attributes.MailingAddress != null otherwise null,

Any help is greatly appreciated...

Current response using the dataweave code attached:

    "physicaladdress": [
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  }
],
"mailingaddress": [
  {
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  }
]

Expected response:

    "address": [
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Physical",
    "addressLine1": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
{
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310-310 Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  },
  {
    "type": "Mailing",
    "lineOne": "1166 Quail Ct Ste 310",
    "cityName": "Pewaukee",
    "country": "United States"
  }
]

If i change the dataweave code to the one below, I will get only mailing address, think mailing address is overriding the physical address:

    address: payload01.attributes.PhysicalAddress map ((physicalAddress , indexOfPhysicalAddress) -> {
type: physicalAddress.value.AddressType.value ,
lineOne: physicalAddress.value.AddressLine1[0].value as :string ,
lineTwo: physicalAddress.value.AddressLine2[0].value as :string,
country: physicalAddress.value.Country[0].value as :string
}) when payload01.attributes.PhysicalAddress != null  otherwise null,
    address: payload01.attributes.MailingAddress map ((mailingAddress , indexOfMailingAddress) -> {
type: mailingAddress.value.AddressType.value ,
lineOne: mailingAddress.value.AddressLine1[0].value as :string,
lineTwo: mailingAddress.value.AddressLine2[0].value as :string ,
country: mailingAddress.value.Country[0].value as :string
}) when payload01.attributes.MailingAddress != null otherwise null,

I am looking for address having both the list (physical and mailing) example attached, for reference.

Body:
See if this can help you :

Sample Input :

{

"physicaladdressList" : [
            "physicaladdress" : {
                "type":  "01" ,
                "lineOne": " 1st Address Line1(P)",
                "lineTwo": " 1st Address Line2 (P)",
                "country": "INDIA"
             },
         "physicaladdress" :{
            "type":  "02" ,
            "lineOne": "2nd Address Line1(P)",
            "lineTwo": "2nd Address Line2(P)",
            "country": "INDIA"
         },
          "physicaladdress" : {
            "type":  "03" ,
            "lineOne": "3rd Address Line1(P)",
            "lineTwo": "3rd Address Line2(P)",
            "country": "INDIA"
         }
 ],
 "mailingaddressList" : [
          "mailingaddress" :{
                "type":  "04" ,
                "lineOne": "1st Address Line1(M)",
                "lineTwo": "1st Address Line2(M)",
                "country": "INDIA"
             },
         "mailingaddress" : {
            "type":  "05" ,
            "lineOne": "2nd Address Line1(M)",
            "lineTwo": "2nd Address Line2(M)",
            "country": "INDIA"
         },
         "mailingaddress" : {
            "type":  "06" ,
            "lineOne": "3rd Address Line1(M)",
            "lineTwo": "3rd Address Line2(M)",
            "country": "INDIA"
         }]

 }

===============DataWeave===============================
%dw 1.0
%input payload application/json
%output application/json
%var phydata = payload.physicaladdressList.physicaladdress
%var mailddata = payload.mailingaddressList.mailingaddress
%var b = sizeOf (payload.physicaladdressList.physicaladdress)
%var a = 0
%var c= b - 1
---
   [[a][0] .. [c][0]] map {
        Address :
      {
          PhysicalAddress:
            {
                "Type" : phydata[$][0].type,
                "AddressLine1" : phydata[$][1].lineOne,
                "AddressLine2" : phydata[$][2].lineTwo,
                "Country" : phydata[$][3].country
            },
            MailingAddress:
            {
                "Type" : mailddata[$][0].type,
                "AddressLine1" : mailddata[$][1].lineOne,
                "AddressLine2" : mailddata[$][2].lineTwo,
                "Country" : mailddata[$][3].country
            }

       }
          }

==========OutPut============================
[
  {
    "Address": {
      "PhysicalAddress": {
        "Type": "01",
        "AddressLine1": " 1st Address Line1(P)",
        "AddressLine2": " 1st Address Line2 (P)",
        "Country": "INDIA"
      },
      "MailingAddress": {
        "Type": "04",
        "AddressLine1": "1st Address Line1(M)",
        "AddressLine2": "1st Address Line2(M)",
        "Country": "INDIA"
      }
    }
  },
  {
    "Address": {
      "PhysicalAddress": {
        "Type": "02",
        "AddressLine1": "2nd Address Line1(P)",
        "AddressLine2": "2nd Address Line2(P)",
        "Country": "INDIA"
      },
      "MailingAddress": {
        "Type": "05",
        "AddressLine1": "2nd Address Line1(M)",
        "AddressLine2": "2nd Address Line2(M)",
        "Country": "INDIA"
      }
    }
  },
  {
    "Address": {
      "PhysicalAddress": {
        "Type": "03",
        "AddressLine1": "3rd Address Line1(P)",
        "AddressLine2": "3rd Address Line2(P)",
        "Country": "INDIA"
      },
      "MailingAddress": {
        "Type": "06",
        "AddressLine1": "3rd Address Line1(M)",
        "AddressLine2": "3rd Address Line2(M)",
        "Country": "INDIA"
      }
    }
  }
]


来源: stackexchange

问:
How to implement an onboarding page with Prism.Forms?
I am developing a Xamarin.Forms app with Prism in which I'd like to incorporate an onboarding page (more specific a top user benefits page, following the Material Design guidelines).

The app itself is structured around a NavigationPage to which I navigate with

```<code>NavigationService.NavigateAsync("/NavigationRootPage/MainPage")
</code>```

in my App(). On the first start I'd like to show the onboarding page instead and I am having quite some issues getting it right.

My first approach was to navigate to MainPage with

```<code>_navigationService.NavigateAsync("/NavigationRootPage/MainPage")
</code>```

from my viewmodel, when the user clicks the Get Started! button. This kind of worked by is also kind of ugly, since this absolute navigation will destroy the oboarding page immediately and not animate the transition. Furthermore at the moment the oboarding page is destroyed, the MainPage will be built, which will take a small, but noticeable, amount of time. In effect the user will notice the MainPage being built up, which does not look smooth at all.

My second approach was to navigate in a relative fashion from my viewmodel.

```<code>_navigationService.NavigateAsync("NavigationRootPage/MainPage")
</code>```

This works way smoother, with the transition animation and after the animation is done, the MainPage is already ready to go. But again there is a major drawback. You can navigate back to the onbaording page, which we dont't want neither. And - to my knowledge - there is no (clean) way to remove the page from the navigation stack, too. I tried calling PageUtility.DestroyPage on my onboarding page, but this only worsened things, since it seemed to keep the page, but destroy the viewmodel, resulting in my onboarding page being shown without data when pushing the back button.

My third approach did not work at all, although it seemed promising to me. In my App() I pushed my navigation page with the main page then then my onboarding page modal

```<code>NavigationService.NavigateAsync("/NavigationRootPage/MainPage");
NavigationService.NavigateAsync("OnboardingPage", useModalNavigation: true);
</code>```

and then in my viewmodel

```<code>_navigationService.GoBackAsync(useModalNavigation: true)
</code>```

but this approach

showed the header of the NavigationPage although the onbaording page was supposed to be shown as a modal

refused to GoBackAsync - when calling this method, nothing happens

waiting for the first call to NavigateAsync did not change anything either.

Some other things I've tried

Implemented INavigationOptions in my viewmodel with ClearNavigationStackOnNavigation being true

Tried setting Application.MainPage after my NavigationPage was shown, but to no avail

I would have believed that this was king of a common requirement when programming an app. Is there something I've missed? Or will I have to live with one of those drawbacks?

答:
I have found a solution, which is not the most beautiful one (it is actually quite ugly) but working.

In my MainPages viewmodel I implemented INavigatingAware and navigated to my OnboardingPage modally

```<code>public async void OnNavigatingTo(NavigationParameters parameters)
{
    await _navigationService.NavigateAsync("LandingPage", useModalNavigation: true);
}
</code>```

However, removing the moal page with

```<code>this._navigationService.GoBackAsync(useModalNavigation: true);
</code>```

does not work as expected. The modal is not removed (although it should work this way from looking at the code, but I did not manage to debug with Re# generated PDBs). Hence I had to go the ugly (non-MVVM) way and create an event handler for Button.Click and remove the modal manually

```<code>private void Button_OnClicked(object sender, EventArgs e)
{
    this.Navigation.PopModalAsync();
}
</code>```

This will return to my MainPage smoothly with an animation and my MainPageis already up and running without being built up while already visible.

Still, I'd appreciate an answer on how to do it the Prism way.

ContentLicense: CC BY-SA 3.0

Body:
I am developing a Xamarin.Forms app with Prism in which I'd like to incorporate an onboarding page (more specific a top user benefits page, following the Material Design guidelines).

The app itself is structured around a NavigationPage to which I navigate with

NavigationService.NavigateAsync("/NavigationRootPage/MainPage")

in my App(). On the first start I'd like to show the onboarding page instead and I am having quite some issues getting it right.

My first approach was to navigate to MainPage with

_navigationService.NavigateAsync("/NavigationRootPage/MainPage")

from my viewmodel, when the user clicks the Get Started! button. This kind of worked by is also kind of ugly, since this absolute navigation will destroy the oboarding page immediately and not animate the transition. Furthermore at the moment the oboarding page is destroyed, the MainPage will be built, which will take a small, but noticeable, amount of time. In effect the user will notice the MainPage being built up, which does not look smooth at all.

My second approach was to navigate in a relative fashion from my viewmodel.

_navigationService.NavigateAsync("NavigationRootPage/MainPage")

This works way smoother, with the transition animation and after the animation is done, the MainPage is already ready to go. But again there is a major drawback. You can navigate back to the onbaording page, which we dont't want neither. And - to my knowledge - there is no (clean) way to remove the page from the navigation stack, too. I tried calling PageUtility.DestroyPage on my onboarding page, but this only worsened things, since it seemed to keep the page, but destroy the viewmodel, resulting in my onboarding page being shown without data when pushing the back button.

My third approach did not work at all, although it seemed promising to me. In my App() I pushed my navigation page with the main page then then my onboarding page modal

NavigationService.NavigateAsync("/NavigationRootPage/MainPage");
NavigationService.NavigateAsync("OnboardingPage", useModalNavigation: true);

and then in my viewmodel

_navigationService.GoBackAsync(useModalNavigation: true)

but this approach

showed the header of the NavigationPage although the onbaording page was supposed to be shown as a modal

refused to GoBackAsync - when calling this method, nothing happens

waiting for the first call to NavigateAsync did not change anything either.

Some other things I've tried

Implemented INavigationOptions in my viewmodel with ClearNavigationStackOnNavigation being true

Tried setting Application.MainPage after my NavigationPage was shown, but to no avail

I would have believed that this was king of a common requirement when programming an app. Is there something I've missed? Or will I have to live with one of those drawbacks?

Body:
I have found a solution, which is not the most beautiful one (it is actually quite ugly) but working.

In my MainPages viewmodel I implemented INavigatingAware and navigated to my OnboardingPage modally

public async void OnNavigatingTo(NavigationParameters parameters)
{
    await _navigationService.NavigateAsync("LandingPage", useModalNavigation: true);
}

However, removing the moal page with

this._navigationService.GoBackAsync(useModalNavigation: true);

does not work as expected. The modal is not removed (although it should work this way from looking at the code, but I did not manage to debug with Re# generated PDBs). Hence I had to go the ugly (non-MVVM) way and create an event handler for Button.Click and remove the modal manually

private void Button_OnClicked(object sender, EventArgs e)
{
    this.Navigation.PopModalAsync();
}

This will return to my MainPage smoothly with an animation and my MainPageis already up and running without being built up while already visible.

Still, I'd appreciate an answer on how to do it the Prism way.


问:
Python - Log Transformation on variables using numpy
I am working on feature engineering process as part of a machine learning project. And currently I have to determine whether to do log transformation for certain columns or not.

I came to know that log transformation should be done on those columns which are having skew distribution of values.

Now here are my questions / doubts for which I need clarifications.

How do I determine in Python whether a particular column values belong to skew distributions(either right skew or left skew) ?

And assume that I have determined the columns over which I need to apply log transformation, there are many bases to the log function such as loge, log10, log2, etc... So do I use natural log (i.e) loge or log10 or anything else in this machine learning approach ?

And if I am not wrong, log transformation can be applied only on numeric variables. Is this right ?

答:
to measure the skew you can use scipy.stats.skew or scipy.stats.skewtest

You can also use scipy.stats.lognorm.fit() to get the parameters for the lognormal distribution


问:
How to get variable passed from input box to another page
I am trying to get a variable from hidden INPUT text box to another page. I created a search.asp page, when I search a Form from this page, clicked search button, then view.asp page will open with that specific Form ID. On View.asp page, I created a link to open a new page called view2.asp that keeps the same Form ID. But it didn't work. Can you please help? Thanks.

view.asp code

```<code><%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Menus Search</title>

</head>
<body>

<style>
table, td, th {
    border: 1px solid #ddd;
}
th, td {
    padding: 3px;
}
</style>
</head>
<body>
<!--#include file="openConn.asp" -->

<%
SET objRS = Server.CreateObject("ADODB.Recordset")
SET objRS1 = Server.CreateObject("ADODB.Recordset")
SET objRS2 = Server.CreateObject("ADODB.Recordset")
SET objRS3 = Server.CreateObject("ADODB.Recordset")

If Request.Form("FormSource") = "SubmitForm" Then

    For j = 1 to Request.Form("txtCount")-1
        strReport   = Request.Form("Report[" & j &"]")

        strValue    = split(strReport,"$")
        sMenuID     = strValue(0)
        sCategoryID = strValue(1)
        sStatus     = strValue(2)

'response.write strReport  & "::" & sMenuID & "::"  & sCategoryID & "::"  & sStatus & "<br>"
'response.end
        sFormID     = Request.Form("FormID")

        sSQL =  "INSERT INTO Report (FormID, MenuID, CategoryID, Status) VALUES " &_
                "('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "');"
            objConn.Execute(sSQL)
    Next
End If
%>

<form action="" method="post" id="newMenu" name="frmReport"  onsubmit="return validateForm(this)">
<p>
<%
'''' RR added today
nFormID= Request("FormID") ''Request.Form("SearchObj")
response.write "FormID: " & nFormID & "<br>"

sSQL2 = "SELECT * FROM Form WHERE Formid = " & nFormID
''response.write "SQL:::: " & sSQL2 & "<br>"

    objRS2.Open sSQL2, objConn
    'response.Write sSQL2
    Do Until objRS2.EOF
        sFormName = objRS2("Form_Name")
%>
<h2><%= objRS2("Form_Name") %></h2>
<p><a href="#" onclick="openview2.asp();"/>Click me</a></p>
    <input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />
<%
    objRS2.MoveNext
    Loop
    objRS2.Close
%>

<p>
<table>
<thead bgcolor="#336666" style="color:#FFFFFF">
    <tr>

        <td>Trainer Name:</td>
        <td>Pass</td>
        <td>Fail</td>
        <td>NA</td>
        <td>Not taken</td>
    </tr>
</thead>
<%
currMenu = ""
sSQL =  "SELECT MenuID, Menu_Name FROM Menu where MENUID in (SELECT MENUID FROM Category where formid=" & nFormID & ")"

    objRS.Open sSQL, objConn
    i=1
    While Not objRS.EOF
        nMenuID     = objRS("MenuID")
        sMenuName   = objRS("Menu_Name")
        If currMenu <> sMenuName Then
            currMenu = sMenuName
            %>
            <tr>
                <th bgcolor="#CCCCCC"><%= sMenuName %></th>
            </tr>
                <input type="hidden" name="MenuID" value="<%=nMenuID%>">
        <%
        End If
        sSQL3 = "SELECT Categoryid, Category_Name FROM Category WHERE MenuID = " & nMenuID & " and FormID=" &  nFormID
            Set objRS3 = Server.CreateObject("ADODB.Recordset")
            objRS3.Open sSQL3, objConn
            While Not objRS3.EOF
                nCategoryID     = objRS3("Categoryid")
                sCategoryName   = objRS3("Category_Name")
        %>
            <tr>
                <td><%= sCategoryName %></td>
                <input type="hidden" name="CategoryID" value="<%=nCategoryID%>">
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1"></td>
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2"></td>
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$3"></td>
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$4"></td>
            </tr>
            <%
            objRS3.MoveNext
            i = i + 1
            Wend
            objRS3.Close
        objRS.MoveNext
    Wend
    objRS.Close
%>
</table>
</p>

<p>
<input type="hidden" name="txtCount" value="<%= i %>">
<input type="button" value="Create Menu" onclick="openwin();" />
<input type="hidden" name="FormSource" value="SubmitForm">
<input type="button" value="View2" onclick="openview2();" />
<input type="submit" value="Update">
<a href="search.asp">Go To Search</a>
</p>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" ></script>
<script type="text/javascript">
function validateForm(daForm) {
nCount = document.frmReport.txtCount.value;

    // check all rb radio buttons
    for (var i = 1; i < nCount; i++) {
        if (! getCheckedRadioValue(daForm["Report"+i])) {
            alert ("Please select a value for option " + i)
            return false
        }
    }
    // add other checks here...
    return true
}
function getCheckedRadioValue(radio) {
    for (var i=0; i < radio.length; i++) {
        if (radio[i].checked) return radio[i].value
    }
    return false
}
function openwin()
{
    //alert($('#idFormName').val());
    //window.location.href = "Create.asp?FormID=" + $('#idFormName').val();

    window.open("Create.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");

}
function openView2()
{
alert($('#idFormName').val());
    window.open("view2.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");
}
</script>
</body>
</html>
</code>```

view2.asp

```<code><%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Menus Search</title>

</head>
<body>

<style>
table, td, th {
    border: 1px solid #ddd;
}
th, td {
    padding: 3px;
}
</style>
</head>
<body>
<!--#include file="openConn.asp" -->

<%
SET objRS = Server.CreateObject("ADODB.Recordset")
SET objRS1 = Server.CreateObject("ADODB.Recordset")
SET objRS2 = Server.CreateObject("ADODB.Recordset")
SET objRS3 = Server.CreateObject("ADODB.Recordset")

If Request("FormID")="" then
    iFormID =0
Else
    iFormID = Request("FormID") ''Request.Form("FormID")
End If

If Request.Form("FormSource") = "SubmitForm" Then

    For j = 1 to Request.Form("txtCount")-1
        strReport   = Request.Form("Report[" & j &"]")

        strValue    = split(strReport,"$")
        sMenuID     = strValue(0)
        sCategoryID = strValue(1)
        sStatus     = strValue(2)

'response.write strReport  & "::" & sMenuID & "::"  & sCategoryID & "::"  & sStatus & "<br>"
'response.end
        sFormID     = Request.Form("FormID")

        sSQL =  "INSERT INTO Report (FormID, MenuID, CategoryID, Status) VALUES " &_
                "('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "');"
            objConn.Execute(sSQL)
    Next
End If
%>

<form action="" method="post" id="newMenu" name="frmReport"  onsubmit="return validateForm(this)">
<p>
<%
'''' RR added today
nFormID= Request("FormID") ''Request.Form("SearchObj")
response.write "FormID: " & nFormID & "<br>"

sSQL2 = "SELECT * FROM Form WHERE Formid = " & nFormID
''response.write "SQL:::: " & sSQL2 & "<br>"

    objRS2.Open sSQL2, objConn
    'response.Write sSQL2
    Do Until objRS2.EOF
        sFormName = objRS2("Form_Name")
%>
<h2><%= objRS2("Form_Name") %></h2>
    <input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />
<%
    objRS2.MoveNext
    Loop
    objRS2.Close
%>

<p>
<table>
<thead bgcolor="#336666" style="color:#FFFFFF">
    <tr>

        <td>Trainer Name:</td>
        <td>Pass</td>
        <td>Fail</td>
        <td>NA</td>
        <td>Not taken</td>
    </tr>
</thead>
<%
currMenu = ""
sSQL =  "SELECT MenuID, Menu_Name FROM Menu where MENUID in (SELECT MENUID FROM Category where formid=" & nFormID & ")"

    objRS.Open sSQL, objConn
    i=1
    While Not objRS.EOF
        nMenuID     = objRS("MenuID")
        sMenuName   = objRS("Menu_Name")
        If currMenu <> sMenuName Then
            currMenu = sMenuName
            %>
            <tr>
                <th bgcolor="#CCCCCC"><%= sMenuName %></th>
            </tr>
                <input type="hidden" name="MenuID" value="<%=nMenuID%>">
        <%
        End If
        sSQL3 = "SELECT Categoryid, Category_Name FROM Category WHERE MenuID = " & nMenuID & " and FormID=" &  nFormID
            Set objRS3 = Server.CreateObject("ADODB.Recordset")
            objRS3.Open sSQL3, objConn
            While Not objRS3.EOF
                nCategoryID     = objRS3("Categoryid")
                sCategoryName   = objRS3("Category_Name")
        %>
            <tr>
                <td><%= sCategoryName %></td>
                <input type="hidden" name="CategoryID" value="<%=nCategoryID%>">
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1"></td>
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2"></td>
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$3"></td>
                <td align="center"><input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$4"></td>
            </tr>
            <%
            objRS3.MoveNext
            i = i + 1
            Wend
            objRS3.Close
        objRS.MoveNext
    Wend
    objRS.Close
%>
</table>
</p>

<p>
<input type="hidden" name="txtCount" value="<%= i %>">
<input type="button" value="Create Menu" onclick="openwin();" />
<input type="hidden" name="FormSource" value="SubmitForm">

<input type="submit" value="Update">
<a href="search.asp">Go To Search</a>
</p>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" ></script>
<script type="text/javascript">
function validateForm(daForm) {
nCount = document.frmReport.txtCount.value;

    // check all rb radio buttons
    for (var i = 1; i < nCount; i++) {
        if (! getCheckedRadioValue(daForm["Report"+i])) {
            alert ("Please select a value for option " + i)
            return false
        }
    }
    // add other checks here...
    return true
}
function getCheckedRadioValue(radio) {
    for (var i=0; i < radio.length; i++) {
        if (radio[i].checked) return radio[i].value
    }
    return false
}
</script>
</body>
</html>
</code>```

答:
It's hard to understand what you are trying to do.

But as I could understand, you want to open view2.asp and be able to have a value from view.asp there.

As I can see you open view2.asp with this line

```<code><input type="button" value="View2" onclick="openview2();" />
</code>```

And you want this hidden input

```<code><input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2('FormID') %>">
</code>```

If this is what you are trying to do. Then your naming is wrong with the javascript. You probably copied and forgot to change name.

See here, where you try to open view2.asp

```<code>function openwin()
{
    window.openView2("view2.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");
}
</code>```

You need to change openwin() to openview2()

EDIT:

I just also saw you have this strange code

```<code><a href="#" onclick="openview2.asp();"/>Click me</a>
</code>```

Which is a link to it self, because you have href="#". But you also trying to call a javascript function with this onclick="openview2.asp();".

You do not have a function called openview2.asp(). And this is not how it works.
If you are trying to call view2.asp with this link and pass the hidden input idFormName. Then it's better if you just do a correct link and pass the ID in the url.
I must say it's a very bad solution, because there is no security here. But the code you provided shows that you are only after a function and ignoring any security aspect.

So change this

```<code><h2><%= objRS2("Form_Name") %></h2>
<p><a href="#" onclick="openview2.asp();"/>Click me</a></p>
    <input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />
</code>```

for this

```<code><h2><%= objRS2("Form_Name") %></h2>
<p><a href="view2.asp?idFormName=<%= objRS2("FormID") %>" />Click me</a></p>
    <input type="hidden" id="idFormName" name="FormID" value="<%= objRS2("FormID") %>"><br />
</code>```

I'm leaving the hidden there in case you refer to this somewhere else in your code.

Good luck and Have a nice day!

Body:
I am trying to get a variable from hidden INPUT text box to another page. I created a search.asp page, when I search a Form from this page, clicked search button, then view.asp page will open with that specific Form ID. On View.asp page, I created a link to open a new page called view2.asp that keeps the same Form ID. But it didn't work. Can you please help? Thanks.

view.asp code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Menus Search</title>

<%
SET objRS = Server.CreateObject("ADODB.Recordset")
SET objRS1 = Server.CreateObject("ADODB.Recordset")
SET objRS2 = Server.CreateObject("ADODB.Recordset")
SET objRS3 = Server.CreateObject("ADODB.Recordset")

If Request.Form("FormSource") = "SubmitForm" Then

    For j = 1 to Request.Form("txtCount")-1
        strReport   = Request.Form("Report[" & j &"]")

        strValue    = split(strReport,"$")
        sMenuID     = strValue(0)
        sCategoryID = strValue(1)
        sStatus     = strValue(2)

'response.write strReport  & "::" & sMenuID & "::"  & sCategoryID & "::"  & sStatus & "
"
'response.end
        sFormID     = Request.Form("FormID")

        sSQL =  "INSERT INTO Report (FormID, MenuID, CategoryID, Status) VALUES " &_
                "('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "');"
            objConn.Execute(sSQL)
    Next
End If
%>

<form action="" method="post" id="newMenu" name="frmReport"  onsubmit="return validateForm(this)">

<%
'''' RR added today
nFormID= Request("FormID") ''Request.Form("SearchObj")
response.write "FormID: " & nFormID & "
"

sSQL2 = "SELECT * FROM Form WHERE Formid = " & nFormID
''response.write "SQL:::: " & sSQL2 & "
"

    objRS2.Open sSQL2, objConn
    'response.Write sSQL2
    Do Until objRS2.EOF
        sFormName = objRS2("Form_Name")
%>

<%= objRS2("Form_Name") %>

Click me

    <input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>">

<%
    objRS2.MoveNext
    Loop
    objRS2.Close
%>

        Trainer Name:
        Pass
        Fail
        NA
        Not taken

<%
currMenu = ""
sSQL =  "SELECT MenuID, Menu_Name FROM Menu where MENUID in (SELECT MENUID FROM Category where formid=" & nFormID & ")"

    objRS.Open sSQL, objConn
    i=1
    While Not objRS.EOF
        nMenuID     = objRS("MenuID")
        sMenuName   = objRS("Menu_Name")
        If currMenu <> sMenuName Then
            currMenu = sMenuName
            %>

                <%= sMenuName %>

                <input type="hidden" name="MenuID" value="<%=nMenuID%>">
        <%
        End If
        sSQL3 = "SELECT Categoryid, Category_Name FROM Category WHERE MenuID = " & nMenuID & " and FormID=" &  nFormID
            Set objRS3 = Server.CreateObject("ADODB.Recordset")
            objRS3.Open sSQL3, objConn
            While Not objRS3.EOF
                nCategoryID     = objRS3("Categoryid")
                sCategoryName   = objRS3("Category_Name")
        %>

                <%= sCategoryName %>
                <input type="hidden" name="CategoryID" value="<%=nCategoryID%>">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$3">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$4">

            <%
            objRS3.MoveNext
            i = i + 1
            Wend
            objRS3.Close
        objRS.MoveNext
    Wend
    objRS.Close
%>

<input type="hidden" name="txtCount" value="<%= i %>">
<input type="button" value="Create Menu" onclick="openwin();" />
<input type="hidden" name="FormSource" value="SubmitForm">
<input type="button" value="View2" onclick="openview2();" />
<input type="submit" value="Update">
Go To Search

</form>

view2.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Menus Search</title>

<%
SET objRS = Server.CreateObject("ADODB.Recordset")
SET objRS1 = Server.CreateObject("ADODB.Recordset")
SET objRS2 = Server.CreateObject("ADODB.Recordset")
SET objRS3 = Server.CreateObject("ADODB.Recordset")

If Request("FormID")="" then
    iFormID =0
Else
    iFormID = Request("FormID") ''Request.Form("FormID")
End If

If Request.Form("FormSource") = "SubmitForm" Then

    For j = 1 to Request.Form("txtCount")-1
        strReport   = Request.Form("Report[" & j &"]")

        strValue    = split(strReport,"$")
        sMenuID     = strValue(0)
        sCategoryID = strValue(1)
        sStatus     = strValue(2)

'response.write strReport  & "::" & sMenuID & "::"  & sCategoryID & "::"  & sStatus & "
"
'response.end
        sFormID     = Request.Form("FormID")

        sSQL =  "INSERT INTO Report (FormID, MenuID, CategoryID, Status) VALUES " &_
                "('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "');"
            objConn.Execute(sSQL)
    Next
End If
%>

<form action="" method="post" id="newMenu" name="frmReport"  onsubmit="return validateForm(this)">

<%
'''' RR added today
nFormID= Request("FormID") ''Request.Form("SearchObj")
response.write "FormID: " & nFormID & "
"

sSQL2 = "SELECT * FROM Form WHERE Formid = " & nFormID
''response.write "SQL:::: " & sSQL2 & "
"

    objRS2.Open sSQL2, objConn
    'response.Write sSQL2
    Do Until objRS2.EOF
        sFormName = objRS2("Form_Name")
%>

<%= objRS2("Form_Name") %>

    <input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>">

<%
    objRS2.MoveNext
    Loop
    objRS2.Close
%>

        Trainer Name:
        Pass
        Fail
        NA
        Not taken

<%
currMenu = ""
sSQL =  "SELECT MenuID, Menu_Name FROM Menu where MENUID in (SELECT MENUID FROM Category where formid=" & nFormID & ")"

    objRS.Open sSQL, objConn
    i=1
    While Not objRS.EOF
        nMenuID     = objRS("MenuID")
        sMenuName   = objRS("Menu_Name")
        If currMenu <> sMenuName Then
            currMenu = sMenuName
            %>

                <%= sMenuName %>

                <input type="hidden" name="MenuID" value="<%=nMenuID%>">
        <%
        End If
        sSQL3 = "SELECT Categoryid, Category_Name FROM Category WHERE MenuID = " & nMenuID & " and FormID=" &  nFormID
            Set objRS3 = Server.CreateObject("ADODB.Recordset")
            objRS3.Open sSQL3, objConn
            While Not objRS3.EOF
                nCategoryID     = objRS3("Categoryid")
                sCategoryName   = objRS3("Category_Name")
        %>

                <%= sCategoryName %>
                <input type="hidden" name="CategoryID" value="<%=nCategoryID%>">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$3">
                <input type="radio" id ="Report<%=i%>"  name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$4">

            <%
            objRS3.MoveNext
            i = i + 1
            Wend
            objRS3.Close
        objRS.MoveNext
    Wend
    objRS.Close
%>

<input type="hidden" name="txtCount" value="<%= i %>">
<input type="button" value="Create Menu" onclick="openwin();" />
<input type="hidden" name="FormSource" value="SubmitForm">

<input type="submit" value="Update">
Go To Search

</form>

Body:
It's hard to understand what you are trying to do.

But as I could understand, you want to open view2.asp and be able to have a value from view.asp there.

As I can see you open view2.asp with this line

<input type="button" value="View2" onclick="openview2();" />

And you want this hidden input

<input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2('FormID') %>">

If this is what you are trying to do. Then your naming is wrong with the javascript. You probably copied and forgot to change name.

See here, where you try to open view2.asp

function openwin()
{
    window.openView2("view2.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");
}

You need to change openwin() to openview2()

EDIT:

I just also saw you have this strange code

<a href="#" onclick="openview2.asp();"/>Click me</a>

Which is a link to it self, because you have href="#". But you also trying to call a javascript function with this onclick="openview2.asp();".

You do not have a function called openview2.asp(). And this is not how it works.
If you are trying to call view2.asp with this link and pass the hidden input idFormName. Then it's better if you just do a correct link and pass the ID in the url.
I must say it's a very bad solution, because there is no security here. But the code you provided shows that you are only after a function and ignoring any security aspect.

So change this

<h2><%= objRS2("Form_Name") %></h2>
<p><a href="#" onclick="openview2.asp();"/>Click me</a></p>
    <input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />

for this

<h2><%= objRS2("Form_Name") %></h2>
<p><a href="view2.asp?idFormName=<%= objRS2("FormID") %>" />Click me</a></p>
    <input type="hidden" id="idFormName" name="FormID" value="<%= objRS2("FormID") %>"><br />

I'm leaving the hidden there in case you refer to this somewhere else in your code.

Good luck and Have a nice day!


问:
Getting selected value from drop down in JS function
I am trying to get the selected value from drop down from JSP. But I am not able to get the values. Can you please help me here. Below is the code snippet.</p>

```<code>function showScreen()
{
    var frm_name = "jpFrm";
    var ele1 = document.getElementById("ele1");
    var ele2 = document.getElementById("ele2");
    alert("1st : " + ele1.value);
    alert("2nd : " + ele2.value);

    if(ele1.value != "" && ele2.value != "" )
    {
        alert("Form is going to submit");
        frm_name.submit();
        alert("Form Submited");
    }
}
</code>```

答:
I don't know what your html is. But you can get value and text of selected item from dropdown by the below snippet:</p>

```<code>   <select id="ddlCar">
          <option value="1">Car1</option>
          <option value="2" selected="selected">Car2</option>
          <option value="3">Car3</option>
        </select>

       function getDDl(){
        var ele = document.getElementById("ddlCar");
        var carValue= ele.options[ele.selectedIndex].value;
        var cartext= ele.options[ele.selectedIndex].text;
}
</code>```

Body:
I am trying to get the selected value from drop down from JSP. But I am not able to get the values. Can you please help me here. Below is the code snippet.

function showScreen()
{
    var frm_name = "jpFrm";
    var ele1 = document.getElementById("ele1");
    var ele2 = document.getElementById("ele2");
    alert("1st : " + ele1.value);
    alert("2nd : " + ele2.value);

    if(ele1.value != "" && ele2.value != "" )
    {
        alert("Form is going to submit");
        frm_name.submit();
        alert("Form Submited");
    }
}

Body:
I don't know what your html is. But you can get value and text of selected item from dropdown by the below snippet:

   <select id="ddlCar">
          <option value="1">Car1</option>
          <option value="2" selected="selected">Car2</option>
          <option value="3">Car3</option>
        </select>

       function getDDl(){
        var ele = document.getElementById("ddlCar");
        var carValue= ele.options[ele.selectedIndex].value;
        var cartext= ele.options[ele.selectedIndex].text;
}


问:
Could not find class 'android.graphics.drawable.RippleDrawable
Android App closing unexpectedly and giving following error in log-cat.

```<code>01-22 00:33:58.470 8193-8193/? E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01-22 00:34:00.010 1173-1173/? E/MyTag: updateClock : 12:34
01-22 00:34:00.015 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.051 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.080 1432-1432/? E/ActionIcon: time changed: time = 20170122T003400Asia/Calcutta(0,21,19800,0,1485025440)
01-22 00:34:00.086 8210-8210/? E/Zygote: Zygote:  error closing descriptor
                                         libcore.io.ErrnoException: close failed: EBADF (Bad file number)
                                             at libcore.io.Posix.close(Native Method)
                                             at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
                                             at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:221)
                                             at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
                                             at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
                                             at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:713)
                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)
                                             at dalvik.system.NativeStart.main(Native Method)
</code>```

答:
For me the problem was the color-selector drawable which I used for the tint value of an ImageView. The crashes occured on API 19 (I assume it's on all devices API < 21).

Problematic code

```<code><ImageView
    android:id="@+id/icon"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_gravity="center"
    android:src="@drawable/ic_music_note_white_24dp"
    android:tint="@color/color_bottom_navigation_item" />
</code>```

color_bottom_navigation_item.xml

```<code><selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#00CCF0" android:state_selected="true" />
    <item android:color="#75848C" />
</selector>
</code>```

Solution

Remove the android:tint attribute from the XML and set it programatically like so:

```<code>ImageView icon = findViewById(R.id.icon);
ColorStateList tint = getResources().getColorStateList(R.color.color_bottom_navigation_item);

Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_music_note_white_24dp);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, tint);
icon.setImageDrawable(drawable);
</code>```

Body:
Android App closing unexpectedly and giving following error in log-cat.

01-22 00:33:58.470 8193-8193/? E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01-22 00:34:00.010 1173-1173/? E/MyTag: updateClock : 12:34
01-22 00:34:00.015 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.051 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.080 1432-1432/? E/ActionIcon: time changed: time = 20170122T003400Asia/Calcutta(0,21,19800,0,1485025440)
01-22 00:34:00.086 8210-8210/? E/Zygote: Zygote:  error closing descriptor
                                         libcore.io.ErrnoException: close failed: EBADF (Bad file number)
                                             at libcore.io.Posix.close(Native Method)
                                             at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
                                             at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:221)
                                             at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
                                             at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
                                             at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:713)
                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)
                                             at dalvik.system.NativeStart.main(Native Method)

Body:
For me the problem was the color-selector drawable which I used for the tint value of an ImageView. The crashes occured on API 19 (I assume it's on all devices API < 21).

Problematic code

<ImageView
    android:id="@+id/icon"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_gravity="center"
    android:src="@drawable/ic_music_note_white_24dp"
    android:tint="@color/color_bottom_navigation_item" />

color_bottom_navigation_item.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#00CCF0" android:state_selected="true" />
    <item android:color="#75848C" />
</selector>

Solution

Remove the android:tint attribute from the XML and set it programatically like so:

ImageView icon = findViewById(R.id.icon);
ColorStateList tint = getResources().getColorStateList(R.color.color_bottom_navigation_item);

Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_music_note_white_24dp);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, tint);
icon.setImageDrawable(drawable);


问:
Java: duplicate method signature in nested class
Hopefully this question hasn't already been asked. I've had a look around but haven't found a similar post.

Experimenting in Java I've noticed that there is no restriction on having duplicate method signatures in a nested class, which seems counter-intuitive.

For example, if I create class A containing a method with the signature int x() and later add a nested class B containing an identical method, the compiler seems to have no problem with it. My initial assumption was that it would complain that x is already defined. Perhaps I'm missing something obvious that explains why this is allowed?

```<code>class A {
    int x() {
        return 1;
    }

    class B {
        int x() {
            return 2;
        }
    }
}
</code>```

Subsequently, is there any way to access class A's method x from within the scope of class B, or is it permanently hidden by the method x of the local scope?

Edit: I appreciate that the core of the question is the same as this post, however, I was more interested in understanding why this behaviour is allowed as it wasn't immediately clear to me.

答: This should be available somewhere in the JLS - but ultimately it boils down to scope. Each of them has a different scope - thus the compiler does not complain.

Body:
Hopefully this question hasn't already been asked. I've had a look around but haven't found a similar post.

Experimenting in Java I've noticed that there is no restriction on having duplicate method signatures in a nested class, which seems counter-intuitive.

For example, if I create class A containing a method with the signature int x() and later add a nested class B containing an identical method, the compiler seems to have no problem with it. My initial assumption was that it would complain that x is already defined. Perhaps I'm missing something obvious that explains why this is allowed?

class A {
    int x() {
        return 1;
    }

    class B {
        int x() {
            return 2;
        }
    }
}

Subsequently, is there any way to access class A's method x from within the scope of class B, or is it permanently hidden by the method x of the local scope?

Edit: I appreciate that the core of the question is the same as this post, however, I was more interested in understanding why this behaviour is allowed as it wasn't immediately clear to me.


问:
is there any way to set char-counter maxlength dynamically for paper-input
I want to set different maxlength for different data, i tried by writing a method in maxlength but it didn't worked, so is there any other possibility</p>

```<code><paper-input label="{{data.name}}" id="input" char-counter maxlength="getMaxLength()"></paper-input>
</code>```

答:
use a property and set max length to property:

```<code>   <paper-input label="{{data.name}}" id="input" char-counter maxlength="[[maxValue]]"></paper-input>
</code>```

use a method and return value from method:

```<code>   <paper-input label="{{data.name}}" id="input" char-counter maxlength="[[getMaxLength()]]"></paper-input>
</code>```

Body:
I want to set different maxlength for different data, i tried by writing a method in maxlength but it didn't worked, so is there any other possibility

<paper-input label="{{data.name}}" id="input" char-counter maxlength="getMaxLength()"></paper-input>

Body:
use a property and set max length to property:

   <paper-input label="{{data.name}}" id="input" char-counter maxlength="[[maxValue]]"></paper-input>

use a method and return value from method:

   <paper-input label="{{data.name}}" id="input" char-counter maxlength="[[getMaxLength()]]"></paper-input>


问:
way in xcode to see which other apps are running?
I'm programming for iphone 4 and was wondering if there was a way to see which other apps are using the internet.  Thanks!</p>

答: On your mac, you could try iStat Menus (or mistat on the Mac App Store). On your iPhone, not possible.</p>

ContentLicense: CC BY-SA 2.5


问:
Ignore fields from Java object dynamically while sending as JSON from Spring MVC
I have model class like this, for hibernate

```<code>@Entity
@Table(name = "user", catalog = "userdb")
@JsonIgnoreProperties(ignoreUnknown = true)
public class User implements java.io.Serializable {

    private Integer userId;
    private String userName;
    private String emailId;
    private String encryptedPwd;
    private String createdBy;
    private String updatedBy;

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "UserId", unique = true, nullable = false)
    public Integer getUserId() {
        return this.userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Column(name = "UserName", length = 100)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "EmailId", nullable = false, length = 45)
    public String getEmailId() {
        return this.emailId;
    }

    public void setEmailId(String emailId) {
        this.emailId = emailId;
    }

    @Column(name = "EncryptedPwd", length = 100)
    public String getEncryptedPwd() {
        return this.encryptedPwd;
    }

    public void setEncryptedPwd(String encryptedPwd) {
        this.encryptedPwd = encryptedPwd;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Column(name = "UpdatedBy", length = 100)
    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }
}
</code>```

In Spring MVC controller, using DAO, I am able to get the object. and returning as JSON Object.

```<code>@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/getUser/{userId}", method = RequestMethod.GET)
    @ResponseBody
    public User getUser(@PathVariable Integer userId) throws Exception {

        User user = userService.get(userId);
        user.setCreatedBy(null);
        user.setUpdatedBy(null);
        return user;
    }
}
</code>```

View part is done using AngularJS, so it will get JSON like this

```<code>{
  "userId" :2,
  "userName" : "john",
  "emailId" : "john@gmail.com",
  "encryptedPwd" : "Co7Fwd1fXYk=",
  "createdBy" : null,
  "updatedBy" : null
}
</code>```

If I don't want to set encrypted Password, I will set that field also as null.

But I don't want like this, I dont want to send all fields to client side. If I dont want password, updatedby, createdby fields to send, My result JSON should be like

```<code>{
  "userId" :2,
  "userName" : "john",
  "emailId" : "john@gmail.com"
}
</code>```

The list of fields which I don't want to send to client coming from other database table. So it will change based on the user who is logged in.  How can I do that?

I hope You got my question.

答:
Would not creating a UserJsonResponse class and populating with the wanted fields be a cleaner solution?

Returning directly a JSON seems a great solution when you want to give all the model back. Otherwise it just gets messy.

In the future, for example you might want to have a JSON field that does not match any Model field and then you're in a bigger trouble.

Body:
I have model class like this, for hibernate

@Entity
@Table(name = "user", catalog = "userdb")
@JsonIgnoreProperties(ignoreUnknown = true)
public class User implements java.io.Serializable {

    private Integer userId;
    private String userName;
    private String emailId;
    private String encryptedPwd;
    private String createdBy;
    private String updatedBy;

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "UserId", unique = true, nullable = false)
    public Integer getUserId() {
        return this.userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Column(name = "UserName", length = 100)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "EmailId", nullable = false, length = 45)
    public String getEmailId() {
        return this.emailId;
    }

    public void setEmailId(String emailId) {
        this.emailId = emailId;
    }

    @Column(name = "EncryptedPwd", length = 100)
    public String getEncryptedPwd() {
        return this.encryptedPwd;
    }

    public void setEncryptedPwd(String encryptedPwd) {
        this.encryptedPwd = encryptedPwd;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Column(name = "UpdatedBy", length = 100)
    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }
}

In Spring MVC controller, using DAO, I am able to get the object. and returning as JSON Object.

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/getUser/{userId}", method = RequestMethod.GET)
    @ResponseBody
    public User getUser(@PathVariable Integer userId) throws Exception {

        User user = userService.get(userId);
        user.setCreatedBy(null);
        user.setUpdatedBy(null);
        return user;
    }
}

View part is done using AngularJS, so it will get JSON like this

{
  "userId" :2,
  "userName" : "john",
  "emailId" : "john@gmail.com",
  "encryptedPwd" : "Co7Fwd1fXYk=",
  "createdBy" : null,
  "updatedBy" : null
}

If I don't want to set encrypted Password, I will set that field also as null.

But I don't want like this, I dont want to send all fields to client side. If I dont want password, updatedby, createdby fields to send, My result JSON should be like

{
  "userId" :2,
  "userName" : "john",
  "emailId" : "john@gmail.com"
}

The list of fields which I don't want to send to client coming from other database table. So it will change based on the user who is logged in.  How can I do that?

I hope You got my question.


问:
difficulty in printing in a 5x3
this is the output i want to do :/

i uploaded an image :/ why doesnt preview

sample output:
1)AUD  6)     11)

2)     7)     12)

3)     8     13
4)     9     14
5)     10    11)PHP

hi im making a table for choices and im kinda stuck in this part(finishing touch)

```<code>#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
    const int ROW = 15;
    const int COL = 15;
    float magicArray1[ROW][COL];
    int choice1,choice2;
    float amount,result;
    //

    char currency_name[15][5] =
    {   "AUD","BRL","CAD","CNY","DKK","EUR","HKD","INR","JPY","RUR","SGD","SEK",
    "CHF","USD","PHP"

    };

    //

    cout << "Available Currencies:" << endl;
        cout << "---------------------" << endl;

    for(int j = 0; j <5; j++)
        {
        for (int i=0; i<5; i++)
            {
            cout << i+1 << ". " << currency_name[i][j] <<endl;
            }
        }
    //

    return 0;
}
</code>```

can someone point out my error :D and give me a hint :D
im kinda puzzled right now
this is all i have now

答:
The code you pasted here works just fine.
But the following code is enough to do what you want it to do.</p>

```<code>#include<iostream>
#include<string>
using namespace std;

int main()
{
    string currency_name[15] =
    {
        "AUD","BRL","CAD","CNY","DKK","EUR","HKD","INR","JPY","RUR","SGD","SEK",
        "CHF","USD","PHP"
    };

    cout << "Available Currencies:" << endl;
    cout << "---------------------" << endl;

    for (int i=0; i<15; i++)
    {
        cout << i+1 << ". " << currency_name[i] <<endl;
    }
}
</code>```

Title: difficulty in printing in a 5x3

Body:
this is the output i want to do :/

i uploaded an image :/ why doesnt preview

sample output:
1)AUD  6)     11)

2)     7)     12)

3)     8     13
4)     9     14
5)     10    11)PHP

hi im making a table for choices and im kinda stuck in this part(finishing touch)

#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
    const int ROW = 15;
    const int COL = 15;
    float magicArray1[ROW][COL];
    int choice1,choice2;
    float amount,result;
    //

    char currency_name[15][5] =
    {   "AUD","BRL","CAD","CNY","DKK","EUR","HKD","INR","JPY","RUR","SGD","SEK",
    "CHF","USD","PHP"

    };

    //

    cout << "Available Currencies:" << endl;
        cout << "---------------------" << endl;

    for(int j = 0; j <5; j++)
        {
        for (int i=0; i<5; i++)
            {
            cout << i+1 << ". " << currency_name[i][j] <<endl;
            }
        }
    //

    return 0;
}

can someone point out my error :D and give me a hint :D
im kinda puzzled right now
this is all i have now

Body:
The code you pasted here works just fine.
But the following code is enough to do what you want it to do.

#include<iostream>
#include<string>
using namespace std;

int main()
{
    string currency_name[15] =
    {
        "AUD","BRL","CAD","CNY","DKK","EUR","HKD","INR","JPY","RUR","SGD","SEK",
        "CHF","USD","PHP"
    };

    cout << "Available Currencies:" << endl;
    cout << "---------------------" << endl;

    for (int i=0; i<15; i++)
    {
        cout << i+1 << ". " << currency_name[i] <<endl;
    }
}


问:
google map v3 dragging marker issue
I am using Google map api V3, and in my application i m making gradable marker. Every thing is working fine except the marker icon while dragging.

What happens in Google Map V2 was it changes marker icon automatically when it was being dragged but in Google Map V3 when dragging the marker its icon doesn't change like it used to change in V2.

答: The answer is simple: in V3 they removed it, since they considered the animation to be of little use in mobile devices. They are trying to aim this V3 release to be as lightweight as possible.</p>

Title: google map v3 dragging marker issue


问:
While executing the below code getting an error bad geometry specifier in python
While trying the below code:

```<code>import tkinter

print(tkinter.TkVersion)

print(tkinter.TclVersion)

mainWindow = tkinter.Tk()

mainWindow.title("Hello Python")

mainWindow.geometry("1200X1024")

mainWindow.mainloop()
</code>```

I am getting an error:

```<code> Traceback (most recent call last):
   File "C:\Users\Satya\IdeaProjects\GUO_python\tkinter1.py", line 11, in <module>
     mainWindow.geometry("1200X1024")
   File "C:\Users\Satya\Anaconda3\lib\tkinter\__init__.py", line 1835, in wm_geometry
     return self.tk.call('wm', 'geometry', self._w, newGeometry)
 _tkinter.TclError: bad geometry specifier "1200X1024"
</code>```

https://i.stack.imgur.com/EJyn6.jpg

答: Also, if you set 1200x1024 (and not 'X') to make your window taking your whole screen you can use mainWindow.state('zoomed')

Body:
While trying the below code:

import tkinter

print(tkinter.TkVersion)

print(tkinter.TclVersion)

mainWindow = tkinter.Tk()

mainWindow.title("Hello Python")

mainWindow.geometry("1200X1024")

mainWindow.mainloop()

I am getting an error:

 Traceback (most recent call last):
   File "C:\Users\Satya\IdeaProjects\GUO_python\tkinter1.py", line 11, in <module>
     mainWindow.geometry("1200X1024")
   File "C:\Users\Satya\Anaconda3\lib\tkinter\__init__.py", line 1835, in wm_geometry
     return self.tk.call('wm', 'geometry', self._w, newGeometry)
 _tkinter.TclError: bad geometry specifier "1200X1024"

https://i.stack.imgur.com/EJyn6.jpg


问:
Vue bypass html into sub-sub component
Lets say, I have the following vuejs structure:

```<code><!-- MainComponent.vue -->
<template>
    <childcomponent></childcomponent>
</template>

<!-- ChildComponent.vue -->
<template>
    <div>
        <grandchild></grandchild>
    </div>
</template>

<!-- GrandchildComponent.vue -->
<template>
    <div>
        FooBar
        <slot name="actions"></slot>
    </div>
</template>
</code>```

If I want to set a value for the grandchild-slot "actions" in the child-component, I have to do this:

```<code><!-- ChildComponent.vue -->
<template>
    <div>
        <grandchild>
            <template slot="actions">Actions from ChildComponent</template>
        </grandchild>
    </div>
</template>
</code>```

But how to bypass "actions" from the MainComponent? I tried this, but thats not working:

```<code><!-- MainComponent.vue -->
<template>
    <childcomponent>
        <template slot="actions" slot-scope="props">
            Actions from MainComponent
        </template>
    </childcomponent>
</template>

<!-- ChildComponent.vue -->
<template>
    <div>
        <grandchild>
            <slot name="actions">
                <template slot="actions" slot-scope="props">
                    Actions from ChildComponent
                </template>
            </slot>
        </grandchild>
    </div>
</template>
</code>```

答:
After a lot of research, I think the only possible way of doing it, is only over the render function (https://v2.vuejs.org/v2/guide/render-function.html).

The main idea behind it is to write instead of html templates for ChildComponent.vue and GrandchildComponent.vue custom render functions.

A complete tutorial for a similar usecase can be found here:
https://github.com/ratiw/vuetable-2-tutorial/wiki

Title: Vue bypass html into sub-sub component

Body:
Lets say, I have the following vuejs structure:

<template>
    <childcomponent></childcomponent>
</template>

<template>

        <grandchild></grandchild>

</template>

<template>

        FooBar
        <slot name="actions"></slot>

</template>

If I want to set a value for the grandchild-slot "actions" in the child-component, I have to do this:

<template>

        <grandchild>
            <template slot="actions">Actions from ChildComponent</template>
        </grandchild>

</template>

But how to bypass "actions" from the MainComponent? I tried this, but thats not working:

<template>
    <childcomponent>
        <template slot="actions" slot-scope="props">
            Actions from MainComponent
        </template>
    </childcomponent>
</template>

<template>

        <grandchild>
            <slot name="actions">
                <template slot="actions" slot-scope="props">
                    Actions from ChildComponent
                </template>
            </slot>
        </grandchild>

</template>

ContentLicense: CC BY-SA 4.0


问:
Using variable number of float arguments
I'm trying to implement a flexible constructor for my struct Polynomial :

```<code>struct Polynomial
{
    std::vector<float> coefficients;
    size_t degree;
};
</code>```

The degree of the polynomial is variable.
What I would like is to have a constructor like

```<code>Polynomial(float... _coefficients);
</code>```

I've tried variadic template :

```<code>template<float... Args>
Polynomial(Args... args);
</code>```

But float is a non-type, so I've done :

```<code>template<typename... Args>
Polynomial(Args... args);
</code>```

But this allow my coefficients to be anything, not realy what I want.
I know I could use :

```<code>Polynomial(size_t _degree, ...);
</code>```

But it is really unsafe.

At the moment I'm using :

```<code>Polynomial(std::vector<float>);
</code>```

But this force the call to be like :

```<code>Polynomial P({f1, f2, f3}); // with fn floats
</code>```

So I would like to know if there is a good way to do this.

Thank you !

答:
You can use initializer_list:

```<code>#include <vector>
#include <initializer_list>

struct Polynomial {
    std::vector<float> coeffs;
    std::size_t degree;

    Polynomial(std::initializer_list<float> init)
        : coeffs{ init }, degree(init.size()) { }
};

int main() {
    Polynomial p{ 1, 2, 3. };
}
</code>```

Body:
I'm trying to implement a flexible constructor for my struct Polynomial :

struct Polynomial
{
    std::vector<float> coefficients;
    size_t degree;
};

The degree of the polynomial is variable.
What I would like is to have a constructor like

Polynomial(float... _coefficients);

I've tried variadic template :

template<float... Args>
Polynomial(Args... args);

But float is a non-type, so I've done :

template<typename... Args>
Polynomial(Args... args);

But this allow my coefficients to be anything, not realy what I want.
I know I could use :

Polynomial(size_t _degree, ...);

But it is really unsafe.

At the moment I'm using :

Polynomial(std::vector<float>);

But this force the call to be like :

Polynomial P({f1, f2, f3}); // with fn floats

So I would like to know if there is a good way to do this.

Thank you !

Body:
You can use initializer_list:

#include <vector>
#include <initializer_list>

struct Polynomial {
    std::vector<float> coeffs;
    std::size_t degree;

    Polynomial(std::initializer_list<float> init)
        : coeffs{ init }, degree(init.size()) { }
};

int main() {
    Polynomial p{ 1, 2, 3. };
}


问:
Rack custom middleware giving error "ActionDispatch::Http::Parameters::ParseError"
I am writing a custom middleware for my rails app, to decrypt/encrypt parameters in a post request. I have configured the middleware in 'config/environments/staging.rb'

```<code>config.middleware.use CustomMiddleware
</code>```

In order to read the request params i am reading the env obj like this

```<code>rack_input = env['rack.input'].read
</code>```

I am able to access the parameter and manipulate as needed. But when i pass over on the env obj to the app object which is the receiver. I am getting

```<code>"ActionDispatch::Http::Parameters::ParseError"
</code>```

Full error

```<code>Error occurred while parsing request parameters.
Contents:

F, [2017-11-15T02:13:50.230088 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc]
F, [2017-11-15T02:13:50.230340 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc] ActionDispatch::Http::Parameters::ParseError (no implicit conversion of nil into String):
F, [2017-11-15T02:13:50.230563 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc]
F, [2017-11-15T02:13:50.230782 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc] app/middleware/custom_middleware.rb:34:in `call'
</code>```

My code is somewhat like this

```<code>class CustomMiddleware
  include Encryption

  def initialize(app)
    @app = app
  end

  def set_payload_params(env)
    rack_input = env['rack.input'].read
    @args = JSON.parse(rack_input) rescue {}
  end

  def call(env)
    request = Rack::Request.new(env)
    set_payload_params(env)

    payload = @args['payload']

    decrypt_params
    status, headers, response = @app.call(env)
    encrypt_params

  end
</code>```

If i don't read the env object and hard code the parameters, there is no such parsing error. And my controller is responding with data w.r.t to hardcode parameters.

My Rails version is 5.1.4
My ruby version is 2.4.2

I have done a similar middleware in another rails app(4.2.8) which is working fine.

Any insight on this will be of much help. Thanks in advance.

答:
Added a hack to set content-type as "" in custom middleware, which avoided  parsing on the input before forwarding the input to next component in the stack. </p>

```<code> class CustomMiddleware

   include Encryption

   def initialize(app)
     @app = app   end

   def set_payload_params(env)
     rack_input = env['rack.input'].read
     @args = JSON.parse(rack_input) rescue {}   end

   def call(env)
     env['CONTENT_TYPE'] = ''
     request = Rack::Request.new(env)
     set_payload_params(env)

     payload = @args['payload']

     decrypt_params
     status, headers, response = @app.call(env)
     encrypt_params

  end
</code>```

Body:
I am writing a custom middleware for my rails app, to decrypt/encrypt parameters in a post request. I have configured the middleware in 'config/environments/staging.rb'

config.middleware.use CustomMiddleware

In order to read the request params i am reading the env obj like this

rack_input = env['rack.input'].read

I am able to access the parameter and manipulate as needed. But when i pass over on the env obj to the app object which is the receiver. I am getting

"ActionDispatch::Http::Parameters::ParseError"

Full error

Error occurred while parsing request parameters.
Contents:

F, [2017-11-15T02:13:50.230088 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc]
F, [2017-11-15T02:13:50.230340 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc] ActionDispatch::Http::Parameters::ParseError (no implicit conversion of nil into String):
F, [2017-11-15T02:13:50.230563 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc]
F, [2017-11-15T02:13:50.230782 #24060] FATAL -- : [9aa25c7e-56e7-4894-ba30-3a01f60ae4fc] app/middleware/custom_middleware.rb:34:in `call'

My code is somewhat like this

class CustomMiddleware
  include Encryption

  def initialize(app)
    @app = app
  end

  def set_payload_params(env)
    rack_input = env['rack.input'].read
    @args = JSON.parse(rack_input) rescue {}
  end

  def call(env)
    request = Rack::Request.new(env)
    set_payload_params(env)

    payload = @args['payload']

    decrypt_params
    status, headers, response = @app.call(env)
    encrypt_params

  end

If i don't read the env object and hard code the parameters, there is no such parsing error. And my controller is responding with data w.r.t to hardcode parameters.

My Rails version is 5.1.4
My ruby version is 2.4.2

I have done a similar middleware in another rails app(4.2.8) which is working fine.

Any insight on this will be of much help. Thanks in advance.

Body:
Added a hack to set content-type as "" in custom middleware, which avoided  parsing on the input before forwarding the input to next component in the stack.

 class CustomMiddleware

   include Encryption

   def initialize(app)
     @app = app   end

   def set_payload_params(env)
     rack_input = env['rack.input'].read
     @args = JSON.parse(rack_input) rescue {}   end

   def call(env)
     env['CONTENT_TYPE'] = ''
     request = Rack::Request.new(env)
     set_payload_params(env)

     payload = @args['payload']

     decrypt_params
     status, headers, response = @app.call(env)
     encrypt_params

  end


问:
How to make logcat tag editor bigger in android studio 3.0?
unable to scroll within it or can't even see my log tag

答:
As a workaround you can try: Right click on 'Logcat' horizontal grey tab(Can be seen on top of the image you attached) -> Select 'Floating Mode' and resize.
 AS 3.1 Canary 2 has the desired(correct) logcat UI.
 I suggest to use floating mode as of now or move to updated latest stable AS version.


问:
How to pick localize android app based on the user profile.?
I would like to localize my app based on the user who has logged in my app and not based on the device loacle. How can I achieve this ?

Regards,

答:
This was required for a customer in europe. They want to provide the locale based on user language they chose at the time of registering witht he company. </p>

<p>We ended up implementing it natively through locale change events.. </p>

Body:
This was required for a customer in europe. They want to provide the locale based on user language they chose at the time of registering witht he company.

We ended up implementing it natively through locale change events..


问:
Bitcode signature failure in Xcode
I updated Xcode to the last version, and now when I'm trying to compile the project I'm getting an error "Invalid bitcode signature", hovewer, the bitcode for my project is disabled. How can I fix it? What should I change to sign my bitcode correctly?

My Podfile:

```<code>source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'MyProjectName' do

pod 'Realm'
pod 'CorePlot'
pod 'GoogleMaps'

end
</code>```

I checked already, everything is fine with it.

答: I was adding static library . I created fat binary of the same library including all architectures and included in my project. This resolved my issue</p>

Title: Bitcode signature failure in Xcode

Body:
I updated Xcode to the last version, and now when I'm trying to compile the project I'm getting an error "Invalid bitcode signature", hovewer, the bitcode for my project is disabled. How can I fix it? What should I change to sign my bitcode correctly?

My Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'MyProjectName' do

pod 'Realm'
pod 'CorePlot'
pod 'GoogleMaps'

end

I checked already, everything is fine with it.


问:
How to write SQL query into code-igniter formate
How to write below SQL query in to code-igniter </p>

```<code>SELECT
    `pm`.`id`,
    `pm`.`region`,
    `pm`.`port_name`,
    `pm`.`country`,
    `tbl_port_annual_throughput`.`YEAR`,
    `tbl_port_annual_throughput`.`TOTAL_THROUGHPUT`,
    `tbl_port_annual_throughput`.`status`
    FROM (`tbl_port_annual_throughput`)
    JOIN `port_master` pm
      ON `pm`.`id` = `tbl_port_annual_throughput`.`PORT_ID`
    WHERE `pm`.`country` = "100@Kenya"
    AND (
        (`tbl_port_annual_throughput`.`YEAR` =  '2014' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2015' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2016' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
    )
</code>```

答:
Well before you can convert this, the actual SQL needs a bit of a tidy up...

```<code>SELECT
    `pm`.`id`,
    `pm`.`region`,
    `pm`.`port_name`,
    `pm`.`country`,
    `pat`.`YEAR`,
    `pat`.`TOTAL_THROUGHPUT`,
    `pat`.`status`
    FROM `tbl_port_annual_throughput` pat
    JOIN `port_master` pm
      ON `pm`.`id` = `pat`.`PORT_ID`
    WHERE `pm`.`country` = "100@Kenya"
    AND `pat`.`YEAR` IN ('2014','2015','2016')
    AND `pat`.`status` =  'Confirmed'
</code>```

So now it is simpler and works - tested in a quick simulation of your tables...

NOTE: Just make sure the above actually does work for you first.

Have a go at converting that.

Body:
How to write below SQL query in to code-igniter

SELECT
    `pm`.`id`,
    `pm`.`region`,
    `pm`.`port_name`,
    `pm`.`country`,
    `tbl_port_annual_throughput`.`YEAR`,
    `tbl_port_annual_throughput`.`TOTAL_THROUGHPUT`,
    `tbl_port_annual_throughput`.`status`
    FROM (`tbl_port_annual_throughput`)
    JOIN `port_master` pm
      ON `pm`.`id` = `tbl_port_annual_throughput`.`PORT_ID`
    WHERE `pm`.`country` = "100@Kenya"
    AND (
        (`tbl_port_annual_throughput`.`YEAR` =  '2014' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2015' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2016' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
    )

Body:
Well before you can convert this, the actual SQL needs a bit of a tidy up...

SELECT
    `pm`.`id`,
    `pm`.`region`,
    `pm`.`port_name`,
    `pm`.`country`,
    `pat`.`YEAR`,
    `pat`.`TOTAL_THROUGHPUT`,
    `pat`.`status`
    FROM `tbl_port_annual_throughput` pat
    JOIN `port_master` pm
      ON `pm`.`id` = `pat`.`PORT_ID`
    WHERE `pm`.`country` = "100@Kenya"
    AND `pat`.`YEAR` IN ('2014','2015','2016')
    AND `pat`.`status` =  'Confirmed'

So now it is simpler and works - tested in a quick simulation of your tables...

NOTE: Just make sure the above actually does work for you first.

Have a go at converting that.


答:
Answering your question

I would like to know if there is a good way to do this

Yes, i think the way you are doing it it's more than acceptable. And even the syntax where you use it Polynomial P({f1, f2, f3}); isn't so ugly at all.

Furthermore, use std::vector is as efficient as variadic and much more comprehensible for others.

With the variadic approach, you will find difficult to force those types received to be float, but with std::vector you got it controlled

Title: Using variable number of float arguments


问:
Comparator as lambda
I've the following method in Java library:

public void setColumnComparator(final int columnIndex, final Comparator<T> columnComparator)
```

<p>Idea says it has the following prorotype:</p>

```setColumnComparator(columnIndex: Int, columnComparator: ((Any!, Any!) -> Int)!)
```

<p>How can I use it? I know it will be <code>String</code>, so I want something like this, but it doesn't compile.</p>

```setColumnComparator(0, Comparator<String> { a, b -> a.compareTo(b) }
```

答:
If you know for sure that your SortableTableView's generic type parameter is String, you could cast it to a SortableTableView<String> and then make the call to it:

```<code>(tableView as SortableTableView<String>).setColumnComparator(1, { x, y ->
    x.compareTo(y)
})
</code>```

Alternatively, you could cast the parameters that the Comparator takes individually:

```<code>tableView.setColumnComparator(1, { x, y ->
    (x as String).compareTo(y as String)
})
</code>```

Title: Comparator as lambda

Body:
I've the following method in Java library:

public void setColumnComparator(final int columnIndex, final Comparator<T> columnComparator)

Idea says it has the following prorotype:

setColumnComparator(columnIndex: Int, columnComparator: ((Any!, Any!) -> Int)!)

How can I use it? I know it will be String, so I want something like this, but it doesn't compile.

setColumnComparator(0, Comparator<String> { a, b -> a.compareTo(b) }

Body:
If you know for sure that your SortableTableView's generic type parameter is String, you could cast it to a SortableTableView<String> and then make the call to it:

(tableView as SortableTableView<String>).setColumnComparator(1, { x, y ->
    x.compareTo(y)
})

Alternatively, you could cast the parameters that the Comparator takes individually:

tableView.setColumnComparator(1, { x, y ->
    (x as String).compareTo(y as String)
})


答:
Its scope, it's similar to have an instance variable called foo and then a local one in the method called foo as well.

Its worth reading about scope in java

Title: Java: duplicate method signature in nested class

Body:
Hopefully this question hasn't already been asked. I've had a look around but haven't found a similar post.

Experimenting in Java I've noticed that there is no restriction on having duplicate method signatures in a nested class, which seems counter-intuitive.

For example, if I create class A containing a method with the signature int x() and later add a nested class B containing an identical method, the compiler seems to have no problem with it. My initial assumption was that it would complain that x is already defined. Perhaps I'm missing something obvious that explains why this is allowed?

class A {
    int x() {
        return 1;
    }

    class B {
        int x() {
            return 2;
        }
    }
}

Subsequently, is there any way to access class A's method x from within the scope of class B, or is it permanently hidden by the method x of the local scope?

Edit: I appreciate that the core of the question is the same as this post, however, I was more interested in understanding why this behaviour is allowed as it wasn't immediately clear to me.


问:
Postman Chrome: What is the difference between form-data, x-www-form-urlencoded and raw
I am using the Postman Chrome extension for testing a web service.

There are three options available for data input.

I guess the raw is for sending JSON.

What is the difference between the other two, form-data and x-www-form-urlencoded?

答:
multipart/form-data

Note. Please consult RFC2388 for additional information about file uploads, including backwards compatibility issues, the relationship between "multipart/form-data" and other content types, performance issues, etc.

Please consult the appendix for information about security issues for forms.

The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.

The content type "multipart/form-data" follows the rules of all multipart MIME data streams as outlined in RFC2045. The definition of "multipart/form-data" is available at the [IANA] registry.

A "multipart/form-data" message contains a series of parts, each representing a successful control. The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream. Part boundaries should not occur in any of the data; how this is done lies outside the scope of this specification.

As with all multipart MIME types, each part has an optional "Content-Type" header that defaults to "text/plain". User agents should supply the "Content-Type" header, accompanied by a "charset" parameter.

application/x-www-form-urlencoded

This is the default content type. Forms submitted with this content type must be encoded as follows:

Control names and values are escaped. Space characters are replaced by +', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by %HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by =' and name/value pairs are separated from each other by `&'.

application/x-www-form-urlencoded the body of the HTTP message sent to the server is essentially one giant query string -- name/value pairs are separated by the ampersand (&), and names are separated from values by the equals symbol (=). An example of this would be:

```<code>MyVariableOne=ValueOne&MyVariableTwo=ValueTwo
</code>```

The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.

Body:
multipart/form-data

Note. Please consult RFC2388 for additional information about file uploads, including backwards compatibility issues, the relationship between "multipart/form-data" and other content types, performance issues, etc.

Please consult the appendix for information about security issues for forms.

The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.

The content type "multipart/form-data" follows the rules of all multipart MIME data streams as outlined in RFC2045. The definition of "multipart/form-data" is available at the [IANA] registry.

A "multipart/form-data" message contains a series of parts, each representing a successful control. The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream. Part boundaries should not occur in any of the data; how this is done lies outside the scope of this specification.

As with all multipart MIME types, each part has an optional "Content-Type" header that defaults to "text/plain". User agents should supply the "Content-Type" header, accompanied by a "charset" parameter.

application/x-www-form-urlencoded

This is the default content type. Forms submitted with this content type must be encoded as follows:

Control names and values are escaped. Space characters are replaced by +', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by %HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by =' and name/value pairs are separated from each other by `&'.

application/x-www-form-urlencoded the body of the HTTP message sent to the server is essentially one giant query string -- name/value pairs are separated by the ampersand (&), and names are separated from values by the equals symbol (=). An example of this would be:

MyVariableOne=ValueOne&MyVariableTwo=ValueTwo

The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.