我已经测试了Glassfish 3.0.1中的默认安全容器,并得出结论,我将不再花费更多时间.相反,我想自己控制验证.但我需要一些指导才能让我走上正轨.
目前我有一个具有登录/注销功能的UserBean(见下文).我不想使用*j_security_check*内置容器,但使用核心JSF 2.0.
我的问题是;
感谢任何帮助或链接到一个例子,问候克里斯.
PS.请原谅我将两个问题集中在一起
@ManagedBean
@SessionScoped
public class UserBean {
private AuthenticateUser authenticateUser;
...
public String login() {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
JsfUtil.log("Username : " +authenticateUser.getUserName());
JsfUtil.log("Password : " +authenticateUser.getPassword());
AuthenticateUser authRequest = authenticationFacade.find(authenticateUser);
try {
if(!authRequest.equals(authenticateUser))
return "/loginError";
request.login(authenticateUser.getUserName(), authenticateUser.getPassword());
return "";
} catch(ServletException e){
JsfUtil.addErrorMessage(e, "Incorrect username or password, please try again.");
return "/loginError";
}
...
public String logOut() {
String result = "/index?faces-redirect=true";
FacesContext context = FacesContext.getCurrentInstance(); …Run Code Online (Sandbox Code Playgroud) 我有很难理解如何以正确的方式使用rich:popupPanel组件.有(至少不是我能找到的)关于如何使用rich:popupPanel以及如何从中提交值的帖子.
更糟糕的是,面板接缝要添加(当检查html时)一个硬编码的"_content"到它的组件ID名称(生成的div).我试图使用aj4:region标签来部分呈现完整的表单.但是这没有发挥作用,因此没有任何内容发布到托管bean.所以现在我有一个选项,其中面板有自己的形式,在页面上的主要形式之外.
我可以看到形式(弹出)值的评估正在发生,但不会执行持久化值的bean函数(我看到命令按钮的POST请求).我现在能想到的唯一原因是,弹出式面板使用另一个bean来持久保存页面上主要表单的值(两者都是会话作用域).我正在考虑一起省略弹出式面板,因为它很难完成这项工作.也许这是一个众所周知的秘密,因为关于它的帖子很少.如果使用componentController或仅使用a4j:commanLink,它的行为相同.
如何从rich:popupPanel提交值并调用支持bean函数来保持弹出窗体值?
感谢有人可以对此有所了解,问候克里斯.
我在Glassfish 3.1上使用Richfaces 4.0-final
<h:form id="main_form">
<!-- Command for popup -->
<a4j:commandLink actionListener="#{userController.prepareCreateSysRequest}" oncomplete="#{rich:component('popup_sys_user_req_form:popup_sys_user_req')}.show(); return false;"
execute="@this" value="Request New Sector/Category" />
...
<a4j:commandButton action="#{projectController.Create}" ...>
</h:form>
<h:form id="popup_sys_user_req_form">
<rich:popupPanel id="popup_sys_user_req" modal="true" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="New Project Request" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('popup_sys_user_req')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<h:panelGrid columns="2">
<h:outputLabel value="Request New:" />
<h:selectOneMenu id="sys_req_type" value="#{userController.selectedSysRequestType}" required="true" requiredMessage="Request …Run Code Online (Sandbox Code Playgroud) 抱歉有点愚蠢.但我明白(我缺乏知识)如果你想在那个页面上使用RichFaces组件,就不可能转发到另一个页面.
这是我转发到具有RichFaces组件的页面时遇到的一些问题
我不需要转发到具有RichFaces组件的页面,但是拥有该选项会很好.可能我误解了如何使用RichFaces的关键.
仅为了您的信息,我在NetBeans 7.0.1中创建了一个全新的Web项目并制作了两个页面.通过a4j:commandLink我从第一页转发到第二页有一个选项卡面板.渲染变得混乱,面板变得无法使用.除了包含RichFaces所需的库和标签之外,新项目完全没有web.xml和rich-faces.xml中的setup参数.
当我转发到具有RichFaces组件的页面时,我错过了什么?
PS.如果有一个模式可以遵循,这将有助于如何使页面转发与RichFaces一起工作.
问候克里斯.
这是firebug报告的错误(在调用转发之后)
XML or text declaration not at start of entity
http://localhost:8080/humis/faces/app_user/projectHome.xhtml
Line 7
Run Code Online (Sandbox Code Playgroud)
Firebug报告页面的这些状态
它是标题中的内容,包括20-30个脚本.不知道如何在这里包含长html列表.它自己接受的请求没问题,但RichFaces生成了一些我可以控制进行页面转发的东西.
masterLayout文件;
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="css/default.css"/>
<h:outputStylesheet name="css/cssLayout.css"/>
<title>
<h:outputText value="Partner Tapestry - " /> <ui:insert name="title">Browser Title</ui:insert>
</title>
</h:head>
<h:body>
<div id="top" >
<ui:insert name="top">Top Default</ui:insert>
</div>
<div id="messages">
<rich:messages id="messagePanel" ajaxRendered="true"/>
</div>
<div id="content">
<ui:insert name="content">Content Default</ui:insert>
</div> …Run Code Online (Sandbox Code Playgroud) 我尝试关注有关如何ViewExpiredException在 GlassFish 3.1 上处理 Mojarra 2.1.0(使用 RichFaces 4)中的不同帖子。但我定义的内容web.xml似乎没有任何效果。我使用表单基础安全性,用户必须登录才能访问内容。我只希望 Glassfish (catalina) 在会话超时时将用户重定向到一个简单的 JSF 页面,并提供返回登录页面的链接。
我总是收到以下错误消息;
javax.faces.application.ViewExpiredException: viewId:/app_user/activity/List.xhtml - View /app_user/activity/List.xhtml could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:202)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
Run Code Online (Sandbox Code Playgroud)
当用户会话超时并在服务器日志中捕获异常时,我可以向谁重定向用户?
问候,克里斯。
布局.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Had no effect
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
-->
<h:outputStylesheet name="css/default.css"/>
<h:outputStylesheet name="css/cssLayout.css"/>
<title> …Run Code Online (Sandbox Code Playgroud) 美好的一天,我有一个问题让我烦恼了几个小时.这非常直截了当.我在渲染复合组件时尝试调用/执行JavaScript.就像你可以用html标签体和onload做的那样.
如何引用要执行的内联JavaScript?
<cc:implementation>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false" />
<div id="#{cc.clientId}" >
<div id="map_canvas" style="width: 850px; height: 350px; padding: 1px; border: darkblue" />
<script>init();</script>
<script type="text/javascript">
var map = null;
function init() {
var latlng = new google.maps.LatLng(51.5001524, -0.12623619);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
</div>
</cc:implementation>
Run Code Online (Sandbox Code Playgroud)
我尝试过this.init(),#{cc.clientId} .init().但是在上下文中找不到JS.如果我从JSF/ajax组件执行它,只需"init();"即可正常工作.
jsf ×4
glassfish ×2
jsf-2 ×2
facelets ×1
google-maps ×1
jakarta-ee ×1
java-ee ×1
javascript ×1
richfaces ×1
servlets ×1
session ×1
xml ×1