lift snippet: prefix not bound to a namespace
Question
im just starting with lift and scala and have a problem i dont realy understand.
i have the folowing 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>
And the following snippet:
class Members {
def list(xhtml: NodeSeq) =
Member.findAll.flatMap(member => bind("m",xhtml
,"nick" -> member.nickName
))
}
for some reason i get the following error. ive tried alot of things but cant get it to work. whats wrong?
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>
-----------------------------^
Solution
Maybe lift doesn't get how to handle your return value. Try forcing an implicit conversion to NodeSeq by specifing it as returntype.
....
def list(xhtml: NodeSeq) : NodeSeq =
....
OTHER TIPS
I just found another cause of this error - an unresolved tag.
I had this HTML:
<div >
<h3>Request Information</h3>
<lift:DetailedRequestData.renderContent>
<f:rowTag></f:rowTag>
</lift:DetailedRequestData.renderContent>
</div>
I had written this for 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
}
Since I had not assigned the result of the bind
to result
, I was returning the unmodified NodeSeq
and got the same prefix not bound to a namespace
error. Changing the one statement to:
result = bind("f", ns, "rowTag" -> <p>Request ID: {requestID}</p>)
Yes, this was my own stupid fault, but by documenting the problem here, hopefully I will save someone else from having this same problem and not knowing why.