问:
XMLHTTPREQUEST error JQUERY
I am working with dark sky API on code pen. https://codepen.io/ashan_zeroxster/pen/MpxVOv?editors=0010
And when I tried to get JSON data from DARKSKY API I get XMLHTTPREQUEST error.
My Code</p>

```<code>$(document).ready(function(){

  var api = https://api.darksky.net/forecast/a18d80cbf99f8930c6a140bf8e722630/";
 var long = "";
 var lat = "";
 var url = "";

navigator.geolocation.getCurrentPosition(function (position){
var long = position.coords.longitude;
var lat =  position.coords.latitude;

var url =  api + long + "," + lat;

$.getJSON(url, function(data){
   document.write(data);
});

});

 });
</code>```

答:
The problem in codepen seems to be CORS (Cross-Origin-Resource-Sharing) violation. Read more on this here.

You also find information directly from darksky about CORS in their FAQ: https://darksky.net/dev/docs/faq

Title: XMLHTTPREQUEST error JQUERY

Body:
I am working with dark sky API on code pen. https://codepen.io/ashan_zeroxster/pen/MpxVOv?editors=0010
And when I tried to get JSON data from DARKSKY API I get XMLHTTPREQUEST error.
My Code

$(document).ready(function(){

  var api = https://api.darksky.net/forecast/a18d80cbf99f8930c6a140bf8e722630/";
 var long = "";
 var lat = "";
 var url = "";

navigator.geolocation.getCurrentPosition(function (position){
var long = position.coords.longitude;
var lat =  position.coords.latitude;

var url =  api + long + "," + lat;

$.getJSON(url, function(data){
   document.write(data);
});

});

 });


来源: stackexchange

问:
How yield identify that its iteration done once.?
I have read about yield at What does the "yield" keyword do in Python? keyword in python but i have one question that how system identity that yield iterated once.

```<code>def test_yield():
    name = 'Hello World!'
    for i in name:
        yield i

y= test_yield()

print "first yield",y
for c in y:
    print c

print "second yield",y
for c in y:
    print c
</code>```

Output

```<code>first yield <generator object test_yield at 0x7f4c2bc10be0>
H
e
l
l
o

W
o
r
l
d
!
second yield <generator object test_yield at 0x7f4c2bc10be0>
</code>```

In output second time yield object printed but not iterate.so how program identity that its executed once?

答:
When you wrote
 y = test_yield()
you initialize iterator and when you finish your iteration after first
 for c in y:
the iterator was ended. You need to initialize once more like:

```<code>def test_yield():
      name = 'Hello World!'
      for i in name:
        yield i

y= test_yield()

print "first yield",y
for c in y:
    print c

# once again
y= test_yield()

print "second yield",y
for c in y:
    print c
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have read about yield at What does the "yield" keyword do in Python? keyword in python but i have one question that how system identity that yield iterated once.

def test_yield():
    name = 'Hello World!'
    for i in name:
        yield i

y= test_yield()

print "first yield",y
for c in y:
    print c

print "second yield",y
for c in y:
    print c

Output

first yield <generator object test_yield at 0x7f4c2bc10be0>
H
e
l
l
o

W
o
r
l
d
!
second yield <generator object test_yield at 0x7f4c2bc10be0>

In output second time yield object printed but not iterate.so how program identity that its executed once?

Body:
When you wrote
 y = test_yield()
you initialize iterator and when you finish your iteration after first
 for c in y:
the iterator was ended. You need to initialize once more like:

def test_yield():
      name = 'Hello World!'
      for i in name:
        yield i

y= test_yield()

print "first yield",y
for c in y:
    print c

# once again
y= test_yield()

print "second yield",y
for c in y:
    print c


问:
Is it possible to prevent the browser from parsing certain elements?
Consider the following markup:

```<code><div hidden id="table-template">
<table>
<tbody>
  <slot></slot>
</tbody>
</table>
</div>
<div hidden id="table-row-template">
<tr>
  <td>
    Some Content
  </td>
</tr>
</div>
</code>```

I would like to use 'table-template' and 'table-row-template' as re-usable components in my script.
(clone them and append them on demand)
but as the page loads the browser parses the markup and mutates it (taking 'slot' element and insert it before the 'table' element, and stripping 'td' and 'tr' tags).

This is reasonable (not valid HTML of course), but is there any way I can prevent the browser from parsing those elements?

So far I have tried:
using hidden elements,
wrapping with 'pre'/'code' tags,
but none seem to work.

答:
Use a fictional tag that the browser wouldn't recognise. You can still target it with Javascript and read it's text content but the browser won't parse it.

Say <template id="the-template">Foo bar</template>.

But really the best way to re-use html snippets it to create them in Javascript without polluting the DOM.

e.g

```<code>var elToReuse = document.createElement('div').innerHTML('<h1>Lets have title here</h1>');
// Let's do some things to the elToReuse
var anotherVersion = elToReuse.querySelector('h1').innerText('My another title');

