2011-04-29 142 views
0

這是我nodefinder.java文件爲什麼我收到以下異常

package com.acme.web.action.executer; 

import java.sql.ResultSet; 
import java.util.Map; 

import org.alfresco.web.bean.repository.Node; 
import org.alfresco.web.bean.repository.Repository; 
import org.alfresco.web.ui.common.component.UIActionLink; 

import javax.faces.context.FacesContext; 
import javax.faces.event.ActionEvent; 

import org.alfresco.service.cmr.model.FileFolderService; 
import org.alfresco.service.cmr.repository.NodeRef; 
import org.alfresco.service.cmr.repository.NodeService; 
import org.alfresco.service.cmr.repository.StoreRef; 
import org.alfresco.service.cmr.search.SearchParameters; 
import org.alfresco.service.cmr.search.SearchService; 

public class NodeFinder { 

    // private static final String = null; 
    SearchParameters sp = new SearchParameters(); 
    private NodeService nodeService; 
    private FileFolderService fileFolderService; 
    //geting the filefolder service      
    public FileFolderService getFileFolderService() { 
     return fileFolderService; 
    } 
    // setting the file folder service 
    public void setFileFolderService(FileFolderService fileFolderService) { 
     this.fileFolderService = fileFolderService; 
    } 
// getting the node servise 
    public NodeService getNodeService() { 
     return nodeService; 
    } 
    // setting the node server 

    public void setNodeService(NodeService nodeService) { 
     this.nodeService = nodeService; 
    } 

    public void execute(ActionEvent event) { 
     ResultSet resultSet_s = null; 
     UIActionLink comp = (UIActionLink) event.getComponent(); 
     Map<String, String> params = comp.getParameterMap(); 
     String id = params.get("id1"); 
     System.out.println("1"); 

     NodeRef actionedUponNodeRef = new NodeRef(Repository.getStoreRef(), id); 
     String qry_s = "@cm\\:name:train"; 
     System.out.println("2"); 

     SearchParameters sp_s = new SearchParameters(); 
     System.out.println("3"); 

     sp_s.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); 
     sp_s.setLanguage(SearchService.LANGUAGE_LUCENE); 

     sp_s.setQuery(qry_s); 
     System.out.println("4"); 

     Node node = new Node(actionedUponNodeRef); 
     System.out.println("5"); 
     resultSet_s = (ResultSet) Repository.getServiceRegistry(
       FacesContext.getCurrentInstance()).getSearchService().query(
       sp_s); 
     System.out.println("5.1"); 

     if (resultSet_s != null) { 
      System.out.println("6"); 

      System.out.println("Node value is::::" + node.getName()); 

     } 
    } 
} 
+0

請修復您的格式,以及異常在哪裏? – Thomas 2011-04-29 06:52:33

+0

我已經創建了gui組件來獲取節點ref的內容的節點元素。但我得到了以下錯誤javax.faces.el.E​​valuationException:調用表達式時的異常#{NodeFinder.execute} 引起的: java.lang.ClassCastException:org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet can not將其轉換爲java.sql.ResultSet – jetty 2011-04-29 06:58:32

回答

1

看看該行...(ResultSet) Repository.getServiceRegistry(...兼容,再看看在你的例外,最後在你的進口。在那裏您會看到ResultSet實際上是java.sql.ResultSet(由您的ClassCastException消息指示)。

如果你再看看org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet的超類或接口,我會說你不會找到任何java.sql.ResultSet。這就是你得到這個例外的原因。

5

因爲你進口java.sql.ResultSet,而不是露天類/接口org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet

+0

爲了給出建議,我會嘗試一下,然後回來 – jetty 2011-04-29 07:13:52

+0

雅它的工作,但我沒有得到節點的價值 – jetty 2011-04-29 07:15:00

+0

雅謝謝你這就是工作....我得到的節點值 – jetty 2011-04-29 07:32:45

相關問題