问:
Freemarker does not assign staticUtil
I worked Application Display Templates on liferay 6.2, I use freemarker help pagination the dynamics data list of liferay. When I upgrade to liferay 7, it is a problem. Liferay 7 use code <#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)> for get a records.

Old code:

<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
  <#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)>
  <#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) >

It doesn't work.

So I try <#assign serviceLocator = staticUtil["com.liferay.portal.template.ServiceLocator"]> but staticUtil get an error.

The following has evaluated to null or missing:
  ==> staticUtil  [in template "20115#20159#21387" at line 9, column 27]
  Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing

In portal-ext.properties I have added:

```<code>freemarker.engine.restricted.classes=
freemarker.engine.restricted.packages=
freemarker.engine.restricted.variables=
</code>```

答:
The properties you refer to have been moved to an OSGI config in Liferay 7/DXP.
To deploy them you need to create a file named com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.cfg and place it under $LIFERAY_HOME/osgi/configs

The content of the file will be the following:

```<code>restrictedVariables=
</code>```

To find all the configs and their defaults you can have a look at the class com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration

That you can find in the Liferay source code.

Title: Freemarker does not assign staticUtil

Body:
I worked Application Display Templates on liferay 6.2, I use freemarker help pagination the dynamics data list of liferay. When I upgrade to liferay 7, it is a problem. Liferay 7 use code <#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)> for get a records.

Old code:

<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
  <#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)>
  <#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) >

It doesn't work.

So I try <#assign serviceLocator = staticUtil["com.liferay.portal.template.ServiceLocator"]> but staticUtil get an error.

The following has evaluated to null or missing:
  ==> staticUtil  [in template "20115#20159#21387" at line 9, column 27]
  Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing

In portal-ext.properties I have added:

freemarker.engine.restricted.classes=
freemarker.engine.restricted.packages=
freemarker.engine.restricted.variables=

Body:
The properties you refer to have been moved to an OSGI config in Liferay 7/DXP.
To deploy them you need to create a file named com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.cfg and place it under $LIFERAY_HOME/osgi/configs

The content of the file will be the following:

restrictedVariables=

To find all the configs and their defaults you can have a look at the class com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration

That you can find in the Liferay source code.


来源: stackexchange

问:
Button inside iframe click functionality changes height of that parent iframe(cross domain)
on click change in height to 500px;

```<code><iframe src="test.html" frameborder="0" scrolling="no" id="myIframe" class="chat-box width-350" style="height:300px;"></iframe>
</code>```

iframe height is set to 300px

test.html

```<code><a href="javascript:void(0)" class="clickhere">button</a>
</code>```

when clicking on "clickhere" will change in height of iframe.

答:
JQuery: </p>

```<code>$('.clickhere').click(function() {
 $('#myIframe').css("height","500px");
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
on click change in height to 500px;

iframe height is set to 300px

test.html

button

when clicking on "clickhere" will change in height of iframe.

Body:
JQuery:

$('.clickhere').click(function() {
 $('#myIframe').css("height","500px");
}


问:
Working with coordinates in android for different screen sizes?
In an application, let suppose we have an image of a car onto which we have mark a damage point. We can mark this point anywhere of the image as shown below.

Suppose we have marked this point on a device of screen size “5 inches” and then we calculated the coordinates of this point and sent it to the server.
Now the user is using another device of screen size “8 inches”. User wants to see those marked points in his new device. But he is not able to see the appropriate position of the points after fetching the actual value from the server.

答:
I think the coordinates depend on the device's screen dpi. Assume your server always store the coordinates in mdpi. Then you should get the correct coordinates at device at different dpi like this:</p>

```<code>DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

float screenAdjust = (float) dm.densityDpi / 160f;

int x = (int) (x_value_from_server) * screenAdjust);
int y = (int) (y_value_from_server) * screenAdjust);
</code>```

Body:
I think the coordinates depend on the device's screen dpi. Assume your server always store the coordinates in mdpi. Then you should get the correct coordinates at device at different dpi like this:

DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

float screenAdjust = (float) dm.densityDpi / 160f;

int x = (int) (x_value_from_server) * screenAdjust);
int y = (int) (y_value_from_server) * screenAdjust);


问:
How can I create a table as displayed in the below screen shot
Please help me on how can I create a table as mentioned in the below screen shot

https://i.stack.imgur.com/zgf2Z.png

Thank you in advance!!

    Duration
    Topic

    10 min
     Recap of FY17 CSP Incentives

     20 min
     Partner Incentive Experience Onboarding

     15 min
     Updating Banking Details/Partner Requirements

     10 min
     Understanding MPN IDs

     5 min
     Q&A and Closing Session Survey

```

答:
Use following code.

```<code>   <table border="1">
      <tr>
        <th>H1</th>
        <th>H2</th>
      </tr>
      <tr>
        <td>R1</td>
        <td>R1</td>
      </tr>
      <tr>
        <td>R2</td>
        <td>R2</td>
      </tr>
      <tr>
        <td>R3</td>
        <td>R3</td>
      </tr>
    </table>
</code>```

Check demo here

Body:
Use following code.

   <table border="1">
      <tr>
        <th>H1</th>
        <th>H2</th>
      </tr>
      <tr>
        <td>R1</td>
        <td>R1</td>
      </tr>
      <tr>
        <td>R2</td>
        <td>R2</td>
      </tr>
      <tr>
        <td>R3</td>
        <td>R3</td>
      </tr>
    </table>

Check demo here


问:
Scala Play 2.5 with Slick 3 and Spec2
I have a play application using Slick that I want to test using Spec2, but I keep getting the error org.postgresql.util.PSQLException: FATAL: sorry, too many clients already. I have tried to shut down the database connection by using

```<code>val mockApp = new GuiceApplicationBuilder()
val db = mockApp.injector.instanceOf[DBApi].database("default")

...

override def afterAll = {
  db.getConnection().close()
  db.shutdown()
}
</code>```

But the error persists. The Slick configuration is

```<code>slick.dbs.default.driver="slick.driver.PostgresDriver$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://db:5432/hygge_db"
slick.dbs.default.db.user="*****"
slick.dbs.default.db.password="*****"
</code>```

答:
getConnection of DbApi either gets connection from underlying data-source's (JdbcDataSource I presume) pool or creates a new one. I see no pool specified in your configuration, so I think it always creates a new one for you. So if you didn't close connection inside the test - getConnection won't help - it will just try to create a new one or take random connection from pool (if pooling is enabled).

So the solution is to either configure connection pooling:

When using a connection pool (which is always recommended in
  production environments) the minimum size of the connection pool
  should also be set to at least the same size. The maximum size of the
  connection pool can be set much higher than in a blocking application.
  Any connections beyond the size of the thread pool will only be used
  when other connections are required to keep a database session open
  (e.g. while waiting for the result from an asynchronous computation in
  the middle of a transaction) but are not actively doing any work on
  the database.

so you can just set maximum available connections number in your config:

```<code>connectionPool = 5
</code>```

Or you can share same connection (you'll probably have to ensure sequentiality then):

```<code>object SharedConnectionForAllTests{
  val connection = db.getConnection()
  def close() = connection.close()
}
</code>```

It's better to inject it with Spring/Guice of course, so you could conviniently manage connection's lifecycle.

Title: Scala Play 2.5 with Slick 3 and Spec2

Body:
I have a play application using Slick that I want to test using Spec2, but I keep getting the error org.postgresql.util.PSQLException: FATAL: sorry, too many clients already. I have tried to shut down the database connection by using

val mockApp = new GuiceApplicationBuilder()
val db = mockApp.injector.instanceOf[DBApi].database("default")

...

override def afterAll = {
  db.getConnection().close()
  db.shutdown()
}

But the error persists. The Slick configuration is

slick.dbs.default.driver="slick.driver.PostgresDriver$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://db:5432/hygge_db"
slick.dbs.default.db.user="*****"
slick.dbs.default.db.password="*****"

Body:
getConnection of DbApi either gets connection from underlying data-source's (JdbcDataSource I presume) pool or creates a new one. I see no pool specified in your configuration, so I think it always creates a new one for you. So if you didn't close connection inside the test - getConnection won't help - it will just try to create a new one or take random connection from pool (if pooling is enabled).

So the solution is to either configure connection pooling:

When using a connection pool (which is always recommended in
  production environments) the minimum size of the connection pool
  should also be set to at least the same size. The maximum size of the
  connection pool can be set much higher than in a blocking application.
  Any connections beyond the size of the thread pool will only be used
  when other connections are required to keep a database session open
  (e.g. while waiting for the result from an asynchronous computation in
  the middle of a transaction) but are not actively doing any work on
  the database.

so you can just set maximum available connections number in your config:

connectionPool = 5

Or you can share same connection (you'll probably have to ensure sequentiality then):

object SharedConnectionForAllTests{
  val connection = db.getConnection()
  def close() = connection.close()
}

It's better to inject it with Spring/Guice of course, so you could conviniently manage connection's lifecycle.


问:
Waiting time is too high to Get Response from HTTPS site compared with http site
I am having an MVC website and deployed as both https and http (test version) in amazon aws. I noticed latency with log-in for specific user role in https site compared to http site. When I checked in fiddler/developer tool, I noticed that waiting time is too high (33715 ms) to get html response for https site compared to http site (700 ms). Same log-in module has been used for other role and there is no latency for other roles.

I have checked the code and I did not see any issue with code or database performance and it also working perfectly for http site.

Any idea what could be possible issue for this slowness?

答:
Check the zone of both the servers. Maybe they are on different places.

Waiting time is too high means it maybe a code related issue like sometimes a DB query can take more time.


问:
How to add scss file globally which should be applied to all the components in angular2 webpack?
I can apply scss to components using syntax

```<code>styleUrls: ['./app.component.scss', '../assets/css/styles.scss']
</code>```

But this style is only visible to particular component.

I want to use '../assets/css/styles.scss' across all the components.

Though using css file globally is easy but scss file is not seem to be working that way.

To configure my webpack for sass, added following line -

```<code>{
     test: /\.scss$/,
     exclude: /node_modules/,
     loaders: ['raw-loader', 'sass-loader']
}
</code>```

答:
Try to access the folder location from the webpack like this.</p>

```<code>{
     test: /\.scss$/,
     loader: 'file-loader?name=assets/css/[name].[ext]'
}
</code>```

Body:
I can apply scss to components using syntax

styleUrls: ['./app.component.scss', '../assets/css/styles.scss']

But this style is only visible to particular component.

I want to use '../assets/css/styles.scss' across all the components.

Though using css file globally is easy but scss file is not seem to be working that way.

To configure my webpack for sass, added following line -

{
     test: /\.scss$/,
     exclude: /node_modules/,
     loaders: ['raw-loader', 'sass-loader']
}

Body:
Try to access the folder location from the webpack like this.

{
     test: /\.scss$/,
     loader: 'file-loader?name=assets/css/[name].[ext]'
}


问:
How to get null instead of the KeyNotFoundException accessing Dictionary value by key?
In some certain scenario it appeared to be useful for me to have a short-spoken, readable way to get null instead of the KeyNotFoundException while accessing dictionary value by key, when there is no such key in the dictionary.

The first thing that came into my mind was an extension method:

```<code>public static U GetValueByKeyOrNull<T, U>(this Dictionary<T, U> dict, T key)
        where U : class //it's acceptable for me to have this constraint
{
    if (dict.ContainsKey(key))
        return dict[key];
    else
        //it could be default(U) to use without U class constraint
        //however, I didn't need this.
        return null;
}
</code>```

But it's not very short-spoken actually, when you write something like this:

```<code>string.Format("{0}:{1};{2}:{3}",
              dict.GetValueByKeyOrNull("key1"),
              dict.GetValueByKeyOrNull("key2"),
              dict.GetValueByKeyOrNull("key3"),
              dict.GetValueByKeyOrNull("key4"));
</code>```

I'd say, it would be much better to havesomething close to base syntax: dict["key4"].

Then I came up with an idea to have a class with a private dictionary field, which exposed the functionality I need:

```<code>public class MyDictionary<T, U> //here I may add any of interfaces, implemented
                                //by dictionary itself to get an opportunity to,
                                //say, use foreach, etc. and implement them
                                // using the dictionary field.
        where U : class
{
    private Dictionary<T, U> dict;

    public MyDictionary()
    {
        dict = new Dictionary<T, U>();
    }

    public U this[T key]
    {
        get
        {
            if (dict.ContainsKey(key))
                return dict[key];
            else
                return null;
        }
        set
        {
            dict[key] = value;
        }
    }
}
</code>```

But it seems a little overhead to get the slight change in the basic behaviour.

One more workaround could be to define a Func in the current context like this:

```<code>Func<string, string> GetDictValueByKeyOrNull = (key) =>
{
    if (dict.ContainsKey(key))
        return dict[key];
    else
        return null;
};
</code>```

so it could be utilized like GetDictValueByKeyOrNull("key1").

Could you, please, give me any more suggestions or help to choose a better one?

答:
Add a DictionaryExtension class

```<code>public static class DictionaryExtension
{
    public static TValue GetValueOrDefault<TKey, TValue>
        (   this IDictionary<TKey, TValue> dictionary,TKey key)
    {
        TValue value;
        return dictionary.TryGetValue(key, out value) ? value : default(TValue);
    }
}
</code>```

And it can return Default value if not found key in dictionary.

The Default is null if this is reference type .

```<code>_dic.GetValueOrDefault();
</code>```

Body:
In some certain scenario it appeared to be useful for me to have a short-spoken, readable way to get null instead of the KeyNotFoundException while accessing dictionary value by key, when there is no such key in the dictionary.

The first thing that came into my mind was an extension method:

public static U GetValueByKeyOrNull<T, U>(this Dictionary<T, U> dict, T key)
        where U : class //it's acceptable for me to have this constraint
{
    if (dict.ContainsKey(key))
        return dict[key];
    else
        //it could be default(U) to use without U class constraint
        //however, I didn't need this.
        return null;
}

But it's not very short-spoken actually, when you write something like this:

string.Format("{0}:{1};{2}:{3}",
              dict.GetValueByKeyOrNull("key1"),
              dict.GetValueByKeyOrNull("key2"),
              dict.GetValueByKeyOrNull("key3"),
              dict.GetValueByKeyOrNull("key4"));

I'd say, it would be much better to havesomething close to base syntax: dict["key4"].

Then I came up with an idea to have a class with a private dictionary field, which exposed the functionality I need:

public class MyDictionary<T, U> //here I may add any of interfaces, implemented
                                //by dictionary itself to get an opportunity to,
                                //say, use foreach, etc. and implement them
                                // using the dictionary field.
        where U : class
{
    private Dictionary<T, U> dict;

    public MyDictionary()
    {
        dict = new Dictionary<T, U>();
    }

    public U this[T key]
    {
        get
        {
            if (dict.ContainsKey(key))
                return dict[key];
            else
                return null;
        }
        set
        {
            dict[key] = value;
        }
    }
}

But it seems a little overhead to get the slight change in the basic behaviour.

One more workaround could be to define a Func in the current context like this:

Func<string, string> GetDictValueByKeyOrNull = (key) =>
{
    if (dict.ContainsKey(key))
        return dict[key];
    else
        return null;
};

so it could be utilized like GetDictValueByKeyOrNull("key1").

Could you, please, give me any more suggestions or help to choose a better one?

Body:
Add a DictionaryExtension class

public static class DictionaryExtension
{
    public static TValue GetValueOrDefault<TKey, TValue>
        (   this IDictionary<TKey, TValue> dictionary,TKey key)
    {
        TValue value;
        return dictionary.TryGetValue(key, out value) ? value : default(TValue);
    }
}

And it can return Default value if not found key in dictionary.

The Default is null if this is reference type .

_dic.GetValueOrDefault();

ContentLicense: CC BY-SA 4.0


问:
OST File Processing
We are using C#.net version.

I want to process OST File in same manner as PST file processing.
Does it possible using Redemption or any other method ?
Or if there any way we can save Message from OST using Redemption..

Can you advise.

Thanks

答:
There is no publicly available API for accessing the standalone OST file - they can only be used in the context of a profile that created them.

OST file format is not documented, but its closely related to PST, which is documented.

Title: OST File Processing


问:
How to Extract vector in session?
I have saved vector in session and I want to use random value from the vector but dont know how to extract value in session.

Errors:

'httpRequest-6' failed to execute: Vector(437420, 443940, 443932,
  437437, 443981, 443956, 443973, 443915, 437445) named 'termIds' does
  not support .random function

And

In 2nd scenario It passes vector in get request like this way, http://someurl/api/thr/Vector(435854)/terms/Vector(437420, 443940,
  443932, 437437, 443981, 443956, 443973, 443915, 437445)

instead of using
http://someurl/api/thr/435854/terms/443973

::Here is my script::

```<code>class getTerm extends Simulation {

 val repeatCount = Integer.getInteger("repeatCount", 1).toInt
 val userCount = Integer.getInteger("userCount", 1).toInt
 val turl =  System.getProperty("turl", "some url")

 val httpProtocol = http
 .baseURL("http://" + turl)

 val headers_10 = Map("Content-Type" -> """application/json""")

 var thrIds = ""
 var termIds = ""

// Scenario - 1
 val getTerms = scenario("Scn 1")
    .exec(http("list_of_term")
    .get("/api/abc")
    .headers(headers_10)
    .check(jsonPath("$[*].id")
    .findAll.saveAs("thrIds"))
 )

   .exec(http("get_all_terms")
     .get("""/api/thr/${thrIds.random()}/terms""")
     .headers(headers_10)
     .check(jsonPath("$[*].id")
     .findAll.saveAs("termIds"))
 )

  .exec(session => {
     thrIds = session("thrIds").as[Long].toString
     termIds = session("termIds").as[Long].toString
     println("***************************************")
     println("Session ====>>>> " + session)
     println("Ths ID ====>>>> " + thrIds)
     println("Term ID ====>>>> " + termIds)
     println("***************************************")
   session}
 )

// Scenario - 2
// Want to extract vectors here and pass its value into get call
 val getKnownTerms = scenario("Get Known Term")
    .exec(_.set("thrIds", thrIds))
    .exec(_.set("termIds", termIds))

    .repeat (repeatCount){
        exec(http("get_k_term")
       .get("""/api/thr/${thrIds}/terms/${termIds.random()}""")
    .headers(headers_10))
 }

 val scn = List(getTerms.inject(atOnceUsers(1)), getKnownTerms.inject(nothingFor(20 seconds), atOnceUsers(userCount)))
 setUp(scn).protocols(httpProtocol)

}
</code>```

答:
Here is the solution which may help others.

```<code>class getTerm extends Simulation {

 val repeatCount = Integer.getInteger("repeatCount", 1).toInt
 val userCount = Integer.getInteger("userCount", 1).toInt
 val turl =  System.getProperty("turl", "some url")

 val httpProtocol = http
 .baseURL("http://" + turl)

 val headers_10 = Map("Content-Type" -> """application/json""")

// Change - 1
var thrIds: Seq[String] = _
var termIds: Seq[String] = _

// Scenario - 1
 val getTerms = scenario("Scn 1")
    .exec(http("list_of_term")
    .get("/api/abc")
    .headers(headers_10)
    .check(jsonPath("$[*].id")
    .findAll
    .transform { v => thrIds = v; v }
    .saveAs("thrIds"))
 )

   .exec(http("get_all_trms")
     .get("""/api/thr/${thrIds.random()}/terms""")
     .headers(headers_10)
     .check(jsonPath("$[*].id")
     .findAll
     .transform { v => termIds = v; v }
    .saveAs("termIds"))
 )

// Scenario - 2
 val getKnownTerms = scenario("Get Known Term")
    .exec(_.set("thrIds", thrIds))
    .exec(_.set("termIds", termIds))

    .repeat (repeatCount){
        exec(http("get_k_term")
       .get("""/api/thr/${thrIds.random()}/terms/${termIds.random()}""")
    .headers(headers_10))
 }

 val scn = List(getTerms.inject(atOnceUsers(1)), getKnownTerms.inject(nothingFor(20 seconds), atOnceUsers(userCount)))
 setUp(scn).protocols(httpProtocol)

}
</code>```

Title: How to Extract vector in session?

Body:
I have saved vector in session and I want to use random value from the vector but dont know how to extract value in session.

Errors:

'httpRequest-6' failed to execute: Vector(437420, 443940, 443932,
  437437, 443981, 443956, 443973, 443915, 437445) named 'termIds' does
  not support .random function

And

In 2nd scenario It passes vector in get request like this way, http://someurl/api/thr/Vector(435854)/terms/Vector(437420, 443940,
  443932, 437437, 443981, 443956, 443973, 443915, 437445)

instead of using
http://someurl/api/thr/435854/terms/443973

::Here is my script::

class getTerm extends Simulation {

 val repeatCount = Integer.getInteger("repeatCount", 1).toInt
 val userCount = Integer.getInteger("userCount", 1).toInt
 val turl =  System.getProperty("turl", "some url")

 val httpProtocol = http
 .baseURL("http://" + turl)

 val headers_10 = Map("Content-Type" -> """application/json""")

 var thrIds = ""
 var termIds = ""

// Scenario - 1
 val getTerms = scenario("Scn 1")
    .exec(http("list_of_term")
    .get("/api/abc")
    .headers(headers_10)
    .check(jsonPath("$[*].id")
    .findAll.saveAs("thrIds"))
 )

   .exec(http("get_all_terms")
     .get("""/api/thr/${thrIds.random()}/terms""")
     .headers(headers_10)
     .check(jsonPath("$[*].id")
     .findAll.saveAs("termIds"))
 )

  .exec(session => {
     thrIds = session("thrIds").as[Long].toString
     termIds = session("termIds").as[Long].toString
     println("***************************************")
     println("Session ====>>>> " + session)
     println("Ths ID ====>>>> " + thrIds)
     println("Term ID ====>>>> " + termIds)
     println("***************************************")
   session}
 )

// Scenario - 2
// Want to extract vectors here and pass its value into get call
 val getKnownTerms = scenario("Get Known Term")
    .exec(_.set("thrIds", thrIds))
    .exec(_.set("termIds", termIds))

    .repeat (repeatCount){
        exec(http("get_k_term")
       .get("""/api/thr/${thrIds}/terms/${termIds.random()}""")
    .headers(headers_10))
 }

 val scn = List(getTerms.inject(atOnceUsers(1)), getKnownTerms.inject(nothingFor(20 seconds), atOnceUsers(userCount)))
 setUp(scn).protocols(httpProtocol)

}

Body:
Here is the solution which may help others.

class getTerm extends Simulation {

 val repeatCount = Integer.getInteger("repeatCount", 1).toInt
 val userCount = Integer.getInteger("userCount", 1).toInt
 val turl =  System.getProperty("turl", "some url")

 val httpProtocol = http
 .baseURL("http://" + turl)

 val headers_10 = Map("Content-Type" -> """application/json""")

// Change - 1
var thrIds: Seq[String] = _
var termIds: Seq[String] = _

// Scenario - 1
 val getTerms = scenario("Scn 1")
    .exec(http("list_of_term")
    .get("/api/abc")
    .headers(headers_10)
    .check(jsonPath("$[*].id")
    .findAll
    .transform { v => thrIds = v; v }
    .saveAs("thrIds"))
 )

   .exec(http("get_all_trms")
     .get("""/api/thr/${thrIds.random()}/terms""")
     .headers(headers_10)
     .check(jsonPath("$[*].id")
     .findAll
     .transform { v => termIds = v; v }
    .saveAs("termIds"))
 )

// Scenario - 2
 val getKnownTerms = scenario("Get Known Term")
    .exec(_.set("thrIds", thrIds))
    .exec(_.set("termIds", termIds))

