似乎人们能够在SWF 2.3.1中实现复合组件,但我无法找到明确的参考方法.我已经遵循JSF复合组件的基本结构,但我的SWF应用程序似乎没有识别taglib命名空间.
有一个工具包/ IDE警告,但更重要的是在浏览器中看到运行时警告,JSF在屏幕上向用户显示以下警告:
Warning: This page calls for XML namespace http://java.sun.com/jsf/composite/myjsf declared with prefix mj but no taglibrary exists for that namespace.
Run Code Online (Sandbox Code Playgroud)
组件定义:
src/main/resources/myjsf/testComponent.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="attr" />
</composite:interface>
<composite:implementation>
#{cc.attrs.attr});
</composite:implementation>
</html>
Run Code Online (Sandbox Code Playgroud)
在给定的xhtml中引用:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:mj="http://java.sun.com/jsf/composite/myjsf">
<!-- snip -->
<mj:testComponent attr="x" />
</ui:composition>
Run Code Online (Sandbox Code Playgroud) 在Eclipse JUNO中,我开始:

将jar复制到WEB-INF / lib(jstl-api,jstl-impl,jsf-api,jsf-impl):

WebContent的新HTML:带有“ New Facelet Composition Page”的index.xhtml,以及其中的代码:

在web.xml中,我将index.xhtml写入welcome部分
当我在apache tomcat 7服务器上运行它时,结果(不必理会h1标题):

那么为什么它不显示出文本和按钮呢?我怎么了 我在youtube上看到了很多视频,我一直跟随着他们,在视频有效的过程中,但对我来说却如此。
我有一个h:inputText,h:selectonemenu和commandbuton.Inputtext是必填字段,我将其定义为immediate ="true".然后,当我单击按钮时,我想将selectonemenu的当前值传递给托管bean.但它的passig null.如何管理此验证,以便我可以在托管bean中获取selectOneMenu的值.
我的代码是......
<h:inputText id="inputSome" required="true" requiredMessage="Pls enter something"/>
<h:message for="inputSome"></h:message>
<h:selectOneMenu id="recepients" value="#{controller.selected}" immediate="true">
<f:selectItem itemLabel="Select" itemValue=""/>
<f:selectItems value="#{controller.tempNameList1}"></f:selectItems>
</h:selectOneMenu>
<p:commandButton value="Add" action="#{controller.submit}"
immediate="true"/>
Run Code Online (Sandbox Code Playgroud) 我创建了JSF登录页面,用于客户端身份验证.我创建了过滤器,当用户打开页面时会破坏用户会话logout.html.我想创建一个简单的http链接,当它被点击以将用户重定向到logout.html页面时将使用它.您可以为页面重定向推荐什么JSF标记?
如何将JavaScript onclick事件绑定到JSF-tag?这是我的JSF标签:
<h:commandLink value="Edit" action="#{adminBean.edit}">
<f:param value="#{user.login}" name="login"/>
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
我已经设法在JSP标记JavaScript函数上绑定click-event:
<script type="text/javascript">
function deleteUser(link)
{
if (confirm("Are you sure?")) {
window.location = link;
}
else {
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
这是JSP-tag中的链接示例.
out.println("<a href=\"#\" onclick=\"deleteUser('deleteUser.htm?userLogin="+user.getLogin()+"');\">Delete</a>");
Run Code Online (Sandbox Code Playgroud)
如何将相同的on-click函数绑定到上面给出的JSF-tag?
我有一个要求,用户应该能够从日历中选择日期.我使用过<p:calendar>PrimeFaces.
<p:calendar value="#{calendarBean.date1}" pattern="MM/dd/yyyy HH:mm" />
Run Code Online (Sandbox Code Playgroud)
问题是用户不应该选择分钟.他应该只能选择几个小时.
我有以下代码:
<h:form>
<h:inputText id="inputField" value="#{bean.myProperty}">
<f:validateLongRange
minimum="#{bean.minimum}"
maximum="#{bean.maximum}"/>
</h:inputText>
<h:commandButton id="submit" value="Submit" >
<f:ajax execute="inputField" render="outputField errors" />
</h:commandButton>
<h:outputText id="outputField" value="#{bean.myPropertyFormatted}"/>
<h:message id="errors" for="inputField"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
当对inputText的验证失败时,我想从用户删除/隐藏outputText。做到这一点的最优雅,最面向未来的方法是什么?
我尝试rendered="#{!facesContext.validationFailed}"在outputText元素上设置属性,但这仅决定了outputText元素是否被重新渲染,而不是使旧文本保持不变。但是,当validateLongRange验证失败时,我想从用户完全删除/隐藏outputText,因为用户将选择验证错误消息,并且不希望基于先前的有效输入选择旧的输出消息,即仍然将值存储在Bean中。
my sessionfacade class
package com.entity;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless
public class UsersFacade extends AbstractFacade<Users> implements UsersFacadeLocal
{
@PersistenceContext(unitName = "My_communityPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
public UsersFacade() {
super(Users.class);
}
}
my managed bean class
package com.jsf;
import com.entity.Users;
import com.entity.UsersFacadeLocal;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@Named(value = "loginMB")
@ManagedBean
@SessionScoped
public class LoginMB implements Serializable {
@EJB …Run Code Online (Sandbox Code Playgroud) 我怎样才能将一个arugument传递给听众方法?
我试过这样的:
<p:poll interval="3" listener="#{vehicleController.onPoll('12')}"
update="vehicleDataList"/>
Run Code Online (Sandbox Code Playgroud)
和
<p:poll interval="3" listener="#{vehicleController.onPoll(vehicle.vehicleLicense)}"
update="vehicleDataList"/>
Run Code Online (Sandbox Code Playgroud)
但它抛出以下异常:
javax.servlet.ServletException: /monitorVehicles/vehiclesList.xhtml
Failed to parse the expression [#{vehicleController.onPoll('12')}]
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这个?
我有一个在tomcat 7.0.29中运行的JSF 2.0 Web应用程序,并尝试使用Servlet 3.0注释,但servlet不起作用,因为我看不到用init()方法编写的日志.
我已经为同样的问题读了很多答案,但仍然没有成功.
我的文件看起来如何:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app metadata-complete="false"
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_3_0.xsd"
version="3.0">
<display-name>GestionCongesFeki</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<!-- <servlet> -->
<!-- <servlet-name>AjaxRelaisServlet</servlet-name> -->
<!-- <servlet-class>utils.AjaxRelaisServlet</servlet-class> -->
<!-- <load-on-startup>2</load-on-startup> -->
<!-- </servlet> -->
<!-- <servlet-mapping> -->
<!-- <servlet-name>AjaxRelaisServlet</servlet-name> -->
<!-- <url-pattern>/AjaxRelaisServlet/*</url-pattern> -->
<!-- </servlet-mapping> -->
</web-app>
Run Code Online (Sandbox Code Playgroud)
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>esprit.pfe2013</groupId>
<artifactId>GestionCongesFeki</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>GestionCongesFeki Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>central</id>
<name>Maven …Run Code Online (Sandbox Code Playgroud) jsf ×10
jsf-2 ×4
primefaces ×3
validation ×2
ajax ×1
arguments ×1
calendar ×1
el ×1
javascript ×1
jpa ×1
listener ×1
maven ×1
servlet-3.0 ×1