// Now it's the time to append to the DOM
document.body.appendChild(anotherVersion);
</code>```

Body:
Consider the following markup:

  <slot></slot>

    Some Content

I would like to use 'table-template' and 'table-row-template' as re-usable components in my script.
(clone them and append them on demand)
but as the page loads the browser parses the markup and mutates it (taking 'slot' element and insert it before the 'table' element, and stripping 'td' and 'tr' tags).

This is reasonable (not valid HTML of course), but is there any way I can prevent the browser from parsing those elements?

So far I have tried:
using hidden elements,
wrapping with 'pre'/'code' tags,
but none seem to work.

Body:
Use a fictional tag that the browser wouldn't recognise. You can still target it with Javascript and read it's text content but the browser won't parse it.

Say <template id="the-template">Foo bar</template>.

But really the best way to re-use html snippets it to create them in Javascript without polluting the DOM.

e.g

var elToReuse = document.createElement('div').innerHTML('<h1>Lets have title here</h1>');
// Let's do some things to the elToReuse
var anotherVersion = elToReuse.querySelector('h1').innerText('My another title');

// Now it's the time to append to the DOM
document.body.appendChild(anotherVersion);


问:
how to get jboss tools to not automatically deploy on server start
ive just upgraded to eclipse 3.6 and i have a seam application running on jboss 5 with the latest version of jboss tools.  my problem is that when i opened an xhtml page it asked me to activate the jsf components.  i went ahead and did so and now my problem is that when i start jboss inside of eclipse it automatically deploys an exploded version of my app.  i don't want this, i use ant to build and deploy the app and just use jboss tools to start and stop the server.  i need to turn this feature off, does anyone have an idea how to do it?</p>

答:
Double click the server and select the radiobutton that says "Never publish automatically"

btw. you can also enable "Deploy projects as compressed archives" if your problem is that the deployment is exploded.

ContentLicense: CC BY-SA 2.5


问:
How to dynamically and correctly change a query in Command Table for Crystal Reports file?
I have many rpt files. I want to change the query for each report using C#. There are several ways to do this changes.

First way:

```<code>private void button_Test_Click(object sender, EventArgs e)
{
    ReportDocument rptDoc = new ReportDocument();
    rptDoc.Load("D:\\Temp_01\\Report1_Test.rpt");
    rptDoc.SetDatabaseLogon("User", "Password", "ServName", "DBName");
    CrystalDecisions.Shared.ConnectionInfo ConnInf;
    ConnInf = rptDoc.Database.Tables[0].LogOnInfo.ConnectionInfo;
    String strSQLQuery = "SELECT TOP(123) * FROM sys.all_objects";
    String strTableName = rptDoc.Database.Tables[0].Name;
    try
    {
        rptDoc.SetSQLCommandTable(ConnInf, strTableName, strSQLQuery);
        rptDoc.VerifyDatabase();
    }
    catch (Exception ex) { rptDoc.Close(); }
    rptDoc.SaveAs("D:\\Temp_02\\Report2_Test.rpt");
    rptDoc.Close();
}
</code>```

It is not the best way. The method SetSQLCommand does not work when the query has any parameters. Even if you set value for each parameter, SetSQLCommand does not work. The example with a parameter which does not work:

```<code>private void button_Test_Click(object sender, EventArgs e)
{
    ReportDocument rptDoc = new ReportDocument();
    rptDoc.Load("D:\\Temp_01\\Report1_Test.rpt");
    rptDoc.SetDatabaseLogon("User", "Password", "ServName", "DBName");
    CrystalDecisions.Shared.ConnectionInfo ConnInf;
    ConnInf = rptDoc.Database.Tables[0].LogOnInfo.ConnectionInfo;
    String strSQLQuery = "SELECT TOP(1) * FROM sys.all_objects WHERE name = {?strName}";
    String strTableName = rptDoc.Database.Tables[0].Name;
    try
    {
        rptDoc.SetParameterValue("strName", "Text");
        rptDoc.SetSQLCommandTable(ConnInf, strTableName, strSQLQuery);
        rptDoc.VerifyDatabase();
    }
    catch (Exception ex) { rptDoc.Close(); }
    rptDoc.SaveAs("D:\\Temp_02\\Report2_Test.rpt");
    rptDoc.Close();
}
</code>```

It returns an error. This method does not work with parameters!

Second way:

```<code>private void button_Test_Click(object sender, EventArgs e)
{
    ReportDocument rptDoc = new ReportDocument();
    rptDoc.Load("D:\\Temp_01\\Report1_Test.rpt");
    rptDoc.SetDatabaseLogon("User", "Password", "ServName", "DBName");
    ISCDReportClientDocument rcd = null;
    rcd = rptDoc.ReportClientDocument as ISCDReportClientDocument;
    CommandTable rTblOld;
    CommandTable rTblNew;
    rTblOld = rcd.Database.Tables[0] as CommandTable;
    rTblNew = rcd.Database.Tables[0].Clone(true) as CommandTable;
    rTblNew.CommandText = "SELECT TOP(1) * FROM sys.all_objects";
    try
    {
        rcd.DatabaseController.SetTableLocationEx(rTblOld, rTblNew);
        rcd.VerifyDatabase();
    }
    catch (Exception ex) { rcd.Close(); }
    rcd.SaveAs(rcd.DisplayName, "D:\\Temp_02\\", 1);
    rcd.Close();
}
</code>```

This is also not the best way. The method SetLocalTableEx does a struct of the report is bad. After run SetLocalTableEx, attribute ConnectionInf.UserId have value NULL also the Name of connection

After SetTableLocationEx:

```<code>rcd.DatabaseController.SetTableLocationEx(rTblOld, rTblNew);
String UserID;
UserID = rptDoc.Database.Tables[0].LogOnInfo.ConnectionInfo.UserID;
if (UserID == null) MessageBox.Show("UserID has NULL");
</code>```

UserId has value NULL

Also, before run SetTableLocationEx, Connection Name is MSODBCSQL11
enter image description here

After run SetTableLocationEx, Connection Name is Command
enter image description here

So,
how do dynamic and correctly to change the query in CommandTable for Crystal Reports file?

Thanks,
Artem

答:
You are using command in Crystal Report which is the best way when doing and displaying a data from database to crystal report but unfortunately you do it in Code Behind.

My Question is:

Why don't you do it in Command of Crystal Report itself?

see this link for more info.

Body:
I have many rpt files. I want to change the query for each report using C#. There are several ways to do this changes.

First way:

private void button_Test_Click(object sender, EventArgs e)
{
    ReportDocument rptDoc = new ReportDocument();
    rptDoc.Load("D:\\Temp_01\\Report1_Test.rpt");
    rptDoc.SetDatabaseLogon("User", "Password", "ServName", "DBName");
    CrystalDecisions.Shared.ConnectionInfo ConnInf;
    ConnInf = rptDoc.Database.Tables[0].LogOnInfo.ConnectionInfo;
    String strSQLQuery = "SELECT TOP(123) * FROM sys.all_objects";
    String strTableName = rptDoc.Database.Tables[0].Name;
    try
    {
        rptDoc.SetSQLCommandTable(ConnInf, strTableName, strSQLQuery);
        rptDoc.VerifyDatabase();
    }
    catch (Exception ex) { rptDoc.Close(); }
    rptDoc.SaveAs("D:\\Temp_02\\Report2_Test.rpt");
    rptDoc.Close();
}

It is not the best way. The method SetSQLCommand does not work when the query has any parameters. Even if you set value for each parameter, SetSQLCommand does not work. The example with a parameter which does not work:

private void button_Test_Click(object sender, EventArgs e)
{
    ReportDocument rptDoc = new ReportDocument();
    rptDoc.Load("D:\\Temp_01\\Report1_Test.rpt");
    rptDoc.SetDatabaseLogon("User", "Password", "ServName", "DBName");
    CrystalDecisions.Shared.ConnectionInfo ConnInf;
    ConnInf = rptDoc.Database.Tables[0].LogOnInfo.ConnectionInfo;
    String strSQLQuery = "SELECT TOP(1) * FROM sys.all_objects WHERE name = {?strName}";
    String strTableName = rptDoc.Database.Tables[0].Name;
    try
    {
        rptDoc.SetParameterValue("strName", "Text");
        rptDoc.SetSQLCommandTable(ConnInf, strTableName, strSQLQuery);
        rptDoc.VerifyDatabase();
    }
    catch (Exception ex) { rptDoc.Close(); }
    rptDoc.SaveAs("D:\\Temp_02\\Report2_Test.rpt");
    rptDoc.Close();
}

It returns an error. This method does not work with parameters!

Second way:

private void button_Test_Click(object sender, EventArgs e)
{
    ReportDocument rptDoc = new ReportDocument();
    rptDoc.Load("D:\\Temp_01\\Report1_Test.rpt");
    rptDoc.SetDatabaseLogon("User", "Password", "ServName", "DBName");
    ISCDReportClientDocument rcd = null;
    rcd = rptDoc.ReportClientDocument as ISCDReportClientDocument;
    CommandTable rTblOld;
    CommandTable rTblNew;
    rTblOld = rcd.Database.Tables[0] as CommandTable;
    rTblNew = rcd.Database.Tables[0].Clone(true) as CommandTable;
    rTblNew.CommandText = "SELECT TOP(1) * FROM sys.all_objects";
    try
    {
        rcd.DatabaseController.SetTableLocationEx(rTblOld, rTblNew);
        rcd.VerifyDatabase();
    }
    catch (Exception ex) { rcd.Close(); }
    rcd.SaveAs(rcd.DisplayName, "D:\\Temp_02\\", 1);
    rcd.Close();
}

This is also not the best way. The method SetLocalTableEx does a struct of the report is bad. After run SetLocalTableEx, attribute ConnectionInf.UserId have value NULL also the Name of connection

After SetTableLocationEx:

rcd.DatabaseController.SetTableLocationEx(rTblOld, rTblNew);
String UserID;
UserID = rptDoc.Database.Tables[0].LogOnInfo.ConnectionInfo.UserID;
if (UserID == null) MessageBox.Show("UserID has NULL");

UserId has value NULL

Also, before run SetTableLocationEx, Connection Name is MSODBCSQL11
enter image description here

After run SetTableLocationEx, Connection Name is Command
enter image description here

So,
how do dynamic and correctly to change the query in CommandTable for Crystal Reports file?

Thanks,
Artem


问:
Asp.net C# InputBox only accepts numbers
my question is simple, I need to know how to only allow integers to my InputBox in ASP.Net C#, without that tag thing , is there any other way ?

Thank you guys

答:
The code is :

```<code>function numericFilter(txb) {
   txb.value = txb.value.replace(/[^\0-9]/ig, "");
}
</code>```

call it in on key up

```<code><input type="text" onKeyUp="numericFilter(this);" />
</code>```

Body:
The code is :

function numericFilter(txb) {
   txb.value = txb.value.replace(/[^\0-9]/ig, "");
}

call it in on key up

<input type="text" onKeyUp="numericFilter(this);" />


问:
Multiple search view for single array list model class data
I have a model class array list with field name, code and mobile. I want to use search view for all. For example, if I write in name search view xyz and in mobile search view 9768 then it gives all the match of xyz and 9768.</p>

```<code> searchMasterList2.add(new SearchItemMaster("111", "222", "333"));
        searchMasterList2.add(new SearchItemMaster("555", "333", "444"));
        searchMasterList2.add(new SearchItemMaster("222", "444", "555"));
        searchMasterList2.add(new SearchItemMaster("333", "111", "222"));
        searchMasterList2.add(new SearchItemMaster("444", "555", "111"));

        final android.support.v7.widget.SearchView searchView1 = (android.support.v7.widget.SearchView) getView().findViewById(R.id.item_name_edtv);

        searchView1.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                is_click_search_item=true;
                is_click_search_group=false;
            }
        });
        searchView1.setOnQueryTextListener(this);
        searchView1.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                is_click_search_item=true;
                is_click_search_group=false;
            }
        });
        final android.support.v7.widget.SearchView searchView2 = (android.support.v7.widget.SearchView) getView().findViewById(R.id.group_edtv);
        searchView2.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                is_click_search_item=false;
                is_click_search_group=true;

            }
        });

        searchView2.setOnQueryTextListener(this);
        searchView2.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                is_click_search_item=false;
                is_click_search_group=true;

            }
        });

     @Override
        public boolean onQueryTextChange(String newText) {

            final List<SearchItemMaster> filteredModelList = filter(searchMasterList2, newText);
            Log.v("App", newText + ", " + searchMasterList2.size() + ", " + filteredModelList.size());
            adapter.animateTo(filteredModelList);
            recyclerView.scrollToPosition(0);
            return false;
        }

 private List<SearchItemMaster> filter(List<SearchItemMaster> numbers, String input_text) {
        input_text = input_text.toLowerCase();
        ArrayList<SearchItemMaster> filteredCompanyList = new ArrayList<>();
        for (SearchItemMaster searchItemMaster : numbers) {

            if (is_click_search_group) {
                final String moblieNo = searchItemMaster.getMoblieNo();
                if (moblieNo.contains(input_text)) {
                    filteredCompanyList.add(searchItemMaster);
                }
            }

            if (is_click_search_item) {

                final String code = searchItemMaster.getCode().toLowerCase();
                if (code.contains(input_text)) {
                    filteredCompanyList.add(searchItemMaster);
                }
            }
        }

        return filteredCompanyList;
    }
</code>```

答:
** i changed following code and working fine for me **</p>

```<code>  ArrayList<SearchItemMaster> searchMasterList2 = new ArrayList<>();
    ArrayList<SearchItemMaster> filteredCompanyList1 = new ArrayList<>();
    ArrayList<SearchItemMaster> filteredCompanyList2 = new ArrayList<>();

     @Override
        public boolean onQueryTextChange(String newText) {
        if(is_click_search_item){
            filteredCompanyList1.clear();
        }
            if(is_click_search_group){
                filteredCompanyList2.clear();
            }
            final List<SearchItemMaster> filteredModelList = filter(searchMasterList2, newText);
            Log.v("App", newText + ", " + searchMasterList2.size() + ", " + filteredModelList.size());
            adapter.animateTo(filteredModelList);
            recyclerView.scrollToPosition(0);
            return false;
        }

        for (SearchItemMaster searchItemMaster : numbers) {

                    if (is_click_search_group) {
                        final String moblieNo = searchItemMaster.getMoblieNo().toLowerCase();;
                        if (moblieNo.contains(input_text)) {
                            filteredCompanyList2.add(searchItemMaster);
                            if(filteredCompanyList1.size()!=0) {
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(filteredCompanyList1);
                            }
                            else{
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(searchMasterList2);
                            }
                        }
                    }

                    if (is_click_search_item) {
                        final String code = searchItemMaster.getCode().toLowerCase();
                        if (code.contains(input_text)) {
                            filteredCompanyList1.add(searchItemMaster);
                            if(filteredCompanyList2.size()!=0){
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(filteredCompanyList2);
                            }
                            else{
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(searchMasterList2);
                            }
                        }
                    }
                }
</code>```

Body:
I have a model class array list with field name, code and mobile. I want to use search view for all. For example, if I write in name search view xyz and in mobile search view 9768 then it gives all the match of xyz and 9768.

 searchMasterList2.add(new SearchItemMaster("111", "222", "333"));
        searchMasterList2.add(new SearchItemMaster("555", "333", "444"));
        searchMasterList2.add(new SearchItemMaster("222", "444", "555"));
        searchMasterList2.add(new SearchItemMaster("333", "111", "222"));
        searchMasterList2.add(new SearchItemMaster("444", "555", "111"));

        final android.support.v7.widget.SearchView searchView1 = (android.support.v7.widget.SearchView) getView().findViewById(R.id.item_name_edtv);

        searchView1.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                is_click_search_item=true;
                is_click_search_group=false;
            }
        });
        searchView1.setOnQueryTextListener(this);
        searchView1.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                is_click_search_item=true;
                is_click_search_group=false;
            }
        });
        final android.support.v7.widget.SearchView searchView2 = (android.support.v7.widget.SearchView) getView().findViewById(R.id.group_edtv);
        searchView2.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                is_click_search_item=false;
                is_click_search_group=true;

            }
        });

        searchView2.setOnQueryTextListener(this);
        searchView2.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                is_click_search_item=false;
                is_click_search_group=true;

            }
        });

     @Override
        public boolean onQueryTextChange(String newText) {

            final List<SearchItemMaster> filteredModelList = filter(searchMasterList2, newText);
            Log.v("App", newText + ", " + searchMasterList2.size() + ", " + filteredModelList.size());
            adapter.animateTo(filteredModelList);
            recyclerView.scrollToPosition(0);
            return false;
        }

 private List<SearchItemMaster> filter(List<SearchItemMaster> numbers, String input_text) {
        input_text = input_text.toLowerCase();
        ArrayList<SearchItemMaster> filteredCompanyList = new ArrayList<>();
        for (SearchItemMaster searchItemMaster : numbers) {

            if (is_click_search_group) {
                final String moblieNo = searchItemMaster.getMoblieNo();
                if (moblieNo.contains(input_text)) {
                    filteredCompanyList.add(searchItemMaster);
                }
            }

            if (is_click_search_item) {

                final String code = searchItemMaster.getCode().toLowerCase();
                if (code.contains(input_text)) {
                    filteredCompanyList.add(searchItemMaster);
                }
            }
        }

        return filteredCompanyList;
    }

Body:
** i changed following code and working fine for me **

  ArrayList<SearchItemMaster> searchMasterList2 = new ArrayList<>();
    ArrayList<SearchItemMaster> filteredCompanyList1 = new ArrayList<>();
    ArrayList<SearchItemMaster> filteredCompanyList2 = new ArrayList<>();

     @Override
        public boolean onQueryTextChange(String newText) {
        if(is_click_search_item){
            filteredCompanyList1.clear();
        }
            if(is_click_search_group){
                filteredCompanyList2.clear();
            }
            final List<SearchItemMaster> filteredModelList = filter(searchMasterList2, newText);
            Log.v("App", newText + ", " + searchMasterList2.size() + ", " + filteredModelList.size());
            adapter.animateTo(filteredModelList);
            recyclerView.scrollToPosition(0);
            return false;
        }

        for (SearchItemMaster searchItemMaster : numbers) {

                    if (is_click_search_group) {
                        final String moblieNo = searchItemMaster.getMoblieNo().toLowerCase();;
                        if (moblieNo.contains(input_text)) {
                            filteredCompanyList2.add(searchItemMaster);
                            if(filteredCompanyList1.size()!=0) {
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(filteredCompanyList1);
                            }
                            else{
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(searchMasterList2);
                            }
                        }
                    }

                    if (is_click_search_item) {
                        final String code = searchItemMaster.getCode().toLowerCase();
                        if (code.contains(input_text)) {
                            filteredCompanyList1.add(searchItemMaster);
                            if(filteredCompanyList2.size()!=0){
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(filteredCompanyList2);
                            }
                            else{
                                filteredCompanyList.add(searchItemMaster);
                                filteredCompanyList.retainAll(searchMasterList2);
                            }
                        }
                    }
                }


问:
Can I know when will be the Kubernetes Cron Jobs beta/GA release?
Can someone please let us know the roadmap? I want to use Cron Jobs and get statistics features</p>

答: You can track this issue: https://github.com/kubernetes/kubernetes/issues/41039 . This is about the topic Migrate CronJobs to beta


问:
Unity3d Render openGL FBO to texture in android (java)
I'm trying to make a plugin in Android (java) for Unity3D to render using an OpenGL texture, get the native pointer and maping a Quad in Unity. So far my Unity code is simple:

```<code>    // Use this for initialization
void Start () {
    AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    context = jc.GetStatic<AndroidJavaObject>("currentActivity");
    surface2Unity = new AndroidJavaObject("com.everywoah.surface2unity.Surface2Unity");

    int i = surface2Unity.Call<int> ("getTextureID");
    t =Texture2D.CreateExternalTexture (1280, 720, TextureFormat.ARGB32, false,false, new IntPtr(i));
    t.filterMode = FilterMode.Bilinear;
    t.wrapMode = TextureWrapMode.Repeat;
    debug.text = "" + i;
    GetComponent<MeshRenderer> ().material.mainTexture = t;
}

// Update is called once per frame
void Update () {
    //transform.Rotate(1f,1f,1f);
    surface2Unity.Call ("draw");
}
</code>```

And in Java I have:

```<code>public MyRenderer(){
    initGL();
    initFBO();
}

private void initGL(){
    GLstatics.checkGlError("initGL_S");

    String vertexShader = "attribute vec4 aPosition;\n" +
            "attribute vec4 aTex;\n" +
            "varying vec2 tex;\n" +
            "void main() {\n" +
            "    gl_Position = aPosition;\n" +
            "tex=aTex.xy;\n" +
            "}";

    String fragmentShader = "precision mediump float;\n" +
            "\n" +
            "void main(){\n" +
            "        gl_FragColor = vec4(1.0,1.0,0.0,1.0);\n" +
            "\n" +
            "}";

    mProgram         = GLstatics.createProgram(vertexShader, fragmentShader);
    maPositionHandle = GLES30.glGetAttribLocation(mProgram, "aPosition");
    maTexHandle = GLES30.glGetAttribLocation(mProgram, "aTex");

    GLstatics.checkGlError("initGL_E");

}

private void initFBO(){
    GLstatics.checkGlError("initFBO_S");

    GLES30.glGenFramebuffers(1, mFboId, 0);
    GLES30.glGenRenderbuffers(1, mRboId, 0);
    GLES30.glGenTextures(1, mTexId, 0);

    GLES30.glGenBuffers(1,buffer, 0);

    GLES30.glBindRenderbuffer(GLES30.GL_RENDERBUFFER, mRboId[0]);
    GLES30.glRenderbufferStorage(GLES30.GL_RENDERBUFFER, GLES30.GL_DEPTH_COMPONENT16, 1280,
            720);

    GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFboId[0]);
    GLES30.glFramebufferRenderbuffer(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT,
            GLES30.GL_RENDERBUFFER, mRboId[0]);

    GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
    GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mTexId[0]);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE);

    GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, 1280, 720, 0,
            GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null);

    GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0,
            GLES30.GL_TEXTURE_2D, mTexId[0], 0);
    GLstatics.checkGlError("initFBO_E ");
}