    .repeat (repeatCount){
        exec(http("get_k_term")
       .get("""/api/thr/${thrIds.random()}/terms/${termIds.random()}""")
    .headers(headers_10))
 }

 val scn = List(getTerms.inject(atOnceUsers(1)), getKnownTerms.inject(nothingFor(20 seconds), atOnceUsers(userCount)))
 setUp(scn).protocols(httpProtocol)

}


问:
Bootstrap place all div in single line
I am trying to place userlist in left side and searchbox and button in right side in same line

```<code><div class="row">
  <div class="col-md-4">
    <div class="user-title">User List-5</div>
  </div>
  <div class="col-md-8">
    <div class="input-group user-search-box col-md-6">
      <input type="text" class="form-control" placeholder="Search" aria-describedby="basic-addon2">
      <span class="input-group-addon input-search-custom-adon" ><i class="fa fa-search" aria-hidden="true"></i></span>
    </div>
    <div class="add-new-user col-md-6">
      <a class="btn  add-new-user" href="#" role="button">ADD NEW USER</a>
    </div>
  </div>
</div>
</code>```

i have tried by using float:left then add button will show first instead of search box
can any one help me

答:
This code work for you perfect
 HTML is like this

```<code> <div class="row">
     <div class="col-md-4">
         <div class="user-title">User List-5</div>
     </div>
     <div class="col-md-8 right-col">
         <div class="input-group">
            <input type="text" class="form-control" placeholder="Search" aria-describedby="basic-addon2">
            <span class="input-group-addon input-search-custom-adon"><i class="fa fa-search" aria-hidden="true"></i></span>
         </div>
         <div class="add-new-user"> <a class="btn  add-new-user" href="#" role="button">ADD NEW USER</a></div>
     </div>
 </div>
</code>```

and CSS like this

```<code>  .right-col {
    display: flex; justify-content: flex-end;
  }
  .input-group {
    max-width: 520px;
  }
</code>```

Title: Bootstrap place all div in single line

Body:
I am trying to place userlist in left side and searchbox and button in right side in same line

User List-5

      <input type="text" class="form-control" placeholder="Search" aria-describedby="basic-addon2">

      ADD NEW USER

i have tried by using float:left then add button will show first instead of search box
can any one help me

Body:
This code work for you perfect
 HTML is like this

 <div class="row">
     <div class="col-md-4">
         <div class="user-title">User List-5</div>
     </div>
     <div class="col-md-8 right-col">
         <div class="input-group">
            <input type="text" class="form-control" placeholder="Search" aria-describedby="basic-addon2">
            <span class="input-group-addon input-search-custom-adon"><i class="fa fa-search" aria-hidden="true"></i></span>
         </div>
         <div class="add-new-user"> <a class="btn  add-new-user" href="#" role="button">ADD NEW USER</a></div>
     </div>
 </div>

and CSS like this

  .right-col {
    display: flex; justify-content: flex-end;
  }
  .input-group {
    max-width: 520px;
  }


问:
How to correctly override `errResponse` which is passed to the `catch(function(errResponse){` function?
This is my controller:

```<code>angular.module("AuthenticationApp", ["BaseApp"])
    .controller("MainCtrl", ["$http", "$window", "BaseService", function($http, $window, BaseService) {
        var self = this;

        self.add = function() {
            BaseService.add.user(self.user)
                .catch(function(errorResponse) {
                    self.cerrorMessages = errorResponse.data;
                });
        };
</code>```

This is my BaseApp / factory:

```<code>angular.module("BaseApp", [])
    .config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.xsrfCookieName = 'csrftoken';
        $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
    }])

    .factory("BaseService", ["$http", "$window", function($http, $window) {
        var self = this;

        self.add = {
            user: function(user) {
                $http.post("/users/", user)
                .then(function(response) {
                    $http.post("/api-auth/login", user)
                    .then(function(response) {
                        $window.location.href = "/";
                    });
                // if there are errors, rewrite the error messages
                }).catch(function(response) {
                     for (prop in response.data) {
                         if (prop == "email") {
                             response.data[prop] = "Please enter a valid email address.";
                         } else if (prop == "username") {
                             response.data[prop] = "Please enter a valid username";
                         }
                     }
                });
            }
         };
</code>```

