我有两个系统,我正在尝试整合.一个是基于原始servlet构建的,新的一个是使用IceFaces构建在JSF上的.我正在尝试促进跨系统登录.我的想法是,我在旧系统中有一个按钮,它将适当的信息发布到新站点并将其记录下来.
好吧,理想情况下,我只想使用一个普通的旧servlet在新网站上使用它.转到新站点的Servlet,执行它需要做的事情并转发到仪表板上.
我们的安全性通过托管bean处理.但是,当你到达Servlet时,没有面部上下文.那么,我将如何创建一个新的面部上下文?
我有一个备份计划,我可以随时链接到一个虚拟的.iface页面,它将为我创建FacesContext,然后创建一个支持bean,当它获得实例化然后转发到主页面时将执行操作.但这感觉非常像黑客.
任何帮助,将不胜感激!
编辑:我采取了备份的方式.基本上,我发布到这样的页面:
<f:view>
<ice:outputText value="#{EntryPoint}"/>
</f:view
Run Code Online (Sandbox Code Playgroud)
支持豆看起来像......
public EntryPoint() {
try {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
String loginID = request.getParameter("loginID");
//Do some code to load the user/permissions
response.sendRedirect(
//The appropriate page
);
} catch (IOException ex) {
logger.error(null, ex);
} catch (SQLException ex) {
logger.error(null, ex);
}
}
Run Code Online (Sandbox Code Playgroud)
这仍然感觉像是一个黑客,但我不知道如何解决这个问题.理想情况下,我将POST发送到servlet,获取loginID,构建用户并将其直接放入托管bean.但是,FacesContext在那时并不存在.
还有其他想法吗?
您是否可以分离IceFaces应用程序的组件,以便可以单独测试它们,而不是在组装的应用程序上使用Selenium或HttpUnit之类的东西?
支持bean可以很容易地隔离(如果编写为可测试的),但我有兴趣测试应用程序的模板/显示部分,同时尽可能少地使用应用程序的其余部分.可以这样做吗?怎么样?
有没有办法使用"虚拟数据"将IceFaces对象渲染为文本,然后我可以通过传统的单元测试运行?
我可以想办法做所有这些,但它们涉及创建多个应用程序(我希望测试的每个组件一个).然而,这似乎是一种次优的做事方式.
我已经看过ICEfaces与RichFaces的一些非常简短的比较,但有没有人写过这两个框架的详细比较?我对每个框架的实现细节的详细比较特别感兴趣,但我看到的只是那些仅使用其中一个框架的人的简短意见.
我正在尝试使用JSF 2.0(过去几个月使用ICEfaces 1.8之后),我试图找出为什么在JSF 2.0中我的支持bean构造函数被多次调用.
bean应该在创建时实例化一次,但每当我单击commandButton时,就会显示"Bean Initialized"文本,指示一个新的Bean对象被实例化.
facelet页面:
<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:body>
<div id="content">
<h:form id="form">
<h:commandButton value="Toggle" action="#{bean.toggleShowMe}"/>
</h:form>
<h:panelGrid rendered="#{bean.showMe}">
<h:outputText value="Show me!"/>
</h:panelGrid>
</div>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
支持bean:
@ManagedBean
@RequestScoped
public class Bean {
private boolean showMe = false;
public boolean isShowMe() {
return showMe;
}
public void setShowMe(boolean showMe) {
this.showMe = showMe;
}
public void toggleShowMe(){
System.out.println(showMe);
if(showMe==true){
showMe=false;
}else{
showMe=true;
}
}
/** Creates a new instance of Bean */
public Bean() …Run Code Online (Sandbox Code Playgroud) 我有一个JSF页面。我的CommandButton动作方法值取决于bean变量值。示例:Bean headerBean具有可变的actionValue,其值为“ someBean.doAction1()”
当我使用时,它说headerBean.actionValue不是正确的方法。
如何获得作为“ someBean.doAction1”而不是headerBean.actionValue的操作值。
谢谢,
我正在使用一个名为Woodstock的旧组件库.每当我尝试改变某些东西时,我都会陷入困境,而找不到有关此库的充分文档.我正在考虑迁移到另一个库,如ICE Faces或Prime Faces.但我怀疑迁移到另一个图书馆将在3 - 4年内得到相同的结果,没有文件,不再支持.我是否应该使用JSF标准库而不再使用组件库,或者是否有一个持续超过3年的库
嗨,我想一起使用以下技术:
我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>appName</display-name>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/spring/applicationContext.xml
</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>/</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app> …Run Code Online (Sandbox Code Playgroud) 当我尝试渲染视图时,浏览器显示此错误
01:46:11,371 GRAVE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) Error Rendering View[/index.xhtml]: javax.el.PropertyNotFoundException: /index.xhtml @15,74 value="#{actividades.getAll}": The class 'org.pfc.controller.principal.ActividadesController' does not have the property 'getAll'.
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
Run Code Online (Sandbox Code Playgroud)
ActvidadController代码
@ManagedBean(name="actividades")
@ViewScoped public class ActividadesController implements Serializable {
private static final long serialVersionUID = 1L;
private final static Log logger=LogFactory.getLog(ActividadesController.class);
@ManagedProperty(value="#{actividadBO}")
private ActividadBO actividad;
public void setActividad(ActividadBO actividad) {
this.actividad = actividad;
}
public List<Actividad> getAll(){
logger.trace("ActividadesController.getAll");
return actividad.getAll();
}
}
Run Code Online (Sandbox Code Playgroud)
查看代码
<h:body>
<ui:composition template="/WEB-INF/templates/main-template.xhtml">
<ui:define name="content">
<h:dataTable value="#{actividades.getAll}" var="actividad">
<h:column>
<f:facet name="header">
<h:outputText>Título</h:outputText>
</f:facet> …Run Code Online (Sandbox Code Playgroud) 我正在寻找如何根据用户登录启用和禁用icefaces组件?例如:
如果以管理员身份登录我需要启用更多组件并以用户身份登录,请禁用某些组件以及在一个页面中添加其他组件?如何在jsf/icefaces中执行此功能?
这两个在一个页面中启用和禁用.
我提出你的建议.
现在我正在使用以下内容:
我试图用我已经创建的列表填充“ace:dataTable”。
当我尝试在没有 ace:dataTable 的情况下运行“Principal.xhtml”时页面正常加载,但是如果我添加带有我想要填充的值的 ace:dataTable 会显示错误“HTTP 500 – 内部服务器错误”除了“javax.servlet.ServletException: javax/enterprise/context/spi/Contextual javax.faces.webapp.FacesServlet.service(FacesServlet.java:683) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter .java:52)"
这是我在 pom.xml 中使用的依赖项
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这里也是我在 XHTML 中使用的代码
<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:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<h:head>
<title>List Test</title>
</h:head>
<h:body>
<ace:dataTable id="test"
value="#{personaController.listaPersona}"
rows="5"
var="item"
paginator="true" styleClass="textTabla" paginatorPosition="bottom">
<ace:column>
<f:facet name="header">
<h:outputText value="SOLICITUD" styleClass="textTablaCabeza" />
</f:facet>
<h:outputText value="#{item.nombre}" styleClass="textTablaDetalle" …Run Code Online (Sandbox Code Playgroud)