public void draw() {
    GLstatics.checkGlError("draw_S");

    GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFboId[0]);
    GLES30.glClearColor(0.0f,0.0f,1.0f,1.0f);

    GLES30.glViewport(0, 0, 1280, 720);

    GLES30.glClear(GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);

    GLES30.glUseProgram(mProgram);

    mVtxBuf.position(0);
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, buffer[0]);

    GLES30.glVertexAttribPointer(maPositionHandle,
            3, GLES30.GL_FLOAT, false, 4*(3+2), mVtxBuf);
    GLES30.glEnableVertexAttribArray(maPositionHandle);

    mVtxBuf.position(3);
    GLES30.glVertexAttribPointer(maTexHandle, 2, GLES30.GL_FLOAT, false, 4 * (3 + 2), mVtxBuf);
    GLES30.glEnableVertexAttribArray(maTexHandle);

    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);

    GLstatics.checkGlError("draw_E ");
}
</code>```

It should be a really simple code, just drawing a yellow rectangle in a blue background, and I can make it work in an Activity. The problem here is that my app looks like this:

From where I think I'm messing with openGL buffers already bound, cause the vertices of my rectangle are drawn but with a weird thing inside. I've tried saving them and binding them after the draw function but I'm having the same result. Any ideas what I'm doing wrong? If possible I'd really like to solve this in Java, I have up to 0 experience using the NDK.

答:
Java side:

```<code>public int loadImageReturnTexturePtr(String imagePath, int width, int heigh) {
    Log.d("unity", "loading image1: " + imagePath);

    Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
    Log.d("unity", "Bitmap is: " + bitmap);

    int textures[] = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    int textureId = textures[0];

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, heigh, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap,0);

    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
    Log.d("unity", "texture id returned: " + textureId);

    return textureId;
}
</code>```

unity c# side:

```<code>// Use this for initialization
void Start ()
{
    AndroidJavaObject mImageLoader = new AndroidJavaObject ("com.dvision.load.LoadTexture");
    Texture2D texture2D = new Texture2D (2048, 2048, TextureFormat.ARGB32, false);

    int texPtr = mImageLoader.Call <int> ("loadImageReturnTexturePtr", "/sdcard/Lfront.jpg", 2048, 2048);
    Debug.Log ("texture pointer? " + texPtr);
    Texture2D nativeTexture = Texture2D.CreateExternalTexture (2048, 2048, TextureFormat.ARGB32, false, true, new System.IntPtr (texPtr));
    texture2D.UpdateExternalTexture (nativeTexture.GetNativeTexturePtr ());
    gameObject.GetComponent<Renderer> ().material.mainTexture = texture2D;
}
</code>```

you can use the function: Texture2D.CreateExternalTexture
It is so simple to do it.

Body:
I'm trying to make a plugin in Android (java) for Unity3D to render using an OpenGL texture, get the native pointer and maping a Quad in Unity. So far my Unity code is simple:

    // Use this for initialization
void Start () {
    AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    context = jc.GetStatic<AndroidJavaObject>("currentActivity");
    surface2Unity = new AndroidJavaObject("com.everywoah.surface2unity.Surface2Unity");

    int i = surface2Unity.Call<int> ("getTextureID");
    t =Texture2D.CreateExternalTexture (1280, 720, TextureFormat.ARGB32, false,false, new IntPtr(i));
    t.filterMode = FilterMode.Bilinear;
    t.wrapMode = TextureWrapMode.Repeat;
    debug.text = "" + i;
    GetComponent<MeshRenderer> ().material.mainTexture = t;
}

// Update is called once per frame
void Update () {
    //transform.Rotate(1f,1f,1f);
    surface2Unity.Call ("draw");
}

And in Java I have:

public MyRenderer(){
    initGL();
    initFBO();
}

private void initGL(){
    GLstatics.checkGlError("initGL_S");

    String vertexShader = "attribute vec4 aPosition;\n" +
            "attribute vec4 aTex;\n" +
            "varying vec2 tex;\n" +
            "void main() {\n" +
            "    gl_Position = aPosition;\n" +
            "tex=aTex.xy;\n" +
            "}";

    String fragmentShader = "precision mediump float;\n" +
            "\n" +
            "void main(){\n" +
            "        gl_FragColor = vec4(1.0,1.0,0.0,1.0);\n" +
            "\n" +
            "}";

    mProgram         = GLstatics.createProgram(vertexShader, fragmentShader);
    maPositionHandle = GLES30.glGetAttribLocation(mProgram, "aPosition");
    maTexHandle = GLES30.glGetAttribLocation(mProgram, "aTex");

    GLstatics.checkGlError("initGL_E");

}

private void initFBO(){
    GLstatics.checkGlError("initFBO_S");

    GLES30.glGenFramebuffers(1, mFboId, 0);
    GLES30.glGenRenderbuffers(1, mRboId, 0);
    GLES30.glGenTextures(1, mTexId, 0);

    GLES30.glGenBuffers(1,buffer, 0);

    GLES30.glBindRenderbuffer(GLES30.GL_RENDERBUFFER, mRboId[0]);
    GLES30.glRenderbufferStorage(GLES30.GL_RENDERBUFFER, GLES30.GL_DEPTH_COMPONENT16, 1280,
            720);

    GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFboId[0]);
    GLES30.glFramebufferRenderbuffer(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT,
            GLES30.GL_RENDERBUFFER, mRboId[0]);

    GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
    GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mTexId[0]);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE);
    GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE);

    GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, 1280, 720, 0,
            GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null);

    GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0,
            GLES30.GL_TEXTURE_2D, mTexId[0], 0);
    GLstatics.checkGlError("initFBO_E ");
}

public void draw() {
    GLstatics.checkGlError("draw_S");

    GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFboId[0]);
    GLES30.glClearColor(0.0f,0.0f,1.0f,1.0f);

    GLES30.glViewport(0, 0, 1280, 720);

    GLES30.glClear(GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);

    GLES30.glUseProgram(mProgram);

    mVtxBuf.position(0);
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, buffer[0]);

    GLES30.glVertexAttribPointer(maPositionHandle,
            3, GLES30.GL_FLOAT, false, 4*(3+2), mVtxBuf);
    GLES30.glEnableVertexAttribArray(maPositionHandle);

    mVtxBuf.position(3);
    GLES30.glVertexAttribPointer(maTexHandle, 2, GLES30.GL_FLOAT, false, 4 * (3 + 2), mVtxBuf);
    GLES30.glEnableVertexAttribArray(maTexHandle);

    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);

    GLstatics.checkGlError("draw_E ");
}

It should be a really simple code, just drawing a yellow rectangle in a blue background, and I can make it work in an Activity. The problem here is that my app looks like this:

From where I think I'm messing with openGL buffers already bound, cause the vertices of my rectangle are drawn but with a weird thing inside. I've tried saving them and binding them after the draw function but I'm having the same result. Any ideas what I'm doing wrong? If possible I'd really like to solve this in Java, I have up to 0 experience using the NDK.

Body:
Java side:

public int loadImageReturnTexturePtr(String imagePath, int width, int heigh) {
    Log.d("unity", "loading image1: " + imagePath);

    Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
    Log.d("unity", "Bitmap is: " + bitmap);

    int textures[] = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    int textureId = textures[0];

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, heigh, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap,0);

    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
    Log.d("unity", "texture id returned: " + textureId);

    return textureId;
}

unity c# side:

// Use this for initialization
void Start ()
{
    AndroidJavaObject mImageLoader = new AndroidJavaObject ("com.dvision.load.LoadTexture");
    Texture2D texture2D = new Texture2D (2048, 2048, TextureFormat.ARGB32, false);

    int texPtr = mImageLoader.Call <int> ("loadImageReturnTexturePtr", "/sdcard/Lfront.jpg", 2048, 2048);
    Debug.Log ("texture pointer? " + texPtr);
    Texture2D nativeTexture = Texture2D.CreateExternalTexture (2048, 2048, TextureFormat.ARGB32, false, true, new System.IntPtr (texPtr));
    texture2D.UpdateExternalTexture (nativeTexture.GetNativeTexturePtr ());
    gameObject.GetComponent<Renderer> ().material.mainTexture = texture2D;
}

you can use the function: Texture2D.CreateExternalTexture
It is so simple to do it.

ContentLicense: CC BY-SA 4.0


问:
Adding Action to button in HTML
```<code><html>
<%@ page import="java.sql.*" %>
<head>
<title>Sarvotam List</title>
<link rel="stylesheet" href="Styles/main.css">
</head>
<body>
<div class="seg">
    <form action="main.jsp" method="post">
    <table class="data" align="center" width=80%>
        <tr>
            <th width=20%>Qualification Exam</th>
            <th width=20%>Course Type</th>
            <th width=20%>Duration</th>
            <th width=20%>Number of Cheques</th>
            <th width=20%>Course_Category</th>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual"
  width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype"
  width=20%></td>
            <td width=20% align="center"><input type="number" name="dur"
  width=20%></td>
            <td width=20% align="center"><input type="number" name="che"
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual"
 width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype"
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur"
     width=20%></td>
            <td width=20% align="center"><input type="number" name="che"
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual"
width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype"
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur"
width=20%></td>
            <td width=20% align="center"><input type="number" name="che"
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual"
width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype"
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur"
width=20%></td>
            <td width=20% align="center"><input type="number" name="che"
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual"
  width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype"
 width=20%></td>
            <td width=20% align="center"><input type="number" name="dur"
    width=20%></td>
            <td width=20% align="center"><input type="number" name="che"
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
            </table>
        <center><button id="submit" name="save">Submit</button></center>

<%              try{
    ResultSet rs=null;
    Statement st=null;
    Connection conn = null;
    Class.forName("oracle.jdbc.driver.OracleDriver");
            conn =
   DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE",
   "system", "parents94");
            st=conn.createStatement();
            int i=0;
            String s = request.getParameter("save");
            String[] qual=request.getParameterValues("qual");
            String[] ctype=request.getParameterValues("ctype");
            String[] dur=request.getParameterValues("dur");
            String[] noc=request.getParameterValues("che");
            String[] cou=request.getParamterValues("opt");
            if(s!=null)
            while(qual[i].length()!=0){
                st.executeUpdate("insert into SCHOL_COURSE_MASTER values('"+qual[i]+"','"+ctype[i]+"','"+dur[i]+"','"+noc[i]+"','"+cou[i]+"')");
                i++;
            }
        conn.close();
        st.close();
            }
catch(Exception e)
    {
        e.getMessage();
    }
%>
</form>
</div>
  </body>
 </html>
</code>```

This is my code
I need to take inputs from user in the table and add to the database
All the connections work
But the sql query does not lead to any changes in the data base
I just need help in how to code it to work on press of submit button

答:
Add submit type to button:</p>

```<code><center>
    <button type="submit" id="submit" name="save">Submit</button>
