起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 277|回复: 13

【搞定】Invokemethod调用方法的时候,提示找不到方法! 是版本问题吗?**

[复制链接]
发表于 2007-12-6 20:17:28 | 显示全部楼层 |阅读模式
http://bbs.justep.com/forum.php? ... hlight=invokemethod
帖子中描述平台的使用方法,我做了一个例子,调用的时候提示找不到方法。我的版本是2617
回复

使用道具 举报

发表于 2007-12-7 10:22:35 | 显示全部楼层
贴一下您实现的代码和调用的代码。另外贴一下报错的截图或者错误信息。
回复 支持 反对

使用道具 举报

发表于 2007-12-7 17:00:45 | 显示全部楼层
该方法从26XX版本就可以了,楼主把实现的代码和调用的代码都帖出来,当然错误信息也帖出来看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-7 17:11:36 | 显示全部楼层
{ TBeLogoned }
  TbeLogoned = class(TBusinessRuntimeServerMethod)
    function GetName: string; override;
    function Invoke(var Params: array of object): object; override;
  end;



  { TBelogoned }
function Tbelogoned.GetName: string;
begin
  Result := 'belogoned';
end;

function Tbelogoned.Invoke(var Params: array of object): object;
begin
  if TsystemCore.Operator <> nil then
    Result := 'TRUE'
  else
    Result := 'FALSE';
end;



下面的两个事件中也处理过了
constructor TInit.Create(AContext: TContext);  
destructor TInit.Destroy;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-7 17:17:13 | 显示全部楼层
下面是Business.jsp 文件的内容:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="com.justep.loader.LibContext"%>
<%@ page import="java.lang.reflect.Method" %>
<%
Class pclass = LibContext.getInstance().getLoader().loadClass

("com.justep.web.SysServerProvider");
Object pobj = pclass.newInstance();
Method getBXClassIDMethod = pclass.getMethod("getBXClassID",new Class[]{});
Method getBXCodeMethod = pclass.getMethod("getBXCodebase",new Class[]{});
Method getSysServerURLMethod = pclass.getMethod("getSysServerURL",new Class[]{});

String classId = (String)getBXClassIDMethod.invoke(pobj,new Object[]{});
String codeBase = (String)getBXCodeMethod.invoke(pobj,new Object[]{});
String url = (String)getSysServerURLMethod.invoke(pobj,new Object[]{});
%>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
boolean notNull = false;
if(username != null && password != null){
notNull = true;
}
%>
<HTML>
<HEAD>
<title>>X3协同管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>

<BODY leftmargin="0" topmargin="0" scroll="no">

<OBJECT  id = "X3X"
          classid="<%= classId%>"
          codebase="<%= codeBase%>"
          width="100%"
          height="100%"
          align=center
          hspace=0
          vspace=0
>
</OBJECT>

<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-

00C04FD705A2">
</object>

<script ID="BusinessCloseEventHandler" language="javascript" FOR="X3X" EVENT="OnTerminate">
  WebBrowser.ExecWB(45,1); // close window
</script>
<% if(notNull) { %>
<script type="text/javascript">
  function BeforeClose()
  {
    if(!X3X.TerminateQuery())
    {
      event.returnValue = "";
    }
  }

  document.title = X3X.DisplayName;
  X3X.ServerURL = "<%= url%>"
  //X3X.ShowSplash();
  X3X.UpdateVersion();
  X3X.Init();
  //X3X.CloseSplash();
  X3X.Logon("<%=username%>","<%=password%>");
  X3X.Run("Biz:\\System\\Init.Func", "", "", "");
  alert(X3X.invokemethod("belogoned",""));
  document.body.onbeforeunload=BeforeClose;
  document.title = X3X.DisplayName;
</script>
<% } else { %>
<script type="text/javascript">
  function BeforeClose()
  {
    if(!X3X.TerminateQuery())
    {
      event.returnValue = "";
    }
  }

  document.title = X3X.DisplayName;
  X3X.ServerURL = "<%= url%>"
  X3X.ShowSplash();
  X3X.UpdateVersion();
  X3X.Init();
  X3X.CloseSplash();
  X3X.Run("", "", "", "");
  document.body.onbeforeunload=BeforeClose;
  document.title = X3X.DisplayName;
</script>
<% } %>
</BODY>
</HTML>
回复 支持 反对

使用道具 举报

发表于 2007-12-7 17:40:39 | 显示全部楼层
恩,你把
下面的两个事件中也处理过了
constructor TInit.Create(AContext: TContext);  
destructor TInit.Destroy;
这里面的也帖出来,

还有错误信息也帖出来吧
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-7 18:03:52 | 显示全部楼层
错误信息

error.jpg

29.48 KB, 下载次数: 130

回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-7 18:05:34 | 显示全部楼层
constructor TInit.Create(AContext: TContext);
begin
  if FInitInstance <> nil then
    raise Exception.Create('初始化功能已经创建');
  FInitInstance := Self;
  inherited;

  FRunningClients := TRunningClients.Create;

  FShutdown := TShutdown.Create;
  FShow := TShow.Create;

  FRegisterClient := TRegisgerClient.Create;
  FRegisterClient.FRegister := FRunningClients;
  FUnregisterClient := TUnregisgerClient.Create;
  FUnregisterClient.FRegister := FRunningClients;
  FTouchClient := TTouchClient.Create;
  FTouchClient.FRegister := FRunningClients;

  FGetServerURL := TGetServerURL.Create;
  FGetOperatorID := TGetOperatorID.Create;

  FGetClientAccount := TGetClientAccount.Create;

  FBelogoned:= TBelogoned.Create;

  FRunning := TRunning.Create;

  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FShutdown);
  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FShow);

  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FRegisterClient);
  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FUnregisterClient);
  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FTouchClient);

  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FGetServerURL);
  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FGetOperatorID);

  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FRunning);

  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FGetClientAccount);

  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FBelogoned);

  StartServer;
end;

destructor TInit.Destroy;
begin
  FInitInstance := nil;

  StopServer;
  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FBelogoned);

  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FGetClientAccount);

  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FRunning);

  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FGetOperatorID);
  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FGetServerURL);

  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FRegisterClient);
  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FUnregisterClient);
  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FTouchClient);

  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FShow);
  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FShutdown);

  FBelogoned.Free;
  FGetClientAccount.Free;

  FRunning.Free;

  FGetOperatorID.Free;
  FGetServerURL.Free;

  FRegisterClient.Free;
  FUnregisterClient.Free;
  FTouchClient.Free;

  FShow.Free;
  FShutdown.Free;

  inherited;
end;
回复 支持 反对

使用道具 举报

发表于 2007-12-8 10:29:53 | 显示全部楼层
还有阿,楼主,保存,编译,刷新缓存过没有?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-12-9 13:38:02 | 显示全部楼层
问题已经解决,可以结贴了。解决办法是新实现的方法应当在Init静态方法中注册,而不是在Create方法中注册。希望对于相关的官方贴进行修正。谢谢atiger进行支持!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-2 01:34 , Processed in 0.044385 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表