2009-06-19 71 views
3

即時只是開始升降機和斯卡拉,並有一個問題,我不明白。電梯片段:前綴不綁定到命名空間

我有如下因素的index.html

<html> 
<head><title>title</title></head> 
<body> 
    <table> 
     <lift:Members.list> 
      <tr> 
       <td><m:nick/></td> 
      </tr> 
     </lift:Members.list> 
    </table> 
</body> 
</html> 

和下面的代碼片段:

class Members { 
    def list(xhtml: NodeSeq) = 
    Member.findAll.flatMap(member => bind("m",xhtml 
             ,"nick" -> member.nickName 
    )) 
} 

由於某種原因,我得到以下錯誤。我嘗試了很多東西,但無法讓它工作。怎麼了?

XML Parsing Error: prefix not bound to a namespace 
Location: http://localhost:8080/hazardlift-1.0-SNAPSHOT/ 
Line Number 8, Column 25:<td><m:nick></m:nick></td> 
-----------------------------^ 

回答

4

也許lift不知道如何處理您的返回值。嘗試強制隱式轉換爲NodeSeq,方法是將其指定爲returntype。

.... 
def list(xhtml: NodeSeq) : NodeSeq = 
.... 
+0

這工作,非常感謝。 怎麼能發現一個好方法?這個錯誤並不是真的有用...... – 2009-06-20 08:15:11

0

我剛發現這個錯誤的另一個原因 - 一個未解決的標記。

我有這個HTML:

<div > 
    <h3>Request Information</h3> 

    <lift:DetailedRequestData.renderContent> 
     <f:rowTag></f:rowTag> 
    </lift:DetailedRequestData.renderContent> 
</div> 

我這樣寫了renderContent

def renderContent(ns: NodeSeq): NodeSeq = { 
    val key = beginTrans(DisplayData.logger) 
    var result = ns 

    try { 
    var requestID = DisplayData.getParameter("request") 
    bind("f", ns, "rowTag" -> <p>Request ID: {requestID}</p>) 
    } 
    catch { 
    case t: Throwable => DisplayData.logger.error("[DetailedRequestData$.renderContent] ", t) 
    } 

    endTrans(DisplayData.logger, key) 
    result 
} 

因爲我沒有分配bindresult的結果,我返回未修改NodeSeq和得到了相同的prefix not bound to a namespace錯誤。改變一個聲明:

result = bind("f", ns, "rowTag" -> <p>Request ID: {requestID}</p>) 

是的,這是我自己的愚蠢的錯誤,但在這裏記錄的問題,希望我救一個人從有這個同樣的問題,不知道爲什麼別人。