2010-09-29 58 views
0

我試圖在URL上傳遞參數,但我得到了託管bean「無法實例化類:」錯誤。 代碼是在這裏:無法創建Managedbean錯誤雖然在URL上傳遞參數

創建網址:

<h:outputLink id="link" 
    value="#{facesContext.externalContext.requestContextPath}/Public/Home/altKanallar.jsf?id=#{item.id}&name=#{item.name}"> 
    <h:outputText value="#{item.name}" /> 
    </h:outputLink> 

altKanallar.jsf

<h:form> 
     <div style="text-align: center;"> 

     <div style="text-align: left;"> 
     <h:panelGrid style="font-size: 12px; text-decoration:none; " width="100%"> 
      <h:dataTable value="#{altKanallarBean.categories}" var="item" style=" width : 100%;"> 
       <h:column> 
        <h:outputLink id="link" 
         value="#{facesContext.externalContext.requestContextPath}/Public/Home/default.jsf"> 
         <h:outputText value="#{item.name}" /> 
        </h:outputLink> 

        <div style="style=clear:both; font-size:1px; height:2px; line-height:1px;"> 
        </div> 
        <div style="border-bottom:1px solid #D3E8FF; font-size:1px; height:1px; line-height:1px;"> 
        </div> 
        <div style="style=clear:both; font-size:1px; height:2px; line-height:1px;"> 
        </div> 
       </h:column> 

      </h:dataTable> 
     </h:panelGrid> 
     </div> 
    </h:form> 

AltKanallarBean.java

public class AltKanallarBean { 


    private List<com.uzmantv.data.category.Item> categories; 

    public AltKanallarBean(){ 
     HttpServletRequest request=(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); 
     System.out.println(request.getParameter("name")); 
     System.out.println(request.getParameter("id")); 
     categories = RestServices.getCategoriesById(Long.parseLong(request.getParameter("id"))).getItems(); 
     name = request.getParameter("name"); 
    } 



    public List<com.uzmantv.data.category.Item> getCategories() { 
     return categories; 
    } 



    public void setCategories(List<com.uzmantv.data.category.Item> categories) { 
     this.categories = categories; 
    } 
} 
+1

需要完整的堆棧跟蹤 – 2010-09-29 12:25:12

回答

0

確保構造AltKanallarBean()不會拋出例外。 通常這不建議在構造函數中調用業務邏輯。

+0

構造函數甚至沒有調用。我也嘗試在getter中處理邏輯。仍然是同樣的問題 – Cagri 2010-09-29 12:46:30

+0

你可以附加faces-config文件和至少一部分日誌文件嗎? – 2010-09-29 12:59:28

0

感謝您的支持。問題解決了。

Jboss沒有部署AltKanallarBean類。花了幾個小時才決定關閉並重新打開Eclipse並清理jboss。