signal isn't being routed to the AddCommentCommand
For some reason my signal isn't being routed to the AddCommentCommand after the AddCommentSignal is fired from the AddCommentsMediator by signal.dispatch(comment);
package controller.setup
{
import controller.*;
import events.ApplicationConfigurationEvent;
import org.robotlegs.base.SignalCommandMap;
import org.robotlegs.mvcs.SignalCommand;
import views.events.*;
import views.signalz.AddCommentSignal;
public class ConfigureControllerCommand extends SignalCommand
{
override public function execute():void
{
commandMap.mapEvent(LDAP_LoginEvent.LOGIN,AuthenticateLoginCommand);
signalCommandMap.mapSignalClass(AddCommentSignal,AddCommentCommand);
dispatch(new ApplicationConfigurationEvent(ApplicationConfigurationEvent.CONFIGURE_SERVICE));
}
}
}
package views
{
import events.UserEvent;
import flash.events.Event;
import flash.events.MouseEvent;
import model.UserModel;
import model.vo.Comment;
import org.robotlegs.mvcs.Mediator;
import views.events.LDAP_LoginEvent;
import views.events.LogoutEvent;
import views.signalz.AddCommentSignal;
public class AddCommentsMediator extends Mediator
{
[Inject]
public var viewObject:AddComments;
[Inject]
public var userModel:UserModel;
override public function onRegister():void
{
eventMap.mapListener(eventDispatcher, LogoutEvent.LOGOUT,handleLogout );
viewObject.signal.add(handleADD_COMMENT);
}
private function handleLogout(event:Event):void
{
viewObject.clearFields();
}
private function handleADD_COMMENT(text:String):void
{
var comment:Comment = new Comment();
comment.comment = text;
comment.contributingSAMAccountName = userModel.loggedInUser.SAMAccountName;
var signal : AddCommentSignal = new AddCommentSignal();
signal.dispatch(comment);
}
}
}
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Nikos on 15 Oct, 2010 09:52 AM
Still can't figure out the issue here, I've verified in the debuger that the signalCommandMap gets updated correctly when I do this:
signalCommandMap.mapSignalClass(AddCommentSignal,AddCommentCommand);
But AddCommentCommand is not called when I do this and I'm not sure where to look to fix this. Any ideas where I could look next? Could the commandMap be interfering?
var signal : AddCommentSignal = new AddCommentSignal();
Support Staff 2 Posted by creynders on 15 Oct, 2010 09:56 AM
AFAIK you need to inject the AddCommentSignal
Support Staff 3 Posted by Shaun Smith on 15 Oct, 2010 10:11 AM
Hi Nikos,
How would the SignalCommandMap know when the signal fires if you instantiate it yourself? Surely you need to use the signal instance that is in the signalCommandMap? Something like:
Or, by using injection as Creynders pointed out.
Either way, you need to be dispatching from the same signal instance as the one that the signal command map is listening to.
4 Posted by Nikos on 15 Oct, 2010 10:27 AM
Opps, makes perfect sense thanks, I guess I thought it worked the same way as the commandMap worked with native events :), ie not needing event injection
Nikos closed this discussion on 04 Dec, 2010 10:03 AM.