如何重定向到 lift 中的新页面
我是 Scala 和 Lift 的新手,我只使用了 2 个月,所以我在某些方面遇到了很多麻烦。我一直在阅读简单的电梯和电梯的权威指南,但我尝试了按下按钮时重定向到另一个页面的方法,但没有成功。
这是我到目前为止的代码:
class BL_LOG001S {
object Log extends Logger
var lang_id = 1//English
var ido = IDO_LOG001
var odo = ODO_LOG001
var usr = new User
var input_usr = DAO_LOGIN_USER_001.create
def init = {
Log.info("INIT 1: LANG_ID: "+lang_id)
lang_id = usr.lang_id
Log.info("INIT 2: LANG_ID: "+ lang_id)
}
def title = {
Log.info("TITLE: INIT END:")
<h2>{odo.body("title").toLabel(lang_id)}</h2>
<span>{usr.login_nm.toString}</span>
}
def login() = {
<table>
{odo.body("organization_nm").toTableElement(lang_id)}
{odo.body("login_nm").toTableElement(lang_id)}
{odo.body("password").toTableElement(lang_id)}
</table>
}
def transaction() = {
<table>
<tr>
<td><LOG001_1:submit><button>Login</button></LOG001_1:submit>
</td>
</tr>
</table>
}
def display(form: NodeSeq) = {
<lift:BL_LOG001.execute form="post" multipart="true">
{login}
{transaction}
</lift:BL_LOG001.execute>
}
def execute(form: NodeSeq) = {
doBind(form)
}
def checkAndLogin(): Unit = {
Log.info("Check: init: organization_nm = "+input_usr.organization_nm)
ido.body("organization_nm").setValue(input_usr.organization_nm)
ido.body("login_nm").setValue(input_usr.login_nm)
ido.body("password").setValue(input_usr.password)
usr.login(ido.body("organization_nm").getValue.toString,
ido.body("login_nm").getValue.toString,
ido.body("password").getValue.toString)
S.redirectTo("/AdminPage/ADM001")
}
def doBind(form: NodeSeq) = {
bind("LOG001_1", form,
"organization_nm" -> input_usr.organization_nm.toForm,
"login_nm" -> input_usr.login_nm.toForm,
"password" -> input_usr.password.toForm,
"submit" -> SHtml.submit("Login", checkAndLogin))
}
}
方法 checkAndLogin 有 S.redirectTo,但它不会重定向到我需要的页面。我需要的是捕获组织和登录名,并将其显示在下一页中。
如果我问了一些愚蠢的事情,我很抱歉。我真的很感激任何帮助。 谢谢
I am a total newbie in Scala and Lift, I've been working with that for 2 months only, so I have a lot of trouble with some stuff. I've been reading simply lift and the definitive guide to lift, but I tried the methods to redirect to another page when pressing a button with no success.
Here's the code I have until now:
class BL_LOG001S {
object Log extends Logger
var lang_id = 1//English
var ido = IDO_LOG001
var odo = ODO_LOG001
var usr = new User
var input_usr = DAO_LOGIN_USER_001.create
def init = {
Log.info("INIT 1: LANG_ID: "+lang_id)
lang_id = usr.lang_id
Log.info("INIT 2: LANG_ID: "+ lang_id)
}
def title = {
Log.info("TITLE: INIT END:")
<h2>{odo.body("title").toLabel(lang_id)}</h2>
<span>{usr.login_nm.toString}</span>
}
def login() = {
<table>
{odo.body("organization_nm").toTableElement(lang_id)}
{odo.body("login_nm").toTableElement(lang_id)}
{odo.body("password").toTableElement(lang_id)}
</table>
}
def transaction() = {
<table>
<tr>
<td><LOG001_1:submit><button>Login</button></LOG001_1:submit>
</td>
</tr>
</table>
}
def display(form: NodeSeq) = {
<lift:BL_LOG001.execute form="post" multipart="true">
{login}
{transaction}
</lift:BL_LOG001.execute>
}
def execute(form: NodeSeq) = {
doBind(form)
}
def checkAndLogin(): Unit = {
Log.info("Check: init: organization_nm = "+input_usr.organization_nm)
ido.body("organization_nm").setValue(input_usr.organization_nm)
ido.body("login_nm").setValue(input_usr.login_nm)
ido.body("password").setValue(input_usr.password)
usr.login(ido.body("organization_nm").getValue.toString,
ido.body("login_nm").getValue.toString,
ido.body("password").getValue.toString)
S.redirectTo("/AdminPage/ADM001")
}
def doBind(form: NodeSeq) = {
bind("LOG001_1", form,
"organization_nm" -> input_usr.organization_nm.toForm,
"login_nm" -> input_usr.login_nm.toForm,
"password" -> input_usr.password.toForm,
"submit" -> SHtml.submit("Login", checkAndLogin))
}
}
The method checkAndLogin has S.redirectTo, but it does not redirect to the page I need. What I need is to capture the organization and login name, and show them in the next page.
I'm sorry if I am asking something stupid. I would really appreciate any help.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过对象JsCmds的方法RedirectTo? [文档这里]
也许对你有帮助。
对于未来 - 对于与 Lift 框架严格相关的问题,我建议在 Lift 论坛 上提问,所有 Lift 专家都在哪里,他们对每个 Lift 开发人员都非常有帮助,特别是对于新手:)
祝你好运
have you tried method RedirectTo of object JsCmds? [doc of this here]
Maybe it helps you.
For future - for problems strictly connected to Lift framework I recommend to ask on Lift forum, where are all Lift experts and they are very helpful for every Lift developer, especially for newbies :)
good luck