Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
June 23, 2017, 03:24:42 AM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1] 2
Print
Author Topic: Events on GWT  (Read 17013 times)
marcelotmelo
Newbie
*
Posts: 4


View Profile Email
« on: October 18, 2008, 03:22:25 PM »

Hi all,

we're using puremvc for Java on a GWT project. I've wrapped my mind around almost everything, but one doubt still haunts me. How to properly handle events sent by widgets on GWT?

In Flex we could create and dispatch an Event on the view, and register the mediator as a listener to this event. I thought about doing the same in GWT, but dispatching an Event from the view as is done in Flex doesn't seem like an option...

What I could do is making my Mediator implement the Listener, get each widget that needs such listener from the view and add itself as a ClickListener. This seems fairly complicated to me, and I am only doing this in order to avoid a coupling between the View and Mediator on the View level, since I could add a reference to the Mediator on the view, and when creating each button I would simply add the mediator as a Listener. That would be simpler, but does not look like the PureMVC way.

Anyone has a better idea? One that would be fit to the puremvc principles?

Thanks!
Logged
marcelotmelo
Newbie
*
Posts: 4


View Profile Email
« Reply #1 on: October 23, 2008, 04:47:09 AM »

Well, seems like no one is using PureMVC and GWT... I am starting to regret my decision...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2870



View Profile WWW
« Reply #2 on: October 26, 2008, 07:12:53 AM »

Hi Marcel,

I am sorry no one caught this. I expected the Java port owner to respond. I will email him.

-=Cliff>
Logged
marcelotmelo
Newbie
*
Posts: 4


View Profile Email
« Reply #3 on: October 27, 2008, 05:10:59 AM »

I asked the same question and got a lot of answers on the GWT list, thanks.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2870



View Profile WWW
« Reply #4 on: October 28, 2008, 07:01:05 AM »

Would you be kind enough to share those answers with us for the next weary traveller passing through?

Thanks,
-=Cliff>
Logged
marcelotmelo
Newbie
*
Posts: 4


View Profile Email
« Reply #5 on: October 28, 2008, 09:17:34 AM »

Sure!

Here's the link for the whole thread:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/67e81d9d761598e2/f7a4ec3ad0ff1725?hl=en&lnk=gst&q=puremvc#f7a4ec3ad0ff1725
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2870



View Profile WWW
« Reply #6 on: October 30, 2008, 06:17:31 AM »

Thanks!

This port is just getting off the ground which is why its still marked as in beta. We can use all the input we can get!

Cheers,
-=Cliff>
Logged
mkn
Newbie
*
Posts: 3


View Profile
« Reply #7 on: February 11, 2009, 04:54:51 AM »

Hello,

This port is just getting off the ground which is why its still marked as in beta.

Does the google code site contain the latest version (dated Septemper) ? I noticed that the demo and the library are not compatible, at least and it takes an awful lot of development time to try to fix the differences.



Markku
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2870



View Profile WWW
« Reply #8 on: February 11, 2009, 06:27:44 AM »

The latest code should be on the trunk. There are changes there about to be tagged 1.0.3.

Also, Anthony Quinault has produced some demos to go with it, which we are going to get into the repo publish at the same time as the new MultiCore version when he gets back from holiday.

-=Cliff> 
Logged
mkn
Newbie
*
Posts: 3


View Profile
« Reply #9 on: February 11, 2009, 08:04:18 AM »

...when he gets back from holiday.

Ok, thanks, Cliff. I will try to find the repository and download the latest version.

Looking forward to Anthony coming back Smiley

Edit: found the repository - always forget where it is in the google code sites!

Markku
« Last Edit: February 11, 2009, 08:07:47 AM by mkn » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2870



View Profile WWW
« Reply #10 on: February 11, 2009, 09:14:54 PM »

No, sorry. The google code site was put up before the port was moved to the PureMVC repo. The google code site should be shut down.

The url is http://trac.puremvc.org/PureMVC_Java_MultiCore

-=Cliff>
Logged
aquinault
Moderator
Jr. Member
*****
Posts: 10


View Profile Email
« Reply #11 on: May 07, 2009, 08:56:57 AM »

Hi,

I recently coded the port of EmployeeAdmin for GWT.
Is anyone interested by this port and another examples?

Anthony Quinault.
Logged
denne
Newbie
*
Posts: 6


View Profile
« Reply #12 on: June 19, 2009, 01:26:05 AM »

I solved the situation with GWT and Java not supporting events like the examples use in ActionScript with creating my own Callback interface.

In the UI Code:
Code:
       
submitCommand.addClickHandler(new ClickHandler(){
@Override
  public void onClick(ClickEvent event) {
  // this tells the Mediator to handle the new activity.
  Activity act = new Activity(descriptionInput.getValue(),
       typeInput.getValue(),   dateInput.getValue());
  callback.execute(act);
}       
});

And previously in the constructor of the Mediator, the Mediator has called this method on the view to register a Callback event in the mediator.
Code:
  
    // add callback to be executed when new activity has been added.
    getViewComponent().setCallback(new Callback(){
@Override
public void execute(Object... params) {
    doAddActivity(params);
}
    });

Resulting in the same behaviour as in action script addEventListener.
Any comments about this solution? Any better solution found?
How does other people do this?
Logged
aquinault
Moderator
Jr. Member
*****
Posts: 10


View Profile Email
« Reply #13 on: June 19, 2009, 03:17:24 AM »

I think you should use :

Code:
submitCommand.addClickHandler(new ClickHandler(){
@Override
  public void onClick(ClickEvent event) {
  // this tells the Mediator to handle the new activity.
  Activity act = new Activity(descriptionInput.getValue(),
       typeInput.getValue(),   dateInput.getValue());

   sendNotification(ApplicationFacade.NEW_ACTIVITY, act);
}       
});


Code:
@Override
public final String[] listNotificationInterests() {
    return new String[] { ApplicationFacade.NEW_ACTIVITY
  };
}


Code:
@Override
public final void handleNotification(final INotification notification) {
  if (notification.getName().equals(ApplicationFacade.NEW_ACTIVITY)) {
    activity = (Activity) notification.getBody();
    doAddActivity(activity);
}

Anthony.
Logged
denne
Newbie
*
Posts: 6


View Profile
« Reply #14 on: June 19, 2009, 05:05:11 AM »

The best practice guide (Page 13, Notification vs Events) shows that Notifications should be used to communicate between PureMVC actors Mediators, Commands and Proxies.

Between Proxies and VOs and Mediators  and View Components local means like Events or direct messages/method calls of your own choice.
Logged
Pages: [1] 2
Print
Jump to: