help problem with diferentiating uses with dwr sessions

View: New views
1 Messages — Rating Filter:   Alert me  

help problem with diferentiating uses with dwr sessions

by robyp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi to all,

problem:
i write a dwr push.. a web page have got a textbox with a button. only the user that write abc and send with button to dwr can get the push data (BrowserwithPage and other update all pages so don't works for me i suppose).

my solution:

i begin with reading session created (1) and then (2) apply
push;
I read about to differentiate users using scriptsession at:
http://directwebremoting.org/dwr/reverse-ajax/hints-and-tips.html:

1)

when a try to construct a listener it doesn't works:

public class Initiate implements ScriptSessionListener{
..

  public void sessionCreated(ScriptSessionEvent arg0) {
         System.out.println("IDSessionDwrListener: new session created for user " + u.getUser_id()
                + "on WebContext: " + d.getWebContext());
    }

    public void sessionDestroyed(ScriptSessionEvent arg0) {
          System.out.println("IDSessionDwrListener: Session destroyed" + u.getUser_id()
                + "on WebContext: " + d.getWebContext());
    }
..

public void startService(String id_user){
..
Container container = d.getWebContext().getContainer();
ScriptSessionManager manager = container.getBean(ScriptSessionManager.class);
manager.addScriptSessionListener(this);
..
}

so i try to add to web.xml (servlet) this:

<init-param>
            <description>enable SessionScriptListener</description>
            <param-name>org.directwebremoting.event.ScriptSessionListener</param-name>
            <param-value>it.netbureau.DwrSessionSpike.Initiate</param-value>
        </init-param>
        </servlet>

but i get from dwr:
GRAVE:   - Can't use : it.netbureau.DwrSessionSpike.Initiate@14c5b37 to implement org.directwebremoting.event.ScriptSessionListener. Reason: java.lang.ClassNotFoundException: it.netbureau.DwrSessionSpike.Initiate@14c5b37
org.directwebremoting.impl.DefaultContainer@2da5a6
org.directwebremoting.impl.DefaultScriptSessionManager@1b09282

why?

2) i try to set the value properties of a session:

webContext d = getWebContext..

if (u.getUser_id().equals("abc")){
              ScriptSession scriptSession = d.getScriptSession();
              scriptSession.setAttribute("user_id", "abc");
        }
//if i am user abc so pushing data
 ScriptSession scriptSession = d.getScriptSession();
String userid = ((String)scriptSession.getAttribute("user_id"));
if (userid!=null && userid.equals(userIDSelected)){
            System.out.println("i'm abc");
}

.. ok this work open 2, 3 browser and write abc, dfg, hjj
only one time "abc" appear on systm.out
so now how can say to dwr to give data only to user (session with abc?)?

Browser.withPage(page, new Runnable() { doesn't work
Browser.withSession could be? i used it but it doesn't work, maybe i'm wrong? how does works?


please help me, i'm terrible late in the project developping
thank you very much

Roby


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...