在使用使用POJO列表的PrimeFaces组件时,如何编写自定义转换器?我的特殊问题是<p:pickList>
<p:pickList converter="????" value="#{bean.projects}" var="project"
itemLabel="#{project.name}" itemValue="#{project}">
Run Code Online (Sandbox Code Playgroud)
我没有转换器,java.lang.ClassCastException因为JSF使用未转换的java.lang.String提交值设置提交的值.
我在实现两个SelectOneMenu控件时遇到问题,第二个控件中的数据取决于第一个控件的选择.primeFaces展示的这个例子与我想要实现的几乎相同:http://www.primefaces.org/showcase-labs/ui/pprSelect.jsf
除了我必须从数据库中获取数据.
上面的示例在同一个项目中正常工作.我使用的是NetBeans 7.0和GlassFish 3.1以及PrimeFaces 3.0.M2,这是最新一次(2011年6月20日).
附加了JSF页面和托管bean的源代码.
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head><title>Facelet Title</title></h:head>
<h:body>
<p:log />
<center>
<h:form>
<h:outputText value="State: "/>
<p:selectOneMenu id="selectState" value="#{stateCityBean.selectedStateArray}">
<f:selectItem itemLabel="Select Any" itemValue="Empty String"/>
<p:ajax update="selectCity" listener="#{stateCityBean.updateCityMap}"/>
<f:selectItems value="#{stateCityBean.stateMap}" />
</p:selectOneMenu>
<p></p>
<h:outputText value="City: "/>
<p:selectOneMenu id="selectCity" value="#{stateCityBean.selectedCityArray}">
<f:selectItem itemLabel="Select Any" itemValue="Empty String"/>
<f:selectItems value="#{stateCityBean.cityMap}"/>
</p:selectOneMenu>
</h:form>
</center>
</h:body>
Run Code Online (Sandbox Code Playgroud)
StateCityBean.java
package com.xyz.mbeans;
import com.iwizability.priceinfo.dao.*;
import com.iwizability.priceinfo.pojo.*;
import java.util.LinkedHashMap;
import …Run Code Online (Sandbox Code Playgroud) 我<p:ajax>在我的代码中使用PrimeFaces 标记.我们如何排除子组件在更新父组件的ajax调用中更新?
我正在使用PrimeFaces的dataTable.我得到"没有找到记录." 当table没有元素时 我想将此消息更改为"无结果",并将此消息设为i18n类型.
我不想用
<p:dataTable
id="idTable"
...
emptyMessage="#{messages['general.message.EmptyList']}"
>
Run Code Online (Sandbox Code Playgroud)
对于每张桌子.
如何更改p:dataTable默认emptyMessage消息?
JSF 2.0,Mojarra 2.0.1,PrimeFaces 3.4.1
这是一个p:inputText组件,当按下回车键时,它应该调用一个支持bean方法.
<p:inputText id="commentInput" rendered="#{status.haveComment}"
value="#{statusBean.newComment}"
onkeypress="if (event.keyCode == 13) { onchange(); return false; }">
<f:ajax event="change" listener="#{statusBean.test}" />
</p:inputText>
Run Code Online (Sandbox Code Playgroud)
虽然支持bean有以下方法:
public void test(AjaxBehaviorEvent event) {
System.out.println("Pressed enter!");
}
Run Code Online (Sandbox Code Playgroud)
当按下回车键时它是调用方法,但它有更多; 意外行为案例:
--Click input text
----Type some letters
------Click somewhere else in the page
--------CONSOLE: Pressed enter!
Run Code Online (Sandbox Code Playgroud)
我认为ajax event=change以某种方式检测到变化并调用该方法.如何将此p:inputText组件转换为适当的评论接受者组件,如Facebook或其他人?
我正在使用JSF2,GlassFish 3.1,PrimeFaces 2.x.
我在IE9上遇到奇怪的渲染问题.我应该能够通过插入以下内容强制IE9呈现为IE9:
<html>
<head>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />
...
Run Code Online (Sandbox Code Playgroud)
但事实是,它不起作用,因为(我被告知)元标记必须是该部分中的第一个标记.
当我在我的XHTML文件中执行此操作时...
<html ...>
<f:view contentType="text/html" locale="#{loginHandler.currentLocale}">
<h:head>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />
Run Code Online (Sandbox Code Playgroud)
生成的HTML看起来像这样,其中JSF/PrimeFaces在我的新元标记之前插入了一堆"链接"和"脚本"标记.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/orcf-webui/javax.faces.resource/jquery/ui/jquery-ui.css.jsf?ln=primefaces&v=2.2" />
<link type="text/css" rel="stylesheet" href="/orcf-webui/javax.faces.resource/wijmo/wijmo.css.jsf?ln=primefaces&v=2.2" />
<script type="text/javascript" src="/orcf-webui/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=2.2"></script>
<script type="text/javascript" src="/orcf-webui/javax.faces.resource/jquery/ui/jquery-ui.js.jsf?ln=primefaces&v=2.2"></script>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />
Run Code Online (Sandbox Code Playgroud)
有没有办法让我的元标记在正确的位置,以便它可以工作?(或者让IE9问题消失的另一种方法是什么?
我正在尝试创建一个链接,在不同的窗口/选项卡中打开一个新页面,并显示一些来自支持bean的消息但是没有这样做,想知道为什么?
这是我的xhtml文件:
<html:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
<h:form id="form66">
<p:commandLink actionListener="#{testing.getMessage}" action="msg.xhtml" target="_blank">get Msg</p:commandLink>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的Msg.xhtml页面
<HTML xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>testing</title>
</h:head>
<h:body>
<div class="div">
<p:panel>
<f:facet name="header">
testing
</f:facet>
<div class="paddingForPanel">
<h:outputText value="#{testing.msg}" escape="false"/>
</div>
</p:panel>
</div>
</h:body>
</HTML>
Run Code Online (Sandbox Code Playgroud)
这是我的testing.java
public void getMessage() {
this.msg = "haha";
}
private String msg;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
Run Code Online (Sandbox Code Playgroud)
上面的代码无法打开一个新的选项卡/窗口,我尝试像下面这样做,它成功在新选项卡中打开新页面但msg为空,当我调试时,它成功调用了监听器getMessage,我想知道为什么msg.xhtml页面中的msg为空?提前致谢....
<p:commandLink actionListener="#{testing.getMessage}" oncomplete="window.open('msg.xhtml')">broadcast …Run Code Online (Sandbox Code Playgroud) 我无法实现dialog具有属性的(primefaces)框modal=true.它与modal = false一起正常工作,但是当我尝试设置时modal=true,即使对话框覆盖也变为非活动状态.
我怎样才能让它正常工作?
我在JSF页面中遇到了ajax请求的问题.当我点击按钮时,我得到以下异常:
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: CDATA tags may not nest
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:630)
at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:172)
at javax.faces.context.PartialResponseWriter.startError(PartialResponseWriter.java:342)
at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:210)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:200)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
Run Code Online (Sandbox Code Playgroud)
我认为这是String对象的一些问题,因为当我对网站上显示的JPA实体属性进行硬编码时,一切都还可以.但是,当从数据库(PostgreSQL)中检索实体时,它会抛出上述异常.
JSF代码:
<p:column>
<f:facet name="header">
Akcja
</f:facet>
<h:commandButton actionListener="#{mBDocumentMigration.actionEdit(object)}" value="Edytuj" rendered="#{mBDocumentMigration.editingObject == null}" >
<f:ajax render="@form" execute="@form" />
</h:commandButton>
<h:commandButton action="#{mBDocumentMigration.actionZapisz}" value="Zapisz" rendered="#{mBDocumentMigration.editingObject != null}" >
<f:ajax render="@form" execute="@this" />
</h:commandButton>
</p:column>
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置数据表的列宽.我已经看了这个问题的答案如何在PrimeFaces 3.0中的ap:dataTable中设置ap:column的宽度?.
然而,我正在尝试做一些不同的事情.我只希望列与它显示的最宽元素一样宽.我的大部分数据都是文字.
例如,它不应该是这样的
----------------------------- | This is some text | -----------------------------
它看起来应该是这样的
--------------------- | This is some text | ---------------------
如果有多行,则coulmn应该与最宽的元素一样大.
primefaces ×10
jsf ×8
ajax ×3
jsf-2 ×3
datatable ×2
cdata ×1
commandlink ×1
converter ×1
css ×1
facelets ×1
javascript ×1
messages ×1
picklist ×1
width ×1