使用 Grails,如何保留不同请求/控制器操作之间的信息
我有一个像这样的控制器:
def save = {
def conferenceUser = new ConferenceUser()
def conf_1 = Conference.get(params.conference.id)
def role_1 = Role.get(params.role.id)
def status_1 = Status.get(params.status.id)
def user_1 = User.get(params.user.id)
conferenceUser.conference = conf_1
conferenceUser.dateParticipated = params.dateParticipated
conferenceUser.accepted = params.accepted
conferenceUser.status = status_1
conferenceUser.role = role_1
conferenceUser.user = user_1
if (!conferenceUser.save(failOnError: true)) {
render (view: 'participatedAdd', model : [conferenceUser: conferenceUser])
return
render(view: 'participatedAdd2', model: [conferenceUser: conferenceUser])
}
}
基本上,这是我的两步注册阶段的保存控制器。我希望能够在保存第一部分后加载第二个视图 (participatedAdd2),但我需要保留下一个控制器操作的 conferenceUser.conference
值。如何在第二个 save2
控制器操作中访问该值?
I have a controller like this:
def save = {
def conferenceUser = new ConferenceUser()
def conf_1 = Conference.get(params.conference.id)
def role_1 = Role.get(params.role.id)
def status_1 = Status.get(params.status.id)
def user_1 = User.get(params.user.id)
conferenceUser.conference = conf_1
conferenceUser.dateParticipated = params.dateParticipated
conferenceUser.accepted = params.accepted
conferenceUser.status = status_1
conferenceUser.role = role_1
conferenceUser.user = user_1
if (!conferenceUser.save(failOnError: true)) {
render (view: 'participatedAdd', model : [conferenceUser: conferenceUser])
return
render(view: 'participatedAdd2', model: [conferenceUser: conferenceUser])
}
}
Basically, this is the save controller of my 2-step registration phase. I want to be able to, after saving the first part, load the second view (participatedAdd2), but I need to keep the conferenceUser.conference
value for the next controller action. How can I access this value in my second save2
controller action?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
participatedAdd2
视图中,将一个表单放入提交给
save2
操作的表单中。然后,您可以在save2
操作中查找ConferenceUser
:In your
participatedAdd2
view, put ain the form that gets submitted to the
save2
action. You can then look up theConferenceUser
in yoursave2
action with: