I am using the below code to execute a command from handler class which uses command context
CheckUserInMemberGroupCmd checkGrpCmd = (CheckUserInMemberGroupCmd)
CommandFactory.createCommand(
CheckUserInMemberGroupCmd.Name,
Integer.valueOf(storeId));
checkGrpCmd.setUser(memberId);
checkGrpCmd.setMemberGroupName(mbrName);
checkGrpCmd.setCommandContext(getCommandContext());
checkGrpCmd.execute();
I'm explicitly calling the method getCommandContext() in same handler class which results null and so the NullPointerException thrown.
public CommandContext getCommandContext()
{
String METHODNAME = "getCommandContext";
if (this.viewCommandContext != null) {
ECTrace.trace(0L, super.getClass().getName(), "getCommandContext", "use viewCommandContext");
return this.viewCommandContext;
}
ECTrace.trace(0L, super.getClass().getName(), "getCommandContext", "use commandContext if any");
return this.commandContext;
}
Now, what could i do to make this code executable?