</center>
</code>```

Title: Adding Action to button in HTML

Body:
<%@ page import="java.sql.*" %>

<title>Sarvotam List</title>
<link rel="stylesheet" href="Styles/main.css">

    <form action="main.jsp" method="post">

            Qualification Exam
            Course Type
            Duration
            Number of Cheques
            Course_Category

            <input type="text" name="qual"
  width=20%>
            <input type="text" name="ctype"
  width=20%>
            <input type="number" name="dur"
  width=20%>
            <input type="number" name="che"
width=20%>
            <select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>

            <input type="text" name="qual"
 width=20%>
            <input type="text" name="ctype"
width=20%>
            <input type="number" name="dur"
     width=20%>
            <input type="number" name="che"
width=20%>
            <select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>

            <input type="text" name="qual"
width=20%>
            <input type="text" name="ctype"
width=20%>
            <input type="number" name="dur"
width=20%>
            <input type="number" name="che"
width=20%>
            <select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>

            <input type="text" name="qual"
width=20%>
            <input type="text" name="ctype"
width=20%>
            <input type="number" name="dur"
width=20%>
            <input type="number" name="che"
width=20%>
            <select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>

            <input type="text" name="qual"
  width=20%>
            <input type="text" name="ctype"
 width=20%>
            <input type="number" name="dur"
    width=20%>
            <input type="number" name="che"
width=20%>
            <select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>

        <button id="submit" name="save">Submit</button>

<%              try{
    ResultSet rs=null;
    Statement st=null;
    Connection conn = null;
    Class.forName("oracle.jdbc.driver.OracleDriver");
            conn =
   DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE",
   "system", "parents94");
            st=conn.createStatement();
            int i=0;
            String s = request.getParameter("save");
            String[] qual=request.getParameterValues("qual");
            String[] ctype=request.getParameterValues("ctype");
            String[] dur=request.getParameterValues("dur");
            String[] noc=request.getParameterValues("che");
            String[] cou=request.getParamterValues("opt");
            if(s!=null)
            while(qual[i].length()!=0){
                st.executeUpdate("insert into SCHOL_COURSE_MASTER values('"+qual[i]+"','"+ctype[i]+"','"+dur[i]+"','"+noc[i]+"','"+cou[i]+"')");
                i++;
            }
        conn.close();
        st.close();
            }
catch(Exception e)
    {
        e.getMessage();
    }
%>
</form>

This is my code
I need to take inputs from user in the table and add to the database
All the connections work
But the sql query does not lead to any changes in the data base
I just need help in how to code it to work on press of submit button

Body:
Add submit type to button:

<center>
    <button type="submit" id="submit" name="save">Submit</button>
</center>


问:
Simulate button click inside browser
I want to open default browser in my computer and then simulate to click the button. I have created a new console application as below:

```<code>class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        var url = "http://google.com";
        Process.Start(url);
        Console.ReadKey();
    }
}
</code>```

Now what can I do? I found WebBrowser class but I think it's for browser control in windows forms app..

答:
Get default browser using the below function

```<code>private static string GetStandardBrowserPath()
{
string browserPath = string.Empty;
RegistryKey browserKey = null;

try
{
    //Read default browser path from Win XP registry key
    browserKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);

    //If browser path wasn't found, try Win Vista (and newer) registry key
    if (browserKey == null)
    {
        browserKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http", false); ;
    }

    //If browser path was found, clean it
    if (browserKey != null)
    {
        //Remove quotation marks
        browserPath = (browserKey.GetValue(null) as string).ToLower().Replace("\"", "");

        //Cut off optional parameters
        if (!browserPath.EndsWith("exe"))
        {
            browserPath = browserPath.Substring(0, browserPath.LastIndexOf(".exe") + 4);
        }

        //Close registry key
        browserKey.Close();
    }
}
catch
{
    //Return empty string, if no path was found
    return string.Empty;
}
//Return default browsers path
return browserPath;
}
</code>```

Open url in default browser:

```<code>string url = "http://google.com";
string browserPath = GetStandardBrowserPath();
if (string.IsNullOrEmpty(browserPath))
{
    MessageBox.Show("No default browser found!");
}
else
{
    Process.Start(browserPath, url);
}
</code>```

Title: Simulate button click inside browser

Body:
I want to open default browser in my computer and then simulate to click the button. I have created a new console application as below:

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        var url = "http://google.com";
        Process.Start(url);
        Console.ReadKey();
    }
}

Now what can I do? I found WebBrowser class but I think it's for browser control in windows forms app..

Body:
Get default browser using the below function

private static string GetStandardBrowserPath()
{
string browserPath = string.Empty;
RegistryKey browserKey = null;

try
{
    //Read default browser path from Win XP registry key
    browserKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);

    //If browser path wasn't found, try Win Vista (and newer) registry key
    if (browserKey == null)
    {
        browserKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http", false); ;
    }

    //If browser path was found, clean it
    if (browserKey != null)
    {
        //Remove quotation marks
        browserPath = (browserKey.GetValue(null) as string).ToLower().Replace("\"", "");

        //Cut off optional parameters
        if (!browserPath.EndsWith("exe"))
        {
            browserPath = browserPath.Substring(0, browserPath.LastIndexOf(".exe") + 4);
        }

        //Close registry key
        browserKey.Close();
    }
}
catch
{
    //Return empty string, if no path was found
    return string.Empty;
}
//Return default browsers path
return browserPath;
}

Open url in default browser:

string url = "http://google.com";
string browserPath = GetStandardBrowserPath();
if (string.IsNullOrEmpty(browserPath))
{
    MessageBox.Show("No default browser found!");
}
else
{
    Process.Start(browserPath, url);
}


答:
```<code><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="TextBox1" runat="server" ErrorMessage="Only Numbers allowed" ValidationExpression="\d+"></asp:RegularExpressionValidator>
</code>```

Title: Asp.net C# InputBox only accepts numbers

Body:
my question is simple, I need to know how to only allow integers to my InputBox in ASP.Net C#, without that tag thing , is there any other way ?

Thank you guys


问:
Visual Studio 2012 macros uses VS2010 values
My working computer had Visual Studio 2010 installed previously. It was working fine.

To gain full support for C++11, the 2012 was installed to this computer recently (VS2010 was not removed, since some old project need it).

My problem is:
If I launch VS2012, the Visual Studio user values (e.G. $(VSInstallDir), $(VCInstallDir), $(ExecutablePath) etc.) are the VS2010's values, not the values suitable for VS2012.

What is the reason for it? And how can I solve this problem? The VS2012 must use its' own user values.

答:
Since multiple installations are there, you can select the Platform Toolset from

Project Property Pages\ Configuration Properties\General\Platform Toolset

If it still doesn't work, do the following as last resort:

Edit the following file to change the macros:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Common.props

For me it is V120. Whatever version it is for you, change it accordingly.


问:
Compile errors when using C# 7 features in new VS Studio 2017 ASP.NET MVC 5.2.3 project
I'm using VS 2017 usually for console applications. But now I have to create a new ASP.NET MVC project and found something curious.

Auto generation of getter and setter (context menu "Quick actions and refactoring < Ecapsulate field (and use property)") raise a compiling error. To give an easy example:

```<code>public class Person
{
    private string firstname;

    public string Firstname { get => firstname; set => firstname = value; }
}
</code>```

Error message:

```<code>1>------ Build started: Project: DummyASPNETMVC, Configuration: Debug Any CPU ------
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(12,39,12,41): error CS1043: { or ; expected
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(12,39,12,41): error CS1513: } expected
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(14,2,14,2): error CS1513: } expected
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code>```

Uncomment the getter and setter will make the things working again.

I'm wondering because this works fine within a console application. Where's the difference here?

答:
Thanks to Panagiotis and Tetsuya. It was the version of c#.

As a reference to this question, you have to do three things:

Uninstall "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" via Nuget Package Manager and reinstall the newest version (currently the 1.0.4)

After this, update Microsoft.Net.Compilers to the newest version (currently 2.2.0)

Change the c# language via project "properties < build < advanced" to version 7.

done.

Body:
I'm using VS 2017 usually for console applications. But now I have to create a new ASP.NET MVC project and found something curious.

Auto generation of getter and setter (context menu "Quick actions and refactoring < Ecapsulate field (and use property)") raise a compiling error. To give an easy example:

public class Person
{
    private string firstname;

    public string Firstname { get => firstname; set => firstname = value; }
}

Error message:

1>------ Build started: Project: DummyASPNETMVC, Configuration: Debug Any CPU ------
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(12,39,12,41): error CS1043: { or ; expected
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(12,39,12,41): error CS1513: } expected
1>C:\dev\C#\DummyASPNETMVC\DummyASPNETMVC\Models\Person.cs(14,2,14,2): error CS1513: } expected
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Uncomment the getter and setter will make the things working again.

I'm wondering because this works fine within a console application. Where's the difference here?


问:
How do I get the workbench window to open a modal dialog in an Eclipse based project?
In order to open a modal dialog, you need to pass a parent window, and pass the necessary flags for the dialog to be modal of course.

Depending on where you are in the eclipse infrastructure, finding this parent window is not always easy.

How can the parent window be accessed?

答:
The piece of code from the previous answer will work. However, keep in mind you can only open your dialog from the UI thread. If you are opening the dialog from a different thread, e.g. a background process, you need to do something like this:

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
    public void run() {
        Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    }
});
```

Otherwise you will get an exception when creating the dialog.

OwnerDisplayName: Tirno

LastEditorDisplayName: Tirno

Body:
The piece of code from the previous answer will work. However, keep in mind you can only open your dialog from the UI thread. If you are opening the dialog from a different thread, e.g. a background process, you need to do something like this:

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
    public void run() {
        Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    }
});

Otherwise you will get an exception when creating the dialog.

OwnerDisplayName: zvikico


问:
Error uploading ios application to itunesconnect "failed to open ssh session (16)"
I am having a real repetitive issue uploading app to itunesConnect. It does not matter if I use "Application loader" or xcodes "Archive" utility, the result is the same ("failed to open ssh session (16)"). I am doing this on a Computer and network that was used for multiple uploads of applications to  itunesConnect in the past and never having this problem. I even uploaded an application the same day (without problem), but got errors for this app.

I reviewed the detail log and found nothing useful to determine why the problem would happen.

I posted the log at link bellow since it is to long to be posted here

http://pastebin.ca/2801584

I am using:

-java (1.6.0)

-xcode 5.1.1

-appLoader 2.9.1

-osx 10.9.3

what i tried already:

-checked and rechecked application meta data

-tried to upload via different network

-changed app bundle identifier (develop site, itunesconnect and application)

-tried contacting support via itunesConnect (with no response after multiple days).

I thank you for any help you can offer me.

答:
Make sure that all sites are smoothly accessible from your Mac,

http://help.apple.com/itc/apploader/e3#/itc8e7ec5a60


答:
You can use a asp:CompareValidator. Like this:

```<code><asp:TextBox ID="txtTotal" runat="server"></asp:TextBox>
<asp:CompareValidator ID="compTotal"
    runat="server"
    ControlToValidate="txtTotal"
    ErrorMessage="ValueNotNumeric"
    Type="Integer" Operator="DataTypeCheck"></asp:CompareValidator>
</code>```

Body:
You can use a asp:CompareValidator. Like this:

<asp:TextBox ID="txtTotal" runat="server"></asp:TextBox>
<asp:CompareValidator ID="compTotal"
    runat="server"
    ControlToValidate="txtTotal"
    ErrorMessage="ValueNotNumeric"
    Type="Integer" Operator="DataTypeCheck"></asp:CompareValidator>


问:
How to use declared variable for SQL statement by using "IN" condition
I am trying to write some code but it doesn't work. It only those TypeT description. How can I display the TypeT and TypeS condition for below case?

```<code>DECLARE @PaymentType VARCHAR(20) = '';

SELECT @PaymentType = LISTID
FROM LIST
WHERE LISTCONFIG IN ('TypeT', 'TypeS')

SELECT *
FROM LIST
WHERE LISTID IN  (@PaymentType)
</code>```

答:
If you want to do it using IN, you'll have to do it with dynamic SQL. This also means creating the comma separated string. Which is doable, but an easier way is this:

