XPages自动登出时如何在$$LoginUserForm中设置ReasonType字段
XPages登录超时后设置登录表单字段的方法
- 可以通过URL参数的方式传递值给$$LoginUserForm的reasontype字段,只需调整重定向URL即可。
- 修改后的代码示例:
注意必须用URL + "?Logout&redirectto=" + encodeURIComponent(Url + "?opendatabase&login&reasontype=3");encodeURIComponent对redirectto的目标URL进行编码,防止URL参数解析混乱。 - 在$$LoginUserForm对应的页面中添加参数读取逻辑:
- 若使用XPage:在页面的
beforePageLoad事件中加入以下代码,读取URL参数并赋值给字段:var reasontype = context.getParameter("reasontype"); if (reasontype === "3") { getComponent("reasontypeField").setValue("3"); } - 若使用传统Notes表单:在表单的WebQueryOpen代理或计算字段中读取URL参数并赋值:
Dim session As New NotesSession Dim doc As NotesDocument Set doc = session.DocumentContext Dim reasontype As String Dim paramPos As Integer paramPos = InStr(doc.Query_String(0), "reasontype=") If paramPos > 0 Then reasontype = Mid(doc.Query_String(0), paramPos + 11) ' 处理可能存在的后续参数 paramPos = InStr(reasontype, "&") If paramPos > 0 Then reasontype = Left(reasontype, paramPos - 1) End If doc.reasontype = reasontype End If
- 若使用XPage:在页面的
- 确认登录表单的字段配置允许接收外部传入的值,避免参数被表单逻辑覆盖。
内容的提问来源于stack exchange,提问作者theBastian
相关产品推荐
相关产品推荐

