Reverse AJAX - Client Script not called on filtered ScriptSessions

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

        Browser.withAllSessions( new Runnable() {
                public void run()
                {
                        ScriptSessions.addFunctionCall( "newMessage", newMessage );
                }
        } );

But when I am trying to use Browser.withAllSessionsFiltered() then the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/

JS code for user login and storing session attribute:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

Sending message to server:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

Using the ScriptSessionFilter:
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

Is there anything I am missing?

Thanks and regards
Mohammad Faisal
Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
Mohammad,
It looks like you are setting the attribute, then moving to a different page.  I haven't worked in this area in awhile but I am pretty sure each page has it's own scriptsession so the attribute is only available on the first page.  You need to set the user attribute on the scriptsession on the new page as well.



On 11/08/2015 08:41 AM, Mohammad Faisal wrote:

> Hi,
>
> I am create a small "Chatbox" project where I am able to update all
> users using the Browser api as:
>
> Browser.withAllSessions( new Runnable() {
> public void run()
> {
> ScriptSessions.addFunctionCall( "newMessage", newMessage );
> }
> } );
>
> But when I am trying to use Browser.withAllSessionsFiltered() then the
> script is not being executed on client end.
>
> Below are the links to the project and code snippets as well:
>
> Project URL:
> https://github.com/faisal6621/chatbox/
>
> JS code for user login and storing session attribute:
> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
>
> Sending message to server:
> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
>
> Using the ScriptSessionFilter:
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
>
> Is there anything I am missing?
>
> Thanks and regards
> Mohammad Faisal
>

Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal
Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession based on the page, because if I do login with a user "faisal" then on sending the message I can see the println( "found scriptSession user >> faisal" ) in my server log, and if no user logged in with that name (as I have currently hard coded) then there is no line printed in the log.



On Mon, Nov 9, 2015 at 1:20 AM, David Marginian <[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a different page.  I haven't worked in this area in awhile but I am pretty sure each page has it's own scriptsession so the attribute is only available on the first page.  You need to set the user attribute on the scriptsession on the new page as well.




On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

        Browser.withAllSessions( new Runnable() {
                public void run()
                {
                        ScriptSessions.addFunctionCall( "newMessage", newMessage );
                }
        } );

But when I am trying to use Browser.withAllSessionsFiltered() then the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/

JS code for user login and storing session attribute:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

Sending message to server:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

Using the ScriptSessionFilter:
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
In reply to this post by Mohammad Faisal

The script session is still there it is just not associated with the page you need it to be which is why you see that log statement.  You need to set the attribute in the script session from the page you intend to use reverse ajax on.

On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]> wrote:
Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession based on the page, because if I do login with a user "faisal" then on sending the message I can see the println( "found scriptSession user >> faisal" ) in my server log, and if no user logged in with that name (as I have currently hard coded) then there is no line printed in the log.



On Mon, Nov 9, 2015 at 1:20 AM, David Marginian <[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a different page.  I haven't worked in this area in awhile but I am pretty sure each page has it's own scriptsession so the attribute is only available on the first page.  You need to set the user attribute on the scriptsession on the new page as well.




On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

        Browser.withAllSessions( new Runnable() {
                public void run()
                {
                        ScriptSessions.addFunctionCall( "newMessage", newMessage );
                }
        } );

But when I am trying to use Browser.withAllSessionsFiltered() then the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/

JS code for user login and storing session attribute:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

Sending message to server:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

Using the ScriptSessionFilter:
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal
But here in the docs setAttribute() it says:

void setAttribute(java.lang.String name, java.lang.Object value)
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.


On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]> wrote:

The script session is still there it is just not associated with the page you need it to be which is why you see that log statement.  You need to set the attribute in the script session from the page you intend to use reverse ajax on.

On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]> wrote:
Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession based on the page, because if I do login with a user "faisal" then on sending the message I can see the println( "found scriptSession user >> faisal" ) in my server log, and if no user logged in with that name (as I have currently hard coded) then there is no line printed in the log.