```<code>DECLARE @PaymentType TABLE (ListID INT) ;

INSERT @PaymentType (ListID)
SELECT LISTID FROM LIST WHERE LISTCONFIG IN ('TypeT','TypeS')

SELECT  LST.*
FROM    LIST Lst
JOIN    @PaymentType AS PT
    ON  PT.ListID = Lst.ListID
</code>```

Body:
I am trying to write some code but it doesn't work. It only those TypeT description. How can I display the TypeT and TypeS condition for below case?

DECLARE @PaymentType VARCHAR(20) = '';

SELECT @PaymentType = LISTID
FROM LIST
WHERE LISTCONFIG IN ('TypeT', 'TypeS')

SELECT *
FROM LIST
WHERE LISTID IN  (@PaymentType)

Body:
If you want to do it using IN, you'll have to do it with dynamic SQL. This also means creating the comma separated string. Which is doable, but an easier way is this:

DECLARE @PaymentType TABLE (ListID INT) ;

INSERT @PaymentType (ListID)
SELECT LISTID FROM LIST WHERE LISTCONFIG IN ('TypeT','TypeS')

SELECT  LST.*
FROM    LIST Lst
JOIN    @PaymentType AS PT
    ON  PT.ListID = Lst.ListID


问:
Search for TRUE in a vector containing TRUE / FALSE
```<code>A<-(FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE)
</code>```

<p>I want an efficient way to find if A has TRUE and stop when TRUE is found. </p>

答:
We can use which to find the elements that are TRUE, select the first, sequence it and subset the 'A'

```<code>A[seq_len(which(A)[1])]
</code>```

data

```<code>A <- c(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE)
</code>```

Body:
A<-(FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE)

I want an efficient way to find if A has TRUE and stop when TRUE is found.

Body:
We can use which to find the elements that are TRUE, select the first, sequence it and subset the 'A'

A[seq_len(which(A)[1])]

data

A <- c(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE)


问:
How to convert the text from a label into double
I am new to C# and just started to learn how to code. I was trying to convert and sum an amounts for several items displayed in a label, then displays the total in another label.I used parse to convert the values to double ,but I've frequently got an error message saying that"cannot implicitly convert type int to string.Here is a sample of my code.

```<code>int Cost;

double total = 0;
costLabel.Text = Convert.ToInt32(priceLabel2.Text);
Cost = int.Parse(priceLabel2.Text);
total += double.Parse(priceLabel2.Text);
costLabel.Text = total.ToString("c");
</code>```

can any one help me to solve this problem?

答:
costlLabel.Text is a string and you try to give it an integer value:

```<code>costLabel.Text = Convert.ToInt32(priceLabel2.Text);
</code>```

use this instead:

```<code>costLabel.Text = priceLabel2.Text;
</code>```

Body:
I am new to C# and just started to learn how to code. I was trying to convert and sum an amounts for several items displayed in a label, then displays the total in another label.I used parse to convert the values to double ,but I've frequently got an error message saying that"cannot implicitly convert type int to string.Here is a sample of my code.

int Cost;

double total = 0;
costLabel.Text = Convert.ToInt32(priceLabel2.Text);
Cost = int.Parse(priceLabel2.Text);
total += double.Parse(priceLabel2.Text);
costLabel.Text = total.ToString("c");

can any one help me to solve this problem?

Body:
costlLabel.Text is a string and you try to give it an integer value:

costLabel.Text = Convert.ToInt32(priceLabel2.Text);

use this instead:

costLabel.Text = priceLabel2.Text;


问:
spring security oauth2 manipulate request url before redirect
I have a Vaadin application that is secured using spring security OAuth2. This works fine except for the occasional PUSH or HEARTBEAT endpoint being used to request first and thus triggering the auth process and the user ends up on the wrong page (These endpoints should not be visited directly by the user).

A simple but unsecure fix is to permitAll() on these endpoints. However as this poses a threat I need to close this hole up.

To do this I would like to parse and potentially edit the request url before redirecting to it at successfull auth. How would I go about doing this?

I would guess I need to add a filter somewhere in the chain to intercept the request and edit it. But I'm not sure where.

Here is my client:

```<code>@Configuration
@EnableOAuth2Sso
public class OAuthConfig extends WebSecurityConfigurerAdapter
{

    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        http.csrf().disable()
                .authorizeRequests()
                .antMatchers("/login**").permitAll()
                .antMatchers("/vaadinServlet/PUSH/**").permitAll()          //todo fix this hole
                .antMatchers("/vaadinServlet/HEARTBEAT/**").permitAll()      //todo fix this hole
                .anyRequest().authenticated()
                .and()
                .logout()
                .logoutSuccessUrl("/")
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout"));

    }

    @Override
    public void configure(WebSecurity web) throws Exception
    {
        web.ignoring().antMatchers("/css/*").antMatchers("/VAADIN/**"); // Static resources are ignored
    }

}
</code>```

And the server:

```<code>@Configuration
@EnableAuthorizationServer
public class OAuth2Config extends AuthorizationServerConfigurerAdapter
{
//jwt token stuff & my own client/auth providers. Should not be important.
...
}
</code>```

server login form:

```<code>@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{

    @Autowired
    private RestAuthenticationProvider authenticationProvider;

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception
    {
        auth.authenticationProvider(authenticationProvider);
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        http
                .authorizeRequests()
                .antMatchers(HttpMethod.GET, "/forgetPassword*").permitAll()
                .antMatchers(HttpMethod.POST,"/user/resetPassword*").permitAll()
                .antMatchers(HttpMethod.GET,"/user/changePassword*").permitAll()
                .antMatchers("/user/updatePassword*", "/user/savePassword*", "/updatePassword*")
                .hasAnyAuthority("CHANGE_PASSWORD_PRIVILEGE","ROLE_USER")
                .anyRequest().authenticated()
                .and()
                    .formLogin()
                    .loginPage("/login")
                    .permitAll()
                .and()
                    .csrf().csrfTokenRepository(csrfTokenRepository());
    }

    private CsrfTokenRepository csrfTokenRepository()
    {
        HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
        repository.setHeaderName("X-XSRF-TOKEN");
        return repository;
    }

}
</code>```

答:
Just add some implementation with your project

1: create Authentication Failure handler

```<code>@Component
public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {

    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
        System.out.print("here failure");

        String s=request.getParameter("username");
        setDefaultFailureUrl("/login?error&username="+s);
        super.onAuthenticationFailure(request,response,exception);
    }

}
</code>```

2:  Authentication Success Handler

```<code>@Component
public class CustomAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {

    @Override
    public void onAuthenticationSuccess(HttpServletRequest request , HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        /* custom Block
Do any thing here
  */

        setDefaultTargetUrl("/home/");
        super.onAuthenticationSuccess(request,response,authentication);
    }
}
</code>```

3: access request entry point

```<code>@Component
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        System.out.print("Unauthorized Access");

        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }
}
</code>```

Implement the components as per your requirement.

Body:
I have a Vaadin application that is secured using spring security OAuth2. This works fine except for the occasional PUSH or HEARTBEAT endpoint being used to request first and thus triggering the auth process and the user ends up on the wrong page (These endpoints should not be visited directly by the user).

A simple but unsecure fix is to permitAll() on these endpoints. However as this poses a threat I need to close this hole up.

To do this I would like to parse and potentially edit the request url before redirecting to it at successfull auth. How would I go about doing this?

I would guess I need to add a filter somewhere in the chain to intercept the request and edit it. But I'm not sure where.

Here is my client:

@Configuration
@EnableOAuth2Sso
public class OAuthConfig extends WebSecurityConfigurerAdapter
{

    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        http.csrf().disable()
                .authorizeRequests()
                .antMatchers("/login**").permitAll()
                .antMatchers("/vaadinServlet/PUSH/**").permitAll()          //todo fix this hole
                .antMatchers("/vaadinServlet/HEARTBEAT/**").permitAll()      //todo fix this hole
                .anyRequest().authenticated()
                .and()
                .logout()
                .logoutSuccessUrl("/")
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout"));

    }

    @Override
    public void configure(WebSecurity web) throws Exception
    {
        web.ignoring().antMatchers("/css/*").antMatchers("/VAADIN/**"); // Static resources are ignored
    }

}

And the server:

@Configuration
@EnableAuthorizationServer
public class OAuth2Config extends AuthorizationServerConfigurerAdapter
{
//jwt token stuff & my own client/auth providers. Should not be important.
...
}

server login form:

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{

    @Autowired
    private RestAuthenticationProvider authenticationProvider;

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception
    {
        auth.authenticationProvider(authenticationProvider);
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        http
                .authorizeRequests()
                .antMatchers(HttpMethod.GET, "/forgetPassword*").permitAll()
                .antMatchers(HttpMethod.POST,"/user/resetPassword*").permitAll()
                .antMatchers(HttpMethod.GET,"/user/changePassword*").permitAll()
                .antMatchers("/user/updatePassword*", "/user/savePassword*", "/updatePassword*")
                .hasAnyAuthority("CHANGE_PASSWORD_PRIVILEGE","ROLE_USER")
                .anyRequest().authenticated()
                .and()
                    .formLogin()
                    .loginPage("/login")
                    .permitAll()
                .and()
                    .csrf().csrfTokenRepository(csrfTokenRepository());
    }

    private CsrfTokenRepository csrfTokenRepository()
    {
        HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
        repository.setHeaderName("X-XSRF-TOKEN");
        return repository;
    }

}

Body:
Just add some implementation with your project

1: create Authentication Failure handler

@Component
public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {

    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
        System.out.print("here failure");

        String s=request.getParameter("username");
        setDefaultFailureUrl("/login?error&username="+s);
        super.onAuthenticationFailure(request,response,exception);
    }

}

2:  Authentication Success Handler

@Component
public class CustomAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {

    @Override
    public void onAuthenticationSuccess(HttpServletRequest request , HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        /* custom Block
Do any thing here
  */

        setDefaultTargetUrl("/home/");
        super.onAuthenticationSuccess(request,response,authentication);
    }
}

3: access request entry point

@Component
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        System.out.print("Unauthorized Access");

        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }
}

Implement the components as per your requirement.


问:
Close one modal ViewController and open another in same method. Possible?
I have a situation where I want to open one modal controller from the other. But when the user closes either, they should go back to the parent controller of both modal controllers.

So I have the parent controller in charge of this. The method on the parent does something similar to the code below when the user clicks a button on the first modal controller.

```<code>[self.navigationController dismissModalViewController:YES];
SecondModalViewController *c = [[SecondModalViewController alloc] init];
[self.navigationController presentModalViewController:c animated:YES];
[c release];
</code>```

The only thing that happens is the first view closes, but I don't see the second view open. Is it possible to close a modal ViewController and open a second one in the same method? If so, how?

答:
You can use handle uiviewcontroller closed and open another with using Unwind Segues.

https://developer.apple.com/library/content/technotes/tn2298/_index.html

Body:
I have a situation where I want to open one modal controller from the other. But when the user closes either, they should go back to the parent controller of both modal controllers.

So I have the parent controller in charge of this. The method on the parent does something similar to the code below when the user clicks a button on the first modal controller.

[self.navigationController dismissModalViewController:YES];
SecondModalViewController *c = [[SecondModalViewController alloc] init];
[self.navigationController presentModalViewController:c animated:YES];
[c release];

The only thing that happens is the first view closes, but I don't see the second view open. Is it possible to close a modal ViewController and open a second one in the same method? If so, how?


问:
How do you assign nodes a property using G.Nodes?
I have a graph with nodes assigned a number. I want this to be the node's "status" so that if I have a node X and I write G.Nodes.Status(X), then Matlab will tell me whether its number is 0 and 1. How do I do this?</p>

答:
Just write:

```<code>G.Nodes.Status = X
</code>```

Where X is a vector of the status of the nodes. X should have a value for each node in the same order that they appear in G.Nodes.

```<code>G = graph([1 1], [2 3]);
X = [1;0;1];
G.Nodes.Status = X;
G.Nodes.Status(2)

ans =
     0
</code>```

Body:
Just write:

G.Nodes.Status = X

Where X is a vector of the status of the nodes. X should have a value for each node in the same order that they appear in G.Nodes.

G = graph([1 1], [2 3]);
X = [1;0;1];
G.Nodes.Status = X;
G.Nodes.Status(2)

ans =
     0


问:
How to resolve FileStream "Error #3013: File or directory is in use" in Action Script 3?
I know this type of questions are already asked by many users but that didn't resolved my problem.

I am using a FileStream to write some content in a file and following are the codes which i am using to do this :

```<code>var fs:FileStream = new FileStream ();
fs.open( f , FileMode.WRITE ); // f is contains the file path
fs.writeBytes ( fzf.content ); // fzf is a FZipFile which contains some content
fs.close ();
</code>```

But problem is that initially if I am writing a file then that is working perfectly but without closing the application if I am trying to write another file then that is showing the error "File or directory is in use" at line fs.open,so I don't know where i am doing wrong as i am calling the close() after writing the write method.

If anybody can find where I am doing wrong or how to resolve this problem please help me to solve.

答:
You are trying to save the files one after another, right ? If so this error comes up because the files are not closing fast enough before you try to write the next one. You should use the openAsync() instead of open() and listen for the Event.CLOSE event on your Filestream (it is only triggered in the asynchronous mode). When it is triggered you can write the next file:</p>

```<code>var fs:FileStream = new FileStream ();
fs.addEventListener(Event.CLOSE, onFileClosed);

fs.openAsync( f , FileMode.WRITE ); // f is contains the file path
fs.writeBytes ( fzf.content ); // fzf is a FZipFile which contains some content
fs.close ();

private function onFileClosed(e:Event):void
{
    // The file was closed succesfully, it is now safe to write the next one
}
</code>```

Body:
I know this type of questions are already asked by many users but that didn't resolved my problem.

I am using a FileStream to write some content in a file and following are the codes which i am using to do this :

var fs:FileStream = new FileStream ();
fs.open( f , FileMode.WRITE ); // f is contains the file path
fs.writeBytes ( fzf.content ); // fzf is a FZipFile which contains some content
fs.close ();

But problem is that initially if I am writing a file then that is working perfectly but without closing the application if I am trying to write another file then that is showing the error "File or directory is in use" at line fs.open,so I don't know where i am doing wrong as i am calling the close() after writing the write method.

If anybody can find where I am doing wrong or how to resolve this problem please help me to solve.

Body:
You are trying to save the files one after another, right ? If so this error comes up because the files are not closing fast enough before you try to write the next one. You should use the openAsync() instead of open() and listen for the Event.CLOSE event on your Filestream (it is only triggered in the asynchronous mode). When it is triggered you can write the next file:

var fs:FileStream = new FileStream ();
fs.addEventListener(Event.CLOSE, onFileClosed);

fs.openAsync( f , FileMode.WRITE ); // f is contains the file path
fs.writeBytes ( fzf.content ); // fzf is a FZipFile which contains some content
fs.close ();

private function onFileClosed(e:Event):void
{
    // The file was closed succesfully, it is now safe to write the next one
}


问:
Scala implicit specialization
I'm working on a generic conversion library and I'd like to add automatic typeclass derivation using shapeless. It works in the general case but I'd like to introduce Haskellesque newtypes with automatic unwrapping and so I'd like to specialize the deriving function for my NewType type but scalac still picks up the more generic implicit value. Here's the code so far:

```<code>import shapeless._, shapeless.syntax._

trait NewType[A] { val value: A }

sealed trait ConversionTree
case class CInt(value:     Int) extends ConversionTree
case class CBoolean(value: Boolean) extends ConversionTree
case class CString(value:  String) extends ConversionTree
case class CArray(value:   List[ConversionTree]) extends ConversionTree
case class CObject(values:  Map[String, ConversionTree]) extends ConversionTree

def mergeCObjects(o1: CObject, o2: CObject): CObject = CObject(o1.values ++ o2.values)

trait ConvertsTo[A] {
  def convertTo(value: A): ConversionTree
}
object ConvertsTo {

  implicit val intConverter = new ConvertsTo[Int] { ... }
  implicit val boolConverter = new ConvertsTo[Boolean] { ... }
  implicit val stringConverter = new ConvertsTo[String] { ... }
  implicit def arrayConverter[A](implicit convertInner: ConvertsTo[A]) = new ConvertsTo[List[A]] { ... }
  implicit def objectConverter[A](implicit convertInner: ConvertsTo[A]) = new ConvertsTo[Map[String, A]] { ... }

  implicit def newTypeConverter[A](implicit convertInner: ConvertsTo[A]): ConvertsTo[NewType[A]] = new ConvertsTo[NewType[A]] {
    override def convertTo(value: NewType[A]): ConversionTree = {
      convertInner.convertTo(value.value)
    }
  }

  implicit def deriveHNil: ConvertsTo[HNil] = new ConvertsTo[HNil] {
    override def convertTo(value: HNil): ConversionTree = CObject(Map[String, ConversionTree]())
  }

  // This is the generic case
  implicit def deriveHCons[K <: Symbol, V, T <: HList](
    implicit
      key: Witness.Aux[K],
      sv: Lazy[ConvertsTo[V]],
      st: Lazy[ConvertsTo[T]]
  ): ConvertsTo[FieldType[K, V] :: T] = new ConvertsTo[FieldType[K, V] :: T]{
    override def convertTo(value: FieldType[K, V] :: T): ConversionTree = {
      val head = sv.value.convertTo(value.head)
      val tail = st.value.convertTo(value.tail)

      mergeCObjects(CObject(Map(key.value.name -> head)), tail.asInstanceOf[CObject])
    }
  }

  // This is the special case for NewTypes
  implicit def deriveHConsNewType[K <: Symbol, V, T <: HList](
    implicit
      key: Witness.Aux[K],
      sv: Lazy[ConvertsTo[V]],
      st: Lazy[ConvertsTo[T]]
  ): ConvertsTo[FieldType[K, NewType[V]] :: T] = new ConvertsTo[FieldType[K, NewType[V]] :: T] {
    override def convertTo(value: FieldType[K, NewType[V]] :: T): ConversionTree = {
      val head = sv.value.convertTo(value.head.value)
      val tail = st.value.convertTo(value.tail)

      mergeCObjects(CObject(Map(key.value.name -> head)), tail.asInstanceOf[CObject])
    }
  }

  implicit def deriveInstance[F, G](implicit gen: LabelledGeneric.Aux[F, G], sg: Lazy[ConvertsTo[G]]): ConvertsTo[F] = {
    new ConvertsTo[F] {
      override def convertTo(value: F): ConversionTree = sg.value.convertTo(gen.to(value))
    }
  }
}

def convertToG[A](value: A)(implicit converter: ConvertsTo[A]): ConversionTree = converter.convertTo(value)

case class Id(value: String) extends NewType[String]
case class User(id: Id, name: String)

println(s"${ConvertsTo.newTypeConverter[String].convertTo(Id("id1"))}")
println(s"User: ${convertToG(User(Id("id1"), "user1"))}")
</code>```

Output of the first println: CString("id1")

Output of the second println: CObject(Map("id" -> CObject(Map("value" -> CString("id1"))), "name" -> CString("user1")))

