简体   繁体   English

SCALA Lift-扩展功能缺少参数类型

[英]SCALA Lift - Missing parameter type for expanded function

I have the following form: 我有以下表格:

<form class="lift:form.ajax">

    <div class="lift:StreamInput">
        <input type="hidden" name="user" value="USER" />
        <input type="hidden" name="room" value="ROOM" />
        <input type="hidden" name="path" value="PATH" />
        <input type="hidden" name="level" value="LEVEL" />
    </div>

    <input type="submit" value="" />

</form>

Which goes into: 涉及到:

object StreamInput {

    case class StreamItem(

        user: String, 
        path: String, 
        level: String, 
        room: String

    )

    def render = {

        var user = ""
        var path = ""
        var level = ""
        var room = ""

        def process(): JsCmd = {

            var message = StreamItem(user, path, level, room)
            StreamServer ! message

        }

        "name=user" #> SHtml.onSubmit(user => user = _)
        "name=path" #> SHtml.onSubmit(path => path = _)
        "name=level" #> SHtml.onSubmit(level => level = _)
        "name=room" #> (SHtml.onSubmit(room => room = _) ++ SHtml.hidden(process))

    }

}

When compiling I'm getting the following errors: 编译时出现以下错误:

"Missing parameter type for expanded function ((x$1) => user = x$1)"
"name=user" #> SHtml.onSubmit(user => user = _)
                                             ^
"Missing parameter type for expanded function ((x$2) => user = x$2)"
"name=path" #> SHtml.onSubmit(path => path = _)
                                             ^
"Missing parameter type for expanded function ((x$3) => user = x$3)"
"name=level" #> SHtml.onSubmit(level => level = _)
                                                ^
"Missing parameter type for expanded function ((x$4) => user = x$4)"
"name=room" #> SHtml.onSubmit(room => room = _)
                                             ^

I've been googling for a while now and can't seem to find an explanation that fits my particular scenario. 我已经搜寻了一段时间,似乎找不到适合我特定情况的解释。

Not sure what I'm missing, any help is much appreciated, thanks in advance :) 不确定我缺少什么,非常感谢您的帮助,在此先感谢:)

SHtml.onSubmit takes a callback (String) ⇒ Any . SHtml.onSubmit接受回调(String) ⇒ Any The String being the newly submitted value of the field. String是字段的新提交的值。 In your case you want to supply a setter method which changes your var s to that new value. 在您的情况下,您想提供一个setter方法,将您的var更改为该新值。 Change the argument to 将参数更改为

SHtml.onSubmit(user = _)

or expanded 或扩展

SHtml.onSubmit(text => user = text)

( Documentation ) 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM