标签: jsf

在Maven项目中实现JSF Composite Component

似乎人们能够在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)

jsf maven composite-component

0
推荐指数
1
解决办法
950
查看次数

为什么我的jsf标签不起作用?

在Eclipse JUNO中,我开始:

  1. 新的动态Web项目
  2. 名称:JSFTest;配置:JavaServer Faces v2.0项目
  3. JSF功能: 在此处输入图片说明
  4. 将jar复制到WEB-INF / lib(jstl-api,jstl-impl,jsf-api,jsf-impl):

    在此处输入图片说明

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

    在此处输入图片说明

  6. 在web.xml中,我将index.xhtml写入welcome部分

  7. 当我在apache tomcat 7服务器上运行它时,结果(不必理会h1标题):

    在此处输入图片说明

那么为什么它不显示出文本和按钮呢?我怎么了 我在youtube上看到了很多视频,我一直跟随着他们,在视频有效的过程中,但对我来说却如此。

jsf jsf-2

0
推荐指数
1
解决办法
2305
查看次数

如何跳过ajax调用的验证?

我有一个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)

validation ajax jsf selectonemenu primefaces

0
推荐指数
1
解决办法
2362
查看次数

JSF页面中的注销链接

我创建了JSF登录页面,用于客户端身份验证.我创建了过滤器,当用户打开页面时会破坏用户会话logout.html.我想创建一个简单的http链接,当它被点击以将用户重定向到logout.html页面时将使用它.您可以为页面重定向推荐什么JSF标记?

jsf jsf-2

0
推荐指数
1
解决办法
1164
查看次数

JSF标记上的onclick事件

如何将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?

javascript jsf jsf-2

0
推荐指数
1
解决办法
2万
查看次数

允许用户选择包含小时数但没有分钟数的完整日期

我有一个要求,用户应该能够从日历中选择日期.我使用过<p:calendar>PrimeFaces.

<p:calendar value="#{calendarBean.date1}" pattern="MM/dd/yyyy HH:mm" />  
Run Code Online (Sandbox Code Playgroud)

问题是用户不应该选择分钟.他应该只能选择几个小时.

jsf calendar primefaces

0
推荐指数
1
解决办法
3606
查看次数

JSF:validateLongRange失败时如何隐藏outputText

我有以下代码:

<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中。

validation jsf

0
推荐指数
1
解决办法
5753
查看次数

我在托管bean中使用session ejb时得到nullpointer异常

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)

jsf jpa nullpointerexception

0
推荐指数
1
解决办法
1312
查看次数

如何在监听器中传递参数?

我怎样才能将一个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)

我怎么能得到这个?

jsf arguments el listener primefaces

0
推荐指数
1
解决办法
823
查看次数

应用程序启动时不加载Servlet 3.0

我有一个在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 servlet-3.0 jsf-2

0
推荐指数
1
解决办法
4537
查看次数