调用客制化方法出现如下异常信息
WARNING: The ManagerService is not initialized! This can be caused by:
1) Attempting to invoke a server only method from a remote client
2) Attempting to invoke a method on a service from the constructor or static initializer of another service
相关实现代码:
jsp
.......
[td]//<td>
//<% ContentItem item = GotoObject.getContentItemfromContentHolder(pt);
//if(item!=null){
//%>
//<%=item.getDisplayIdentifier().getLocalizedMessage(Locale.CHINA)%>-<%=item.getFormatName()%>-<%=item.getDescription()%>-<%=item.getBusinessType()%><%}%>
//</td>
if(item!=null){%>
---
[/td]
.......
GotoObject.java
......
public static ContentItem getContentItemfromContentHolder(ContentHolder contentHolder){
if(contentHolder==null){
return null;
}
EPMDocument epm=null;
if(contentHolder instanceof WTPart){
epm = getEPMDocumentByWTPart((WTPart)contentHolder);
System.out.println("epm is ======="+epm);
}else if(contentHolder instanceof EPMDocument){
epm = (EPMDocument)contentHolder;
System.out.println("epm is ======="+epm);
}
try{
if(epm!=null){
epm = (EPMDocument)ContentHelper.service.getContents(epm);
Enumeration enum = ContentHelper.getContentListAll(epm).elements();
while (enum != null && enum.hasMoreElements())
{
ContentItem item = (ContentItem) enum.nextElement();
if(item !=null){
ApplicationData data=(ApplicationData)item;
try{
ContentServerHelper.service.writeContentStream(data, "c:" + File.separator + data.getFileName());
}catch(Exception e){
e.printStackTrace();
}
return data;
}
}
}
}catch(PropertyVetoException e){
e.printStackTrace();
}catch(WTException ex){
ex.printStackTrace();
}
return null;
}
........
因为使用了ContentServerHelper中的函数。
getContentItemfromContentHolder()函数只能在服务端的class中调用。
如果要在jsp中直接调用,需要采用远程方法调用。
如:
RemoteMethodServer.getDefault().invoke("getContentItemfromContentHolder",null,......);