When I try to run this code and call self.add() on my controller, I get an error saying TypeError: Cannot read property 'catch' of undefined pointing to the line .catch(function(errorResponse) { in my controller. I'm guessing this is because there is no then() function.

What should I do to properly override the errResponse parameter which is passed to the controller's .catch() function (without having a .then() function because nothing is needed to be done if it is successful)?

答:
When I try to run this code and call self.add() on my controller, I get an error saying TypeError: Cannot read property 'catch' of 'undefined' pointing to the line .catch(function(errorResponse) { in my controller. I'm guessing this is because there is no then() function.

That is an erroneous guess. The self.add() returned undefined because the function omitted a return statement. When functions omit return statements, they return the primitive value undefined. There is neither a .then method nor a .catch method on the primitive undefined. Thus the TypeError: Cannot read property 'catch'.

It is important to return the httpPromise:

```<code>user: function(user) {
    //vvvv RETURN the promise
    return $http.post("/users/", user)
      .then(function successHandler(response) {
        //vvvv RETURN to chain
        return $http.post("/api-auth/login", user)
    }).then(function successHandler(response) {
        $window.location.href = "/";
    // if there are errors, rewrite the error messages
    }).catch(function rejectHandler(errorResponse) {
         for (prop in errorResponse.data) {
             if (prop == "email") {
                 errorResponse.data[prop] = "Please enter a valid email address.";
             } else if (prop == "username") {
                 errorResponse.data[prop] = "Please enter a valid username";
             }
         }
         //vvvv THROW to chain rejections
         throw errorResponse;
    });
}
</code>```

Also it is important to use a throw statement in rejection handlers. Otherwise the rejection will be converted to a success. If a rejection handler omits a throw statement, it returns a primitive value of undefined. This means the rejection will be converted to a successful promise that resolves to a value of undefined. It will subsequently skip the .catch method in the controller.

For more information, see Angular execution order with $q.

Body:
This is my controller:

angular.module("AuthenticationApp", ["BaseApp"])
    .controller("MainCtrl", ["$http", "$window", "BaseService", function($http, $window, BaseService) {
        var self = this;

        self.add = function() {
            BaseService.add.user(self.user)
                .catch(function(errorResponse) {
                    self.cerrorMessages = errorResponse.data;
                });
        };

This is my BaseApp / factory:

angular.module("BaseApp", [])
    .config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.xsrfCookieName = 'csrftoken';
        $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
    }])

    .factory("BaseService", ["$http", "$window", function($http, $window) {
        var self = this;

        self.add = {
            user: function(user) {
                $http.post("/users/", user)
                .then(function(response) {
                    $http.post("/api-auth/login", user)
                    .then(function(response) {
                        $window.location.href = "/";
                    });
                // if there are errors, rewrite the error messages
                }).catch(function(response) {
                     for (prop in response.data) {
                         if (prop == "email") {
                             response.data[prop] = "Please enter a valid email address.";
                         } else if (prop == "username") {
                             response.data[prop] = "Please enter a valid username";
                         }
                     }
                });
            }
         };

When I try to run this code and call self.add() on my controller, I get an error saying TypeError: Cannot read property 'catch' of undefined pointing to the line .catch(function(errorResponse) { in my controller. I'm guessing this is because there is no then() function.

What should I do to properly override the errResponse parameter which is passed to the controller's .catch() function (without having a .then() function because nothing is needed to be done if it is successful)?

Body:
When I try to run this code and call self.add() on my controller, I get an error saying TypeError: Cannot read property 'catch' of 'undefined' pointing to the line .catch(function(errorResponse) { in my controller. I'm guessing this is because there is no then() function.

That is an erroneous guess. The self.add() returned undefined because the function omitted a return statement. When functions omit return statements, they return the primitive value undefined. There is neither a .then method nor a .catch method on the primitive undefined. Thus the TypeError: Cannot read property 'catch'.

It is important to return the httpPromise:

user: function(user) {
    //vvvv RETURN the promise
    return $http.post("/users/", user)
      .then(function successHandler(response) {
        //vvvv RETURN to chain
        return $http.post("/api-auth/login", user)
    }).then(function successHandler(response) {
        $window.location.href = "/";
    // if there are errors, rewrite the error messages
    }).catch(function rejectHandler(errorResponse) {
         for (prop in errorResponse.data) {
             if (prop == "email") {
                 errorResponse.data[prop] = "Please enter a valid email address.";
             } else if (prop == "username") {
                 errorResponse.data[prop] = "Please enter a valid username";
             }
         }
         //vvvv THROW to chain rejections
         throw errorResponse;
    });
}

Also it is important to use a throw statement in rejection handlers. Otherwise the rejection will be converted to a success. If a rejection handler omits a throw statement, it returns a primitive value of undefined. This means the rejection will be converted to a successful promise that resolves to a value of undefined. It will subsequently skip the .catch method in the controller.

For more information, see Angular execution order with $q.


问:
I need horizontal scrolling for GridView
I've got my GridView inside another Panel and I got scrollbars but GridView is to big even with paging. So user needs to scroll down to scroll horizontal (to see horizontal scrollbar).

How can I add any horizontal scrolling trick for my GridView in the Panel. Maybe something from javascript ? My js knowledges is still being poor.

I really hard thinking on what that could be, maybe floating horizontal scrollbar ?

Thank you.

答:
This can be done with the CSS Overflow property, see: http://www.w3schools.com/Css/pr_pos_overflow.asp

You may be able to add this to your asp Control, or see how the <asp:Panel> is rendered (I haven't used WebForms for a while, but I think it's a HTML ) and give it an appropriate element Id/class and set the CSS property in a seperate stylesheet.

ContentLicense: CC BY-SA 2.5

Body:
This can be done with the CSS Overflow property, see: http://www.w3schools.com/Css/pr_pos_overflow.asp

You may be able to add this to your asp Control, or see how the <asp:Panel> is rendered (I haven't used WebForms for a while, but I think it's a HTML <span>) and give it an appropriate element Id/class and set the CSS property in a seperate stylesheet.


问:
Group BY Day in the Android?
Can We Parse the JSON Data As Group BY Day in the Android.I am not able to generate logic how to parse the JSON Data as in Day.

JSON Data

```<code>[
 {
    "ID": 2012,
    "ClassRoom_ID": 1,
    "DayOfTheWeek": "6",
    "StartTime": "2017-03-20T12:37:00",
    "EndTime": "2017-03-20T10:37:00",
    "EmpID": 8,
    "classNO": 8,
    "CourseID": 1012,
    "teachers": {
      "EmpID": 8,
      "NAME": "Hunter Fuentes",
      "PHONE_NO": "04 37 33 81 11",
      "MOBILE_NO": "16890727-0931",
      "EMAIL": "id.ante.dictum@egetnisi.ca",
      "DESIGNATION": "Abdul Norris",
      "PERMANENT_ADDRESS": "492-3934 Nunc Road",
      "TEMP_ADDRESS": "P.O. Box 108, 1841 Sodales Rd.",
      "DOB": "1867-09-19T00:00:00",
      "TEACHER_OR_NONTEACHER": "T",
      "NATIONAL_ID_NO": "5",
      "MARITAL_STATUS": "M",
      "GENDER": "M",
      "QUALIFICATION": "SLC",
      "DEPTID": 5,
      "JoiningDate": "2017-10-17T00:00:00",
      "departments": null,
      "Photo": null,
      "base64": null
    },
    "courses": {
      "CourseID": 1012,
      "CourseName": "Math",
      "CourseLevel": 0,
      "CourseInstructor1": "Kennedy Joseph",
      "CourseInstructor2": "Haviva Nielsen",
      "CourseInstructor3": "Bruno Fry",
      "ClassNo": 8,
      "UT_PM": 20,
      "UT_FM": 50,
      "Terminal_PM": 40,
      "Terminal_FM": 100
    }
  },
  {
    "ID": 2013,
    "ClassRoom_ID": 5,
    "DayOfTheWeek": "2",
    "StartTime": "2017-03-20T10:37:00",
    "EndTime": "2017-03-20T11:37:00",
    "EmpID": 5,
    "classNO": 8,
    "CourseID": 2013,
    "teachers": {
      "EmpID": 5,
      "NAME": "Kennedy Joseph",
      "PHONE_NO": "05 49 81 27 99",
      "MOBILE_NO": "16330902-1552",
      "EMAIL": "Cras@metusfacilisislorem.co.uk",
      "DESIGNATION": "Mason Nielsen",
      "PERMANENT_ADDRESS": "Ap #468-4208 Etiam Rd.",
      "TEMP_ADDRESS": "Ap #383-2738 Dui Road",
      "DOB": "1956-01-21T00:00:00",
      "TEACHER_OR_NONTEACHER": "T",
      "NATIONAL_ID_NO": "8",
      "MARITAL_STATUS": "S",
      "GENDER": "M",
      "QUALIFICATION": "Others",
      "DEPTID": 5,
      "JoiningDate": "2016-10-03T00:00:00",
      "departments": null,
      "Photo": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAEsASwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD5/ooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//2Q==",
      "base64": null
    },
    "courses": {
      "CourseID": 2013,
      "CourseName": "English",
      "CourseLevel": 0,
      "CourseInstructor1": "Gabriel Boone",
      "CourseInstructor2": "Georgia Reeves",
      "CourseInstructor3": "Doris Marquez",
      "ClassNo": 8,
      "UT_PM": 15,
      "UT_FM": 100,
      "Terminal_PM": 40,
      "Terminal_FM": 100
    }
  }
]
</code>```

FragmentClassTest

```<code>public class FragmentClassTest extends Fragment {

    LinearLayout sunday, sundaySchedule, monday, mondayClass, tuesday, tuesdayClass, wednesday, wednesdayClass, thrusday, thrusdayClass, friday, fridayClass;

    public static final String Navigation_URL = "http://192.168.100.5:84/api/employeeApi/timeTableByClass";
    String master_id;
    TextView WeekofDay, mondaysubject;
    String day;

    ListView listViewStudentClass;
    List<ClassScheduleStudent> classschedulestudent = new ArrayList<ClassScheduleStudent>();
    String access_token;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.class_schedule_listitem_student, container, false);
        setHasOptionsMenu(true);

        sunday = (LinearLayout) view.findViewById(R.id.sunday);
        monday = (LinearLayout) view.findViewById(R.id.monday);
        tuesday = (LinearLayout) view.findViewById(R.id.tuesday);
        wednesday = (LinearLayout) view.findViewById(R.id.wednesday);
        thrusday = (LinearLayout) view.findViewById(R.id.thrusday);
        friday = (LinearLayout) view.findViewById(R.id.friday);

        sundaySchedule = (LinearLayout) view.findViewById(R.id.sunday_class);
        mondayClass = (LinearLayout) view.findViewById(R.id.monday_class);
        tuesdayClass = (LinearLayout) view.findViewById(R.id.tuesday_class);
        wednesdayClass = (LinearLayout) view.findViewById(R.id.wednesday_class);
        thrusdayClass = (LinearLayout) view.findViewById(R.id.thrusday_class);
        fridayClass = (LinearLayout) view.findViewById(R.id.friday_class);

        WeekofDay = (TextView) view.findViewById(R.id.DayofWeek);

        listViewStudentClass = (ListView) view.findViewById(R.id.list_class_schedule);

        //   sundaySchedule.setVisibility(View.VISIBLE);
        //   mondayClass.setVisibility(View.GONE);
        //   tuesdayClass.setVisibility(View.GONE);
        //   wednesdayClass.setVisibility(View.GONE);
        //   thrusdayClass.setVisibility(View.GONE);
        //   fridayClass.setVisibility(View.GONE);

        SessionManagement session = new SessionManagement(getContext());
        session.checkLogin();
        master_id = session.getMasterId();
        access_token = session.getAccesstToken();

        makeJsonObjectRequest();
        return view;
    }

    ClassScheduleStudent classScheduleStudent;

    private void makeJsonObjectRequest() {

        RequestQueue requestQueue = Volley.newRequestQueue(getContext());
        String URL = Navigation_URL + "?Sid=" + master_id;
        System.out.println(URL);

        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {

                            ArrayList<ClassScheduleStudent> student_list_student_fee = new ArrayList<>();
                            List<JSONObject> dayone=new ArrayList<>();
                            List<JSONObject> daytwo=new ArrayList<>();
                            List<JSONObject> daythree=new ArrayList<>();

                            JSONArray jArray = new JSONArray(response);
                            //  studentFeeInformation = new StudentFeeInformation(response);
                            for (int i = 0; i < jArray.length(); i++) {
                                JSONObject jsonObject = jArray.getJSONObject(i);
                                day = jsonObject.getString("DayOfTheWeek");

                                switch (day) {
                                    case "1":  //for sunday

                                        String classId=jsonObject.getString( "ClassRoom_ID");
                                        dayone.add(jsonObject);

                                        //...... parse data//
                                        break;
                                    case "2":  //for monday

                                        break;
                                    case "3":
//...... do your code//
                                        break;
                                    case "4":
//...... do your code//
                                        break;
                                    case "5":
                                        break;
                                    case "6":
                                        break;
                                    case "7":
                                        break;
                                }

                             /*   String Description = jsonObject.getString("teachers");
                                JSONArray jArray1 = new JSONArray(Description);

                                //   JSONArray descriptionArray = jsonObject.getJSONArray("Description");

                                for (int j = 0; j < jArray1.length(); j++) {
                                    JSONObject jsonObjectinner = jArray1.getJSONObject(j);

                                  String  Descriptionlist = jsonObjectinner.getString("NAME");

                                }   */

                                student_list_student_fee.add(new ClassScheduleStudent(day));

                            }

                            //  JSONObject studentDetails_obj = jsonObject.getJSONObject("studentDetails");
                            // studentInformation.GuardianStudentId = studentDetails_obj.getString("StdID");

                            //  JSONObject studentDetails_obj1 = jsonObject.getJSONObject("stdCategory");
                            //  studentInformation.Category = studentDetails_obj1.getString("Category");
                            //  studentInformation.CategoryId = studentDetails_obj1.getString("Cat_ID");

                            for(JSONObject jobj: dayone){
                                String classId=jobj.getString("ClassRoom_ID"); //class id of dayone
                            }

                            ClassScheduleStudentAdapter customFeeListStudentAdapter = new ClassScheduleStudentAdapter(getActivity(), student_list_student_fee);
                            listViewStudentClass.setAdapter(customFeeListStudentAdapter);

                        } catch (JSONException e) {
                            Toast.makeText(getContext(), "Fetch failed!", Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        }

                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getContext(), error.toString(), Toast.LENGTH_LONG).show();
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Authorization", "Bearer " + access_token);
                headers.put("Content-Type", "application/x-www-form-urlencoded");
                return headers;
            }
/*
            @Override
            protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();

                map.put("id", master_id);
                map.put("accessID", accessID);
                map.put("currentUser", master_id);
                return map;

            }    */
        };

        requestQueue.add(stringRequest);

    }
</code>```

Can this be groupedbyDay?i am totally confused.How can this be done.

答:
I have solved using idea of kiranBenny slution

```<code> private void makeJsonObjectRequest() {

        RequestQueue requestQueue = Volley.newRequestQueue(getContext());
        String URL = Navigation_URL + "?Sid=" + master_id;
        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {

                            ArrayList<ClassScheduleStudent> student_list_class_schedule_sunday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_monday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_tuesday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_wednesday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_thursday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_friday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_saturday = new ArrayList<>();
                            JSONArray jArray = new JSONArray(response);
                            for (int i = 0; i < jArray.length(); i++) {

                                JSONObject jsonObject = jArray.getJSONObject(i);
                                day = jsonObject.getString("DayOfTheWeek");

                                if (day.equals("1")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_sunday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));
                                } else if (day.equals("2")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_monday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("3")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_tuesday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("4")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_wednesday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("5")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_thursday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("6")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_friday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else {

                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_friday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                }

                            }

                            ClassScheduleStudentAdapter classScheduleStudentAdatptersunday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_sunday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatptermonday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_monday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatptertuesday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_tuesday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatpterwednesday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_wednesday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatpterthursday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_thursday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatpterfriday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_friday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatptersaturday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_saturday);
                            listViewStudentClass_Sunday.setAdapter(classScheduleStudentAdatptersunday);
                            listViewStudentClass_Monday.setAdapter(classScheduleStudentAdatptermonday);
                            listViewStudentClass_Tuesday.setAdapter(classScheduleStudentAdatptertuesday);
                            listViewStudentClass_Wednesday.setAdapter(classScheduleStudentAdatpterwednesday);
                            listViewStudentClass_Thursday.setAdapter(classScheduleStudentAdatpterthursday);
                            listViewStudentClass_Friday.setAdapter(classScheduleStudentAdatpterfriday);
                            listViewStudentClass_Saturday.setAdapter(classScheduleStudentAdatptersaturday);

                        } catch (JSONException e) {
                            Toast.makeText(getContext(), "Fetch failed!", Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        }
                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getContext(), error.toString(), Toast.LENGTH_LONG).show();
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Authorization", "Bearer " + access_token);
                headers.put("Content-Type", "application/x-www-form-urlencoded");
                return headers;
            }
/*
            @Override
            protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();

                map.put("id", master_id);
                map.put("accessID", accessID);
                map.put("currentUser", master_id);
                return map;

            } */
        };

        requestQueue.add(stringRequest);

    }
</code>```

Title: Group BY Day in the Android?

Body:
Can We Parse the JSON Data As Group BY Day in the Android.I am not able to generate logic how to parse the JSON Data as in Day.

JSON Data

[
 {
    "ID": 2012,
    "ClassRoom_ID": 1,
    "DayOfTheWeek": "6",
    "StartTime": "2017-03-20T12:37:00",
    "EndTime": "2017-03-20T10:37:00",
    "EmpID": 8,
    "classNO": 8,
    "CourseID": 1012,
    "teachers": {
      "EmpID": 8,
      "NAME": "Hunter Fuentes",
      "PHONE_NO": "04 37 33 81 11",
      "MOBILE_NO": "16890727-0931",
      "EMAIL": "id.ante.dictum@egetnisi.ca",
      "DESIGNATION": "Abdul Norris",
      "PERMANENT_ADDRESS": "492-3934 Nunc Road",
      "TEMP_ADDRESS": "P.O. Box 108, 1841 Sodales Rd.",
      "DOB": "1867-09-19T00:00:00",
      "TEACHER_OR_NONTEACHER": "T",
      "NATIONAL_ID_NO": "5",
      "MARITAL_STATUS": "M",
      "GENDER": "M",
      "QUALIFICATION": "SLC",
      "DEPTID": 5,
      "JoiningDate": "2017-10-17T00:00:00",
      "departments": null,
      "Photo": null,
      "base64": null
    },
    "courses": {
      "CourseID": 1012,
      "CourseName": "Math",
      "CourseLevel": 0,
      "CourseInstructor1": "Kennedy Joseph",
      "CourseInstructor2": "Haviva Nielsen",
      "CourseInstructor3": "Bruno Fry",
      "ClassNo": 8,
      "UT_PM": 20,
      "UT_FM": 50,
      "Terminal_PM": 40,
      "Terminal_FM": 100
    }
  },
  {
    "ID": 2013,
    "ClassRoom_ID": 5,
    "DayOfTheWeek": "2",
    "StartTime": "2017-03-20T10:37:00",
    "EndTime": "2017-03-20T11:37:00",
    "EmpID": 5,
    "classNO": 8,
    "CourseID": 2013,
    "teachers": {
      "EmpID": 5,
      "NAME": "Kennedy Joseph",
      "PHONE_NO": "05 49 81 27 99",
      "MOBILE_NO": "16330902-1552",
      "EMAIL": "Cras@metusfacilisislorem.co.uk",
      "DESIGNATION": "Mason Nielsen",
      "PERMANENT_ADDRESS": "Ap #468-4208 Etiam Rd.",
      "TEMP_ADDRESS": "Ap #383-2738 Dui Road",
      "DOB": "1956-01-21T00:00:00",
      "TEACHER_OR_NONTEACHER": "T",
      "NATIONAL_ID_NO": "8",
      "MARITAL_STATUS": "S",
      "GENDER": "M",
      "QUALIFICATION": "Others",
      "DEPTID": 5,
      "JoiningDate": "2016-10-03T00:00:00",
      "departments": null,
      "Photo": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAEsASwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD5/ooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//2Q==",
      "base64": null
    },
    "courses": {
      "CourseID": 2013,
      "CourseName": "English",
      "CourseLevel": 0,
      "CourseInstructor1": "Gabriel Boone",
      "CourseInstructor2": "Georgia Reeves",
      "CourseInstructor3": "Doris Marquez",
      "ClassNo": 8,
      "UT_PM": 15,
      "UT_FM": 100,
      "Terminal_PM": 40,
      "Terminal_FM": 100
    }
  }
]

FragmentClassTest

public class FragmentClassTest extends Fragment {

    LinearLayout sunday, sundaySchedule, monday, mondayClass, tuesday, tuesdayClass, wednesday, wednesdayClass, thrusday, thrusdayClass, friday, fridayClass;

    public static final String Navigation_URL = "http://192.168.100.5:84/api/employeeApi/timeTableByClass";
    String master_id;
    TextView WeekofDay, mondaysubject;
    String day;

    ListView listViewStudentClass;
    List<ClassScheduleStudent> classschedulestudent = new ArrayList<ClassScheduleStudent>();
    String access_token;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.class_schedule_listitem_student, container, false);
        setHasOptionsMenu(true);

        sunday = (LinearLayout) view.findViewById(R.id.sunday);
        monday = (LinearLayout) view.findViewById(R.id.monday);
        tuesday = (LinearLayout) view.findViewById(R.id.tuesday);
        wednesday = (LinearLayout) view.findViewById(R.id.wednesday);
        thrusday = (LinearLayout) view.findViewById(R.id.thrusday);
        friday = (LinearLayout) view.findViewById(R.id.friday);

        sundaySchedule = (LinearLayout) view.findViewById(R.id.sunday_class);
        mondayClass = (LinearLayout) view.findViewById(R.id.monday_class);
        tuesdayClass = (LinearLayout) view.findViewById(R.id.tuesday_class);
        wednesdayClass = (LinearLayout) view.findViewById(R.id.wednesday_class);
        thrusdayClass = (LinearLayout) view.findViewById(R.id.thrusday_class);
        fridayClass = (LinearLayout) view.findViewById(R.id.friday_class);

        WeekofDay = (TextView) view.findViewById(R.id.DayofWeek);

        listViewStudentClass = (ListView) view.findViewById(R.id.list_class_schedule);

        //   sundaySchedule.setVisibility(View.VISIBLE);
        //   mondayClass.setVisibility(View.GONE);
        //   tuesdayClass.setVisibility(View.GONE);
        //   wednesdayClass.setVisibility(View.GONE);
        //   thrusdayClass.setVisibility(View.GONE);
        //   fridayClass.setVisibility(View.GONE);

        SessionManagement session = new SessionManagement(getContext());
        session.checkLogin();
        master_id = session.getMasterId();
        access_token = session.getAccesstToken();

        makeJsonObjectRequest();
        return view;
    }

    ClassScheduleStudent classScheduleStudent;

    private void makeJsonObjectRequest() {

        RequestQueue requestQueue = Volley.newRequestQueue(getContext());
        String URL = Navigation_URL + "?Sid=" + master_id;
        System.out.println(URL);

        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {

                            ArrayList<ClassScheduleStudent> student_list_student_fee = new ArrayList<>();
                            List<JSONObject> dayone=new ArrayList<>();
                            List<JSONObject> daytwo=new ArrayList<>();
                            List<JSONObject> daythree=new ArrayList<>();

                            JSONArray jArray = new JSONArray(response);
                            //  studentFeeInformation = new StudentFeeInformation(response);
                            for (int i = 0; i < jArray.length(); i++) {
                                JSONObject jsonObject = jArray.getJSONObject(i);
                                day = jsonObject.getString("DayOfTheWeek");

                                switch (day) {
                                    case "1":  //for sunday

                                        String classId=jsonObject.getString( "ClassRoom_ID");
                                        dayone.add(jsonObject);

                                        //...... parse data//
                                        break;
                                    case "2":  //for monday

                                        break;
                                    case "3":
//...... do your code//
                                        break;
                                    case "4":
//...... do your code//
                                        break;
                                    case "5":
                                        break;
                                    case "6":
                                        break;
                                    case "7":
                                        break;
                                }

                             /*   String Description = jsonObject.getString("teachers");
                                JSONArray jArray1 = new JSONArray(Description);

                                //   JSONArray descriptionArray = jsonObject.getJSONArray("Description");

                                for (int j = 0; j < jArray1.length(); j++) {
                                    JSONObject jsonObjectinner = jArray1.getJSONObject(j);

                                  String  Descriptionlist = jsonObjectinner.getString("NAME");

                                }   */

                                student_list_student_fee.add(new ClassScheduleStudent(day));

                            }

                            //  JSONObject studentDetails_obj = jsonObject.getJSONObject("studentDetails");
                            // studentInformation.GuardianStudentId = studentDetails_obj.getString("StdID");

                            //  JSONObject studentDetails_obj1 = jsonObject.getJSONObject("stdCategory");
                            //  studentInformation.Category = studentDetails_obj1.getString("Category");
                            //  studentInformation.CategoryId = studentDetails_obj1.getString("Cat_ID");

                            for(JSONObject jobj: dayone){
                                String classId=jobj.getString("ClassRoom_ID"); //class id of dayone
                            }

                            ClassScheduleStudentAdapter customFeeListStudentAdapter = new ClassScheduleStudentAdapter(getActivity(), student_list_student_fee);
                            listViewStudentClass.setAdapter(customFeeListStudentAdapter);

                        } catch (JSONException e) {
                            Toast.makeText(getContext(), "Fetch failed!", Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        }

                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getContext(), error.toString(), Toast.LENGTH_LONG).show();
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Authorization", "Bearer " + access_token);
                headers.put("Content-Type", "application/x-www-form-urlencoded");
                return headers;
            }
/*
            @Override
            protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();

                map.put("id", master_id);
                map.put("accessID", accessID);
                map.put("currentUser", master_id);
                return map;

            }    */
        };

        requestQueue.add(stringRequest);

    }

Can this be groupedbyDay?i am totally confused.How can this be done.

Body:
I have solved using idea of kiranBenny slution

 private void makeJsonObjectRequest() {

        RequestQueue requestQueue = Volley.newRequestQueue(getContext());
        String URL = Navigation_URL + "?Sid=" + master_id;
        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {

                            ArrayList<ClassScheduleStudent> student_list_class_schedule_sunday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_monday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_tuesday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_wednesday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_thursday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_friday = new ArrayList<>();
                            ArrayList<ClassScheduleStudent> student_list_class_schedule_saturday = new ArrayList<>();
                            JSONArray jArray = new JSONArray(response);
                            for (int i = 0; i < jArray.length(); i++) {

                                JSONObject jsonObject = jArray.getJSONObject(i);
                                day = jsonObject.getString("DayOfTheWeek");

                                if (day.equals("1")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_sunday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));
                                } else if (day.equals("2")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_monday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("3")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_tuesday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("4")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_wednesday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("5")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_thursday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else if (day.equals("6")) {
                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_friday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                } else {

                                    JSONObject studentDetails_obj = jsonObject.getJSONObject("teachers");
                                    JSONObject studentDetails_course = jsonObject.getJSONObject("courses");
                                    SubjectName = (String) studentDetails_course.get("CourseName");
                                    TeacherName = studentDetails_obj.getString("NAME");
                                    StartTime = jsonObject.getString("StartTime").substring(11, 19);
                                    EndTime = jsonObject.getString("EndTime").substring(11, 19);
                                    student_list_class_schedule_friday.add(new ClassScheduleStudent(SubjectName, TeacherName, StartTime, EndTime));

                                }

                            }

                            ClassScheduleStudentAdapter classScheduleStudentAdatptersunday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_sunday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatptermonday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_monday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatptertuesday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_tuesday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatpterwednesday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_wednesday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatpterthursday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_thursday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatpterfriday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_friday);
                            ClassScheduleStudentAdapter classScheduleStudentAdatptersaturday = new ClassScheduleStudentAdapter(getActivity(), student_list_class_schedule_saturday);
                            listViewStudentClass_Sunday.setAdapter(classScheduleStudentAdatptersunday);
                            listViewStudentClass_Monday.setAdapter(classScheduleStudentAdatptermonday);
                            listViewStudentClass_Tuesday.setAdapter(classScheduleStudentAdatptertuesday);
                            listViewStudentClass_Wednesday.setAdapter(classScheduleStudentAdatpterwednesday);
                            listViewStudentClass_Thursday.setAdapter(classScheduleStudentAdatpterthursday);
                            listViewStudentClass_Friday.setAdapter(classScheduleStudentAdatpterfriday);
                            listViewStudentClass_Saturday.setAdapter(classScheduleStudentAdatptersaturday);

                        } catch (JSONException e) {
                            Toast.makeText(getContext(), "Fetch failed!", Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        }
                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getContext(), error.toString(), Toast.LENGTH_LONG).show();
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Authorization", "Bearer " + access_token);
                headers.put("Content-Type", "application/x-www-form-urlencoded");
                return headers;
            }
/*
            @Override
            protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();

                map.put("id", master_id);
                map.put("accessID", accessID);
                map.put("currentUser", master_id);
                return map;

            } */
        };

        requestQueue.add(stringRequest);

    }


问:
Use both $ and jquery as variable
In my project every page loads a cdn jquery script. some use $ and some use jquery. and now I have to use my new script file 'myNewScript.js' in every page.

If I write my function like $(function (){}) it gives error on some pages like

$ is not function

and if I write function like this jquery(function (){}) then it also give error on other page like

jquery is not a function.

I want to know can we use both $ and jquery as variable . like in same script file say 'myNewScript.js' I want to write $(function (){}) and jquery(function (){}).

Every thing is dependent on each other so I can't reverse the loading of the script. I can't think of any solution...

答:
jQuery should always be available using the name jQuery (note the uppercase Q). So use that:

```<code>jQuery(function (){})
</code>```

You can also wrap your code in an IIFE if you would like to refer to jQuery as $ while dealing with the uncertainty whether the global $ actually refers to it:

```<code>(function ($) {
    $(function () {
        // on ready stuff
    });
})(jQuery);
</code>```

Title: Use both $ and jquery as variable

Body:
jQuery should always be available using the name jQuery (note the uppercase Q). So use that:

jQuery(function (){})

You can also wrap your code in an IIFE if you would like to refer to jQuery as $ while dealing with the uncertainty whether the global $ actually refers to it:

(function ($) {
    $(function () {
        // on ready stuff
    });
})(jQuery);


问:
Locking Mechanism for data stored in redis
Dears, I have a problem where multiple redis-clients are accessing a common structure stored in redis-server.

Requirements are as follows:-

If a particular redis-client is accessing the structure stored in redis-server (shall do read and write operation on the structure), no other redis-client should be able to access and wait for being released.

Every time other redis-client is accessing the structure, they should access the updated structure.

How can I put locking mechanism to fulfill this requirement in C Code.
Thanks in Advance.

答:
Dears, thanks all for your response. It was helpful to know various features and generalised way available with the redis.

However I approached as follows as my requirement met this way.

I used secound timestamp (say t_sec) as key and counter as hash value. If in that particular second, further request comes, the counter value corresponding to t_sec key was incremented (HINCRBY command) in atomic way. Rest of the parameters are locally stored in a structure. If counter reaches a particular set limit, requests were dropped.
If this is next sec, new t_sec key value is used and counter is incremented from zero.
t_sec key corresponding to previous second got deleted (HDEL command).


问:
Picking a dll in a particular path while loading a shared library in Windows
I am using MinGW to create a shared library that is dynamically linked and loaded using the LoadLibrary function. My shared library is dependent on a dll that can be found in two different places on the path. These two are different (two different versions) and at the time of loading the library, it picks the wrong dll. How can I explicitly specify which dll to pick?

To be more specific these are the commands I am using:

Compilation

```<code>g++ -m64 -O3 -c my_file.cpp -o myfile.o
</code>```

Creating shared library

```<code>g++ -m64 -shared myfile.o -o myfile.dll
</code>```

I have tried many things including -L option but have not yet been able to figure out how to do this. I also have searched online for a couple of hours but it turn out to be of no use.

Any help is much appreciated.

Thanks in advance

It turns out that the dll I don't want to load is indeed at "The directory where the executable module for the current process is located." The other dll, with the same name is on the path but not where windows looks first. From what this document says, LoadLibrary will always pick the dll from the directory where the executable module for the current process is located, if the dll exists there, no matter what. Is there a way around this? Moving the dlls is really not an option as this is a third party program that we are building on

答:
The chronological order of, how windows looks for DLLs is explained here step by step

https://msdn.microsoft.com/en-us/library/7d83bc18.aspx

After all steps in above link, when it comes to PATH environment variable, windows looks through each directory listed in PATH variable, from left to right.

First try if you can place the correct DLL in any of the locations as listed in the above link. Because path environment variable is the last thing that gets looked into.

If the above step is not possible, then ensure the correct DLL path is on the left of the wrong DLL path in PATH environment variable.

Body:
I am using MinGW to create a shared library that is dynamically linked and loaded using the LoadLibrary function. My shared library is dependent on a dll that can be found in two different places on the path. These two are different (two different versions) and at the time of loading the library, it picks the wrong dll. How can I explicitly specify which dll to pick?

To be more specific these are the commands I am using:

Compilation

g++ -m64 -O3 -c my_file.cpp -o myfile.o

Creating shared library

g++ -m64 -shared myfile.o -o myfile.dll

I have tried many things including -L option but have not yet been able to figure out how to do this. I also have searched online for a couple of hours but it turn out to be of no use.

Any help is much appreciated.

Thanks in advance

It turns out that the dll I don't want to load is indeed at "The directory where the executable module for the current process is located." The other dll, with the same name is on the path but not where windows looks first. From what this document says, LoadLibrary will always pick the dll from the directory where the executable module for the current process is located, if the dll exists there, no matter what. Is there a way around this? Moving the dlls is really not an option as this is a third party program that we are building on


问:
Why Java process hang?
There are many threads in my Java server.
It hangs when one thread recursive invoke a method infinitely.
After the method is invoked 54 times, the process hang, and there is no any log like "StackOverFlow" or "OutOfMemory".

However, as I know, only the thread with the problem will crash, other threads can work normally.

environment:

Linux version 2.6.31-20-server
  (buildd@crested) (gcc version 4.4.1
  (Ubuntu 4.4.1-4ubuntu8) ) java version
  "1.6.0_18" Java(TM) SE Runtime
  Environment (build 1.6.0_18-b07) Java
  HotSpot(TM) 64-Bit Server VM (build
  16.0-b13, mixed mode)

答:
You've answered your question:

It hangs when one thread recursive
  invoke a method infinitely.

My suggestion is to not invoke a method infinitely, you're expanding your stack very quickly as you're recursively calling a method.

What are you trying to do with threads? Can you optimise your code to invoke the method without an infinite loop?

Title: Why Java process hang?