On Mon, Nov 9, 2015 at 1:20 AM, David Marginian <[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a different page.  I haven't worked in this area in awhile but I am pretty sure each page has it's own scriptsession so the attribute is only available on the first page.  You need to set the user attribute on the scriptsession on the new page as well.




On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

        Browser.withAllSessions( new Runnable() {
                public void run()
                {
                        ScriptSessions.addFunctionCall( "newMessage", newMessage );
                }
        } );

But when I am trying to use Browser.withAllSessionsFiltered() then the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/

JS code for user login and storing session attribute:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

Sending message to server:
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

Using the ScriptSessionFilter:
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

Is there anything I am missing?

Thanks and regards
Mohammad Faisal




Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
That is not inconsistent with what I said.  Those are the docs for DWR's
ScriptSession.  "Binds an object to this session" refers to a
ScriptSession, not an HttpSession.  Each page has a distinct
ScriptSession.  You are setting the attribute in the ScriptSession on
the login (index) page.  You are then re-directing to the page where you
actually use reverse-ajax, this page's ScriptSession does not have the
attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:

> But here in the docs setAttribute() [8] it says:
>
> void setAttribute(java.lang.String name, java.lang.Object value)
>
> Binds an object to this session, using the name specified. If an
> object of the same name is already bound to the session, the object is
> replaced.
>
> On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
> wrote:
>
>> The script session is still there it is just not associated with the
>> page you need it to be which is why you see that log statement. 
>> You need to set the attribute in the script session from the page
>> you intend to use reverse ajax on.
>> On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
>> wrote:
>>
>> Hi David,
>>
>> Thanks for the reply.
>>
>> I think the issue is not with the attribute set in the ScriptSession
>> based on the page, because if I do login with a user "faisal" then
>> on sending the message I can see the println( "found scriptSession
>> user >> faisal" ) [1] in my server log, and if no user logged in
>> with that name (as I have currently hard coded [2]) then there is no
>> line printed in the log.
>>
>> On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
>> <[hidden email]> wrote:
>> Mohammad,
>> It looks like you are setting the attribute, then moving to a
>> different page.  I haven't worked in this area in awhile but I am
>> pretty sure each page has it's own scriptsession so the attribute is
>> only available on the first page.  You need to set the user
>> attribute on the scriptsession on the new page as well.
>>
>> On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
>> Hi,
>>
>> I am create a small "Chatbox" project where I am able to update all
>> users using the Browser api as:
>>
>>         Browser.withAllSessions( new Runnable() {
>>                 public void run()
>>                 {
>>                         ScriptSessions.addFunctionCall(
>> "newMessage", newMessage );
>>                 }
>>         } );
>>
>> But when I am trying to use Browser.withAllSessionsFiltered() then
>> the
>> script is not being executed on client end.
>>
>> Below are the links to the project and code snippets as well:
>>
>> Project URL:
>> https://github.com/faisal6621/chatbox/ [3]
>>
>> JS code for user login and storing session attribute:
>>
> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
>> [4]
>>
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
>> [5]
>>
>> Sending message to server:
>>
> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
>> [6]
>>
>> Using the ScriptSessionFilter:
>>
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
>> [7]
>>
>> Is there anything I am missing?
>>
>> Thanks and regards
>> Mohammad Faisal
>
>
>
> Links:
> ------
> [1]
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
> [2]
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
> [3] https://github.com/faisal6621/chatbox/
> [4]
> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
> [5]
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
> [6]
> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
> [7]
> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
> [8]
> http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29
Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal

I cannot figure out where do I supposed to add attribute in ScriptSession from mainpage.jsp.
Can you help me with that?

On 9 Nov 2015 22:57, <[hidden email]> wrote:
That is not inconsistent with what I said.  Those are the docs for DWR's ScriptSession.  "Binds an object to this session" refers to a ScriptSession, not an HttpSession.  Each page has a distinct ScriptSession.  You are setting the attribute in the ScriptSession on the login (index) page.  You are then re-directing to the page where you actually use reverse-ajax, this page's ScriptSession does not have the attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:
But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement. 
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

        Browser.withAllSessions( new Runnable() {
                public void run()
                {
                        ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                }
        } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[5]

Sending message to server:

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[6]

Using the ScriptSessionFilter:

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]
http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29
Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal
Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
I have added code to update the ScriptSession attribute but it still
not works.

On 11/10/15, Mohammad Faisal <[hidden email]> wrote:

> I cannot figure out where do I supposed to add attribute in ScriptSession
> from mainpage.jsp.
> Can you help me with that?
> On 9 Nov 2015 22:57, <[hidden email]> wrote:
>
>> That is not inconsistent with what I said.  Those are the docs for DWR's
>> ScriptSession.  "Binds an object to this session" refers to a
>> ScriptSession, not an HttpSession.  Each page has a distinct
>> ScriptSession.  You are setting the attribute in the ScriptSession on the
>> login (index) page.  You are then re-directing to the page where you
>> actually use reverse-ajax, this page's ScriptSession does not have the
>> attribute set.
>>
>> On 2015-11-09 09:33, Mohammad Faisal wrote:
>>
>>> But here in the docs setAttribute() [8] it says:
>>>
>>> void setAttribute(java.lang.String name, java.lang.Object value)
>>>
>>> Binds an object to this session, using the name specified. If an
>>> object of the same name is already bound to the session, the object is
>>> replaced.
>>>
>>> On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
>>> wrote:
>>>
>>> The script session is still there it is just not associated with the
>>>> page you need it to be which is why you see that log statement.
>>>> You need to set the attribute in the script session from the page
>>>> you intend to use reverse ajax on.
>>>> On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
>>>> wrote:
>>>>
>>>> Hi David,
>>>>
>>>> Thanks for the reply.
>>>>
>>>> I think the issue is not with the attribute set in the ScriptSession
>>>> based on the page, because if I do login with a user "faisal" then
>>>> on sending the message I can see the println( "found scriptSession
>>>> user >> faisal" ) [1] in my server log, and if no user logged in
>>>> with that name (as I have currently hard coded [2]) then there is no
>>>> line printed in the log.
>>>>
>>>> On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
>>>> <[hidden email]> wrote:
>>>> Mohammad,
>>>> It looks like you are setting the attribute, then moving to a
>>>> different page.  I haven't worked in this area in awhile but I am
>>>> pretty sure each page has it's own scriptsession so the attribute is
>>>> only available on the first page.  You need to set the user
>>>> attribute on the scriptsession on the new page as well.
>>>>
>>>> On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
>>>> Hi,
>>>>
>>>> I am create a small "Chatbox" project where I am able to update all
>>>> users using the Browser api as:
>>>>
>>>>         Browser.withAllSessions( new Runnable() {
>>>>                 public void run()
>>>>                 {
>>>>                         ScriptSessions.addFunctionCall(
>>>> "newMessage", newMessage );
>>>>                 }
>>>>         } );
>>>>
>>>> But when I am trying to use Browser.withAllSessionsFiltered() then
>>>> the
>>>> script is not being executed on client end.
>>>>
>>>> Below are the links to the project and code snippets as well:
>>>>
>>>> Project URL:
>>>> https://github.com/faisal6621/chatbox/ [3]
>>>>
>>>> JS code for user login and storing session attribute:
>>>>
>>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
>>>
>>>> [4]
>>>>
>>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
>>>
>>>> [5]
>>>>
>>>> Sending message to server:
>>>>
>>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
>>>
>>>> [6]
>>>>
>>>> Using the ScriptSessionFilter:
>>>>
>>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
>>>
>>>> [7]
>>>>
>>>> Is there anything I am missing?
>>>>
>>>> Thanks and regards
>>>> Mohammad Faisal
>>>>
>>>
>>>
>>>
>>> Links:
>>> ------
>>> [1]
>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
>>> [2]
>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
>>> [3] https://github.com/faisal6621/chatbox/
>>> [4]
>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
>>> [5]
>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
>>> [6]
>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
>>> [7]
>>>
>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
>>> [8]
>>>
>>> http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
In reply to this post by Mohammad Faisal
In a real system you would know what user was logged in on each page (attribute on HttpSession, etc.).  So, you simply move setting the attribute on the script session from the login page to the main page (where you are actually using reverse ajax).  If you want to do this automatically you can use a ScriptSessionListener.  There is an example of how to do this in our docs - http://directwebremoting.org/dwr/documentation/reverse-ajax/hints-and-tips.html#scriptSessionListeners

On 11/09/2015 06:31 PM, Mohammad Faisal wrote:

I cannot figure out where do I supposed to add attribute in ScriptSession from mainpage.jsp.
Can you help me with that?

On 9 Nov 2015 22:57, <[hidden email]> wrote:
That is not inconsistent with what I said.  Those are the docs for DWR's ScriptSession.  "Binds an object to this session" refers to a ScriptSession, not an HttpSession.  Each page has a distinct ScriptSession.  You are setting the attribute in the ScriptSession on the login (index) page.  You are then re-directing to the page where you actually use reverse-ajax, this page's ScriptSession does not have the attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:
But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement. 
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

        Browser.withAllSessions( new Runnable() {
                public void run()
                {
                        ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                }
        } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[5]

Sending message to server:

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[6]

Using the ScriptSessionFilter:

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]
https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]
https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]
http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29

Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
In reply to this post by Mohammad Faisal
I pulled your code down, logged in as Faisal, send a message.  I am
getting into the run method and seeing the new message on the page.  
What isn't working?

On 11/09/2015 06:56 PM, Mohammad Faisal wrote:

> Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
> I have added code to update the ScriptSession attribute but it still
> not works.
>
> On 11/10/15, Mohammad Faisal <[hidden email]> wrote:
>> I cannot figure out where do I supposed to add attribute in ScriptSession
>> from mainpage.jsp.
>> Can you help me with that?
>> On 9 Nov 2015 22:57, <[hidden email]> wrote:
>>
>>> That is not inconsistent with what I said.  Those are the docs for DWR's
>>> ScriptSession.  "Binds an object to this session" refers to a
>>> ScriptSession, not an HttpSession.  Each page has a distinct
>>> ScriptSession.  You are setting the attribute in the ScriptSession on the
>>> login (index) page.  You are then re-directing to the page where you
>>> actually use reverse-ajax, this page's ScriptSession does not have the
>>> attribute set.
>>>
>>> On 2015-11-09 09:33, Mohammad Faisal wrote:
>>>
>>>> But here in the docs setAttribute() [8] it says:
>>>>
>>>> void setAttribute(java.lang.String name, java.lang.Object value)
>>>>
>>>> Binds an object to this session, using the name specified. If an
>>>> object of the same name is already bound to the session, the object is
>>>> replaced.
>>>>
>>>> On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
>>>> wrote:
>>>>
>>>> The script session is still there it is just not associated with the
>>>>> page you need it to be which is why you see that log statement.
>>>>> You need to set the attribute in the script session from the page
>>>>> you intend to use reverse ajax on.
>>>>> On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
>>>>> wrote:
>>>>>
>>>>> Hi David,
>>>>>
>>>>> Thanks for the reply.
>>>>>
>>>>> I think the issue is not with the attribute set in the ScriptSession
>>>>> based on the page, because if I do login with a user "faisal" then
>>>>> on sending the message I can see the println( "found scriptSession
>>>>> user >> faisal" ) [1] in my server log, and if no user logged in
>>>>> with that name (as I have currently hard coded [2]) then there is no
>>>>> line printed in the log.
>>>>>
>>>>> On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
>>>>> <[hidden email]> wrote:
>>>>> Mohammad,
>>>>> It looks like you are setting the attribute, then moving to a
>>>>> different page.  I haven't worked in this area in awhile but I am
>>>>> pretty sure each page has it's own scriptsession so the attribute is
>>>>> only available on the first page.  You need to set the user
>>>>> attribute on the scriptsession on the new page as well.
>>>>>
>>>>> On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
>>>>> Hi,
>>>>>
>>>>> I am create a small "Chatbox" project where I am able to update all
>>>>> users using the Browser api as:
>>>>>
>>>>>          Browser.withAllSessions( new Runnable() {
>>>>>                  public void run()
>>>>>                  {
>>>>>                          ScriptSessions.addFunctionCall(
>>>>> "newMessage", newMessage );
>>>>>                  }
>>>>>          } );
>>>>>
>>>>> But when I am trying to use Browser.withAllSessionsFiltered() then
>>>>> the
>>>>> script is not being executed on client end.
>>>>>
>>>>> Below are the links to the project and code snippets as well:
>>>>>
>>>>> Project URL:
>>>>> https://github.com/faisal6621/chatbox/ [3]
>>>>>
>>>>> JS code for user login and storing session attribute:
>>>>>
>>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
>>>>
>>>>> [4]
>>>>>
>>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
>>>>
>>>>> [5]
>>>>>
>>>>> Sending message to server:
>>>>>
>>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
>>>>
>>>>> [6]
>>>>>
>>>>> Using the ScriptSessionFilter:
>>>>>
>>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
>>>>
>>>>> [7]
>>>>>
>>>>> Is there anything I am missing?
>>>>>
>>>>> Thanks and regards
>>>>> Mohammad Faisal
>>>>>
>>>>
>>>>
>>>> Links:
>>>> ------
>>>> [1]
>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
>>>> [2]
>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
>>>> [3] https://github.com/faisal6621/chatbox/
>>>> [4]
>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
>>>> [5]
>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
>>>> [6]
>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
>>>> [7]
>>>>
>>>> https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
>>>> [8]
>>>>
>>>> http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29
>>>>

Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal

When I am sending the message run method executes but it does not appear on the page.

On 10 Nov 2015 08:52, "David Marginian" <[hidden email]> wrote:
I pulled your code down, logged in as Faisal, send a message.  I am getting into the run method and seeing the new message on the page.  What isn't working?

On 11/09/2015 06:56 PM, Mohammad Faisal wrote:
Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
I have added code to update the ScriptSession attribute but it still
not works.

On 11/10/15, Mohammad Faisal <[hidden email]> wrote:
I cannot figure out where do I supposed to add attribute in ScriptSession
from mainpage.jsp.
Can you help me with that?
On 9 Nov 2015 22:57, <[hidden email]> wrote:

That is not inconsistent with what I said.  Those are the docs for DWR's
ScriptSession.  "Binds an object to this session" refers to a
ScriptSession, not an HttpSession.  Each page has a distinct
ScriptSession.  You are setting the attribute in the ScriptSession on the
login (index) page.  You are then re-directing to the page where you
actually use reverse-ajax, this page's ScriptSession does not have the
attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:

But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement.
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

         Browser.withAllSessions( new Runnable() {
                 public void run()
                 {
                         ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                 }
         } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11

[4]


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

[5]

Sending message to server:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

[6]

Using the ScriptSessionFilter:


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]

http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29


Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
I would verify that you are actually running your latest code, that your container hasn't cached it, etc.  Like I said, I pulled down your code and it is working as expected, not sure what else to suggest.

On 11/09/2015 09:52 PM, Mohammad Faisal wrote:

When I am sending the message run method executes but it does not appear on the page.

On 10 Nov 2015 08:52, "David Marginian" <[hidden email]> wrote:
I pulled your code down, logged in as Faisal, send a message.  I am getting into the run method and seeing the new message on the page.  What isn't working?

On 11/09/2015 06:56 PM, Mohammad Faisal wrote:
Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
I have added code to update the ScriptSession attribute but it still
not works.

On 11/10/15, Mohammad Faisal <[hidden email]> wrote:
I cannot figure out where do I supposed to add attribute in ScriptSession
from mainpage.jsp.
Can you help me with that?
On 9 Nov 2015 22:57, <[hidden email]> wrote:

That is not inconsistent with what I said.  Those are the docs for DWR's
ScriptSession.  "Binds an object to this session" refers to a
ScriptSession, not an HttpSession.  Each page has a distinct
ScriptSession.  You are setting the attribute in the ScriptSession on the
login (index) page.  You are then re-directing to the page where you
actually use reverse-ajax, this page's ScriptSession does not have the
attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:

But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement.
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

         Browser.withAllSessions( new Runnable() {
                 public void run()
                 {
                         ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                 }
         } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11

[4]


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

[5]

Sending message to server:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

[6]

Using the ScriptSessionFilter:


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]

http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29



Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal

I am using JBoss AS7 and to deploy it I am first creating the war from maven command and copying the war into JBoss deployment directory.
In server log I see deployment/replaced deployment success.

On 10 Nov 2015 17:43, "David Marginian" <[hidden email]> wrote:
I would verify that you are actually running your latest code, that your container hasn't cached it, etc.  Like I said, I pulled down your code and it is working as expected, not sure what else to suggest.

On 11/09/2015 09:52 PM, Mohammad Faisal wrote:

When I am sending the message run method executes but it does not appear on the page.

On 10 Nov 2015 08:52, "David Marginian" <[hidden email]> wrote:
I pulled your code down, logged in as Faisal, send a message.  I am getting into the run method and seeing the new message on the page.  What isn't working?

On 11/09/2015 06:56 PM, Mohammad Faisal wrote:
Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
I have added code to update the ScriptSession attribute but it still
not works.

On 11/10/15, Mohammad Faisal <[hidden email]> wrote:
I cannot figure out where do I supposed to add attribute in ScriptSession
from mainpage.jsp.
Can you help me with that?
On 9 Nov 2015 22:57, <[hidden email]> wrote:

That is not inconsistent with what I said.  Those are the docs for DWR's
ScriptSession.  "Binds an object to this session" refers to a
ScriptSession, not an HttpSession.  Each page has a distinct
ScriptSession.  You are setting the attribute in the ScriptSession on the
login (index) page.  You are then re-directing to the page where you
actually use reverse-ajax, this page's ScriptSession does not have the
attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:

But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement.
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

         Browser.withAllSessions( new Runnable() {
                 public void run()
                 {
                         ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                 }
         } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11

[4]


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

[5]

Sending message to server:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

[6]

Using the ScriptSessionFilter:


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]

http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29



Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

david@butterdev.com
I pulled your code down, ran it and it works.  I am not sure what you want us to do.  You need to simplify your deployment.  I would suggest adding the jetty maven plugin to your pom and running it locally to verify you are seeing the same behavior as you are seeing in JBoss.  Or do a simply Google search - http://stackoverflow.com/questions/1568546/does-jboss-cache-class-files

On 11/10/2015 06:12 AM, Mohammad Faisal wrote:

I am using JBoss AS7 and to deploy it I am first creating the war from maven command and copying the war into JBoss deployment directory.
In server log I see deployment/replaced deployment success.

On 10 Nov 2015 17:43, "David Marginian" <[hidden email]> wrote:
I would verify that you are actually running your latest code, that your container hasn't cached it, etc.  Like I said, I pulled down your code and it is working as expected, not sure what else to suggest.

On 11/09/2015 09:52 PM, Mohammad Faisal wrote:

When I am sending the message run method executes but it does not appear on the page.

On 10 Nov 2015 08:52, "David Marginian" <[hidden email]> wrote:
I pulled your code down, logged in as Faisal, send a message.  I am getting into the run method and seeing the new message on the page.  What isn't working?

On 11/09/2015 06:56 PM, Mohammad Faisal wrote:
Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
I have added code to update the ScriptSession attribute but it still
not works.

On 11/10/15, Mohammad Faisal <[hidden email]> wrote:
I cannot figure out where do I supposed to add attribute in ScriptSession
from mainpage.jsp.
Can you help me with that?
On 9 Nov 2015 22:57, <[hidden email]> wrote:

That is not inconsistent with what I said.  Those are the docs for DWR's
ScriptSession.  "Binds an object to this session" refers to a
ScriptSession, not an HttpSession.  Each page has a distinct
ScriptSession.  You are setting the attribute in the ScriptSession on the
login (index) page.  You are then re-directing to the page where you
actually use reverse-ajax, this page's ScriptSession does not have the
attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:

But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement.
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

         Browser.withAllSessions( new Runnable() {
                 public void run()
                 {
                         ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                 }
         } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11

[4]


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

[5]

Sending message to server:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

[6]

Using the ScriptSessionFilter:


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]

http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29




Reply | Threaded
Open this post in threaded view
|

Re: Reverse AJAX - Client Script not called on filtered ScriptSessions

Mohammad Faisal

Hi David,
Thanks for the time.
Finally it's working as expected with the maven profile"jboss" which I already have added.
You were right about the page scoped ScriptSession.
To fix the issue in "mainpage.jsp" I have added a call to update/set the ScriptSession attribute.

I will also gonna try it with listener which you have previously suggested.

Thanks again for you help.

Regards
Mohammad Faisal

I pulled your code down, ran it and it works.  I am not sure what you want us to do.  You need to simplify your deployment.  I would suggest adding the jetty maven plugin to your pom and running it locally to verify you are seeing the same behavior as you are seeing in JBoss.  Or do a simply Google search - http://stackoverflow.com/questions/1568546/does-jboss-cache-class-files

On 11/10/2015 06:12 AM, Mohammad Faisal wrote:

I am using JBoss AS7 and to deploy it I am first creating the war from maven command and copying the war into JBoss deployment directory.
In server log I see deployment/replaced deployment success.

On 10 Nov 2015 17:43, "David Marginian" <[hidden email]> wrote:
I would verify that you are actually running your latest code, that your container hasn't cached it, etc.  Like I said, I pulled down your code and it is working as expected, not sure what else to suggest.

On 11/09/2015 09:52 PM, Mohammad Faisal wrote:

When I am sending the message run method executes but it does not appear on the page.

On 10 Nov 2015 08:52, "David Marginian" <[hidden email]> wrote:
I pulled your code down, logged in as Faisal, send a message.  I am getting into the run method and seeing the new message on the page.  What isn't working?

On 11/09/2015 06:56 PM, Mohammad Faisal wrote:
Here (https://github.com/faisal6621/chatbox/commit/8cf158c3da57946ad4018e749d1488272beee23d#diff-8918f89ff39d8d57457eb16e16396017R22)
I have added code to update the ScriptSession attribute but it still
not works.

On 11/10/15, Mohammad Faisal <[hidden email]> wrote:
I cannot figure out where do I supposed to add attribute in ScriptSession
from mainpage.jsp.
Can you help me with that?
On 9 Nov 2015 22:57, <[hidden email]> wrote:

That is not inconsistent with what I said.  Those are the docs for DWR's
ScriptSession.  "Binds an object to this session" refers to a
ScriptSession, not an HttpSession.  Each page has a distinct
ScriptSession.  You are setting the attribute in the ScriptSession on the
login (index) page.  You are then re-directing to the page where you
actually use reverse-ajax, this page's ScriptSession does not have the
attribute set.

On 2015-11-09 09:33, Mohammad Faisal wrote:

But here in the docs setAttribute() [8] it says:

void setAttribute(java.lang.String name, java.lang.Object value)

Binds an object to this session, using the name specified. If an
object of the same name is already bound to the session, the object is
replaced.

On Mon, Nov 9, 2015 at 8:50 AM, David Marginian <[hidden email]>
wrote:

The script session is still there it is just not associated with the
page you need it to be which is why you see that log statement.
You need to set the attribute in the script session from the page
you intend to use reverse ajax on.
On Nov 8, 2015 6:54 PM, Mohammad Faisal <[hidden email]>
wrote:

Hi David,

Thanks for the reply.

I think the issue is not with the attribute set in the ScriptSession
based on the page, because if I do login with a user "faisal" then
on sending the message I can see the println( "found scriptSession
user >> faisal" ) [1] in my server log, and if no user logged in
with that name (as I have currently hard coded [2]) then there is no
line printed in the log.

On Mon, Nov 9, 2015 at 1:20 AM, David Marginian
<[hidden email]> wrote:
Mohammad,
It looks like you are setting the attribute, then moving to a
different page.  I haven't worked in this area in awhile but I am
pretty sure each page has it's own scriptsession so the attribute is
only available on the first page.  You need to set the user
attribute on the scriptsession on the new page as well.

On 11/08/2015 08:41 AM, Mohammad Faisal wrote:
Hi,

I am create a small "Chatbox" project where I am able to update all
users using the Browser api as:

         Browser.withAllSessions( new Runnable() {
                 public void run()
                 {
                         ScriptSessions.addFunctionCall(
"newMessage", newMessage );
                 }
         } );

But when I am trying to use Browser.withAllSessionsFiltered() then
the
script is not being executed on client end.

Below are the links to the project and code snippets as well:

Project URL:
https://github.com/faisal6621/chatbox/ [3]

JS code for user login and storing session attribute:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11

[4]


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29

[5]

Sending message to server:


https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82

[6]

Using the ScriptSessionFilter:


https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57

[7]

Is there anything I am missing?

Thanks and regards
Mohammad Faisal



Links:
------
[1]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L54
[2]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50
[3] https://github.com/faisal6621/chatbox/
[4]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/index.jsp#L11
[5]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/Login.java#L29
[6]

https://github.com/faisal6621/chatbox/blob/master/src/main/webapp/mainpage.jsp#L77-L82
[7]

https://github.com/faisal6621/chatbox/blob/master/src/main/java/chatbox/ChatRoomDatabase.java#L50-L57
[8]

http://directwebremoting.org/dwr/javadoc/org/directwebremoting/ScriptSession.html#setAttribute%28java.lang.String,%20java.lang.Object%29