I'd like to get rid of the extra CObject around the id field in the second println. As you can see, calling the newTypeConverter directly results in the correct output but it doesn't work when the NewType is embedded in an object(and if I put a breakpoint in the deriveHConsNewType.convertTo method I can verify that it doesn't get called).
I've tried to define deriveHConsNewType like this as well but it didn't help:

```<code> implicit def deriveHConsNewType[K <: Symbol, V, N <: NewType[V], T <: HList](
   implicit
     key: Witness.Aux[K],
     sv: Lazy[ConvertsTo[V]],
     st: Lazy[ConvertsTo[T]]
 ): ConvertsTo[FieldType[K, N] :: T] = new ConvertsTo[FieldType[K, N] :: T] { ... }
</code>```

Can someone explain me how the implicit search works when this kind of overlap occurs and provide a solution to my problem?

EDIT: Solved the issue by making the type variable of ConvertsTo contravariant, scalac now picks the specialized implicit value.

答:
Solved the issue by making the type variable of ConvertsTo contravariant, scalac now picks the specialized implicit value.</p>

```<code>trait ConvertsTo[-A] {
  def convertTo(value: A): ConversionTree
}
</code>```

Title: Scala implicit specialization

Body:
I'm working on a generic conversion library and I'd like to add automatic typeclass derivation using shapeless. It works in the general case but I'd like to introduce Haskellesque newtypes with automatic unwrapping and so I'd like to specialize the deriving function for my NewType type but scalac still picks up the more generic implicit value. Here's the code so far:

import shapeless._, shapeless.syntax._

trait NewType[A] { val value: A }

sealed trait ConversionTree
case class CInt(value:     Int) extends ConversionTree
case class CBoolean(value: Boolean) extends ConversionTree
case class CString(value:  String) extends ConversionTree
case class CArray(value:   List[ConversionTree]) extends ConversionTree
case class CObject(values:  Map[String, ConversionTree]) extends ConversionTree

def mergeCObjects(o1: CObject, o2: CObject): CObject = CObject(o1.values ++ o2.values)

trait ConvertsTo[A] {
  def convertTo(value: A): ConversionTree
}
object ConvertsTo {

  implicit val intConverter = new ConvertsTo[Int] { ... }
  implicit val boolConverter = new ConvertsTo[Boolean] { ... }
  implicit val stringConverter = new ConvertsTo[String] { ... }
  implicit def arrayConverter[A](implicit convertInner: ConvertsTo[A]) = new ConvertsTo[List[A]] { ... }
  implicit def objectConverter[A](implicit convertInner: ConvertsTo[A]) = new ConvertsTo[Map[String, A]] { ... }

  implicit def newTypeConverter[A](implicit convertInner: ConvertsTo[A]): ConvertsTo[NewType[A]] = new ConvertsTo[NewType[A]] {
    override def convertTo(value: NewType[A]): ConversionTree = {
      convertInner.convertTo(value.value)
    }
  }

  implicit def deriveHNil: ConvertsTo[HNil] = new ConvertsTo[HNil] {
    override def convertTo(value: HNil): ConversionTree = CObject(Map[String, ConversionTree]())
  }

  // This is the generic case
  implicit def deriveHCons[K <: Symbol, V, T <: HList](
    implicit
      key: Witness.Aux[K],
      sv: Lazy[ConvertsTo[V]],
      st: Lazy[ConvertsTo[T]]
  ): ConvertsTo[FieldType[K, V] :: T] = new ConvertsTo[FieldType[K, V] :: T]{
    override def convertTo(value: FieldType[K, V] :: T): ConversionTree = {
      val head = sv.value.convertTo(value.head)
      val tail = st.value.convertTo(value.tail)

      mergeCObjects(CObject(Map(key.value.name -> head)), tail.asInstanceOf[CObject])
    }
  }

  // This is the special case for NewTypes
  implicit def deriveHConsNewType[K <: Symbol, V, T <: HList](
    implicit
      key: Witness.Aux[K],
      sv: Lazy[ConvertsTo[V]],
      st: Lazy[ConvertsTo[T]]
  ): ConvertsTo[FieldType[K, NewType[V]] :: T] = new ConvertsTo[FieldType[K, NewType[V]] :: T] {
    override def convertTo(value: FieldType[K, NewType[V]] :: T): ConversionTree = {
      val head = sv.value.convertTo(value.head.value)
      val tail = st.value.convertTo(value.tail)

      mergeCObjects(CObject(Map(key.value.name -> head)), tail.asInstanceOf[CObject])
    }
  }

  implicit def deriveInstance[F, G](implicit gen: LabelledGeneric.Aux[F, G], sg: Lazy[ConvertsTo[G]]): ConvertsTo[F] = {
    new ConvertsTo[F] {
      override def convertTo(value: F): ConversionTree = sg.value.convertTo(gen.to(value))
    }
  }
}

def convertToG[A](value: A)(implicit converter: ConvertsTo[A]): ConversionTree = converter.convertTo(value)

case class Id(value: String) extends NewType[String]
case class User(id: Id, name: String)

println(s"${ConvertsTo.newTypeConverter[String].convertTo(Id("id1"))}")
println(s"User: ${convertToG(User(Id("id1"), "user1"))}")

Output of the first println: CString("id1")

Output of the second println: CObject(Map("id" -> CObject(Map("value" -> CString("id1"))), "name" -> CString("user1")))

I'd like to get rid of the extra CObject around the id field in the second println. As you can see, calling the newTypeConverter directly results in the correct output but it doesn't work when the NewType is embedded in an object(and if I put a breakpoint in the deriveHConsNewType.convertTo method I can verify that it doesn't get called).
I've tried to define deriveHConsNewType like this as well but it didn't help:

 implicit def deriveHConsNewType[K <: Symbol, V, N <: NewType[V], T <: HList](
   implicit
     key: Witness.Aux[K],
     sv: Lazy[ConvertsTo[V]],
     st: Lazy[ConvertsTo[T]]
 ): ConvertsTo[FieldType[K, N] :: T] = new ConvertsTo[FieldType[K, N] :: T] { ... }

Can someone explain me how the implicit search works when this kind of overlap occurs and provide a solution to my problem?

EDIT: Solved the issue by making the type variable of ConvertsTo contravariant, scalac now picks the specialized implicit value.

Body:
Solved the issue by making the type variable of ConvertsTo contravariant, scalac now picks the specialized implicit value.

trait ConvertsTo[-A] {
  def convertTo(value: A): ConversionTree
}


问:
How to change font family only numbers
On whole my website there are many places that use numbers. because my font doesn't good to numbers.I would like to change font them to what I wanted.

now similar questions asked before but I not find a good answer to do this.
some answers suggests to use jquery/javascript function. but I think using jquery/javascript function make lazy my webpages.

Is there any better solution?

答:
You can use a class for all your number set like this:</p>

```<code>//css
.number{ font-family: 'your-font-name', fallback-font; }

//html
<p>something <span class='number'>877866</span> goes here</p>
</code>```

Title: How to change font family only numbers

Body:
You can use a class for all your number set like this:

//css
.number{ font-family: 'your-font-name', fallback-font; }

//html
<p>something <span class='number'>877866</span> goes here</p>


问:
[C++]Would this be a valid approach for a 'sleep' function in a thread?
I would like to implement a sleep() function in my thread class, but I don't know if this is a valid/proper way to do it.
This is my entire thread class (thread.h):

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

struct RUNNABLE{
    virtual void run() = 0;
};

class thread{
public:
    void start(void *ptr){
        DWORD thr_id;
        HANDLE thr_handl = (HANDLE)_beginthreadex(NULL, 0, thread_proc, ptr, 0, (unsigned int*)&thr_id);
    }

    void sleep(int sleep_time, bool alertable){
        SleepEx(sleep_time, alertable);
    }
private:
    static unsigned int __stdcall thread_proc(void *param){
        ((RUNNABLE*)param)->run();
        _endthreadex(0);
        return 0;
    }
};
</code>```

And as you're probably able to sort out, this is my sleep() function:

```<code>void sleep(int sleep_time, bool alertable){
    SleepEx(sleep_time, alertable);
}
</code>```

But will this make the actual thread contained inside this thread instance sleep for the specified amount of milliseconds?

Best regards,
Benjamin :).

EDIT:

So according to atzz, I could define the sleep function as a static member function, and have that call ::SleepEx(), and that would allow me to call it like this:

```<code>class test : RUNNABLE{
    virtual void run(){
        printf("hi");
        thread::sleep(1000, false);
    }
};
</code>```

and then that'll cause the thread executing the 'test' runnable to sleep 1000 milliseonds?

答: It will put to sleep whichever thread calls this member function.

Body:
I would like to implement a sleep() function in my thread class, but I don't know if this is a valid/proper way to do it.
This is my entire thread class (thread.h):

#include <process.h>

struct RUNNABLE{
    virtual void run() = 0;
};

class thread{
public:
    void start(void *ptr){
        DWORD thr_id;
        HANDLE thr_handl = (HANDLE)_beginthreadex(NULL, 0, thread_proc, ptr, 0, (unsigned int*)&thr_id);
    }

    void sleep(int sleep_time, bool alertable){
        SleepEx(sleep_time, alertable);
    }
private:
    static unsigned int __stdcall thread_proc(void *param){
        ((RUNNABLE*)param)->run();
        _endthreadex(0);
        return 0;
    }
};

And as you're probably able to sort out, this is my sleep() function:

void sleep(int sleep_time, bool alertable){
    SleepEx(sleep_time, alertable);
}

But will this make the actual thread contained inside this thread instance sleep for the specified amount of milliseconds?

Best regards,
Benjamin :).

EDIT:

So according to atzz, I could define the sleep function as a static member function, and have that call ::SleepEx(), and that would allow me to call it like this:

class test : RUNNABLE{
    virtual void run(){
        printf("hi");
        thread::sleep(1000, false);
    }
};

and then that'll cause the thread executing the 'test' runnable to sleep 1000 milliseonds?


问:
DataTables YajraBox Laravel extension with Eloquent Query String Filtering
im newbie Laravel, im trying to create a data table with YajraBox extension.

Im stuck on ajax controller:

```<code>public function indexData(LotFilters $filters)
    {
       $lots  = Lot::filter($filters)->get();

        return Datatables::of($lots)->make(true);
    }
</code>```

This is my route:

```<code>Route::get('data', 'LotController@indexData');
</code>```

When i go: http://127.0.0.1:8000/data it gives me an error:

Allowed memory size of 134217728 bytes exhausted (tried to allocate
  140673944 bytes)

It think i need to set up a pagination, but i didn't find a example how to do it, maybe you guys can help me?

答: Actually i find a solution just now. i just need to remove ->get(); from the end.

Body:
im newbie Laravel, im trying to create a data table with YajraBox extension.

Im stuck on ajax controller:

public function indexData(LotFilters $filters)
    {
       $lots  = Lot::filter($filters)->get();

        return Datatables::of($lots)->make(true);
    }

This is my route:

Route::get('data', 'LotController@indexData');

When i go: http://127.0.0.1:8000/data it gives me an error:

Allowed memory size of 134217728 bytes exhausted (tried to allocate
  140673944 bytes)

It think i need to set up a pagination, but i didn't find a example how to do it, maybe you guys can help me?