Tag: jsf 2

推迟加载和parsingPrimeFaces JavaScript文件

在分析使用Google PageSpeed的JSF 2.1 + PrimeFaces 4.0 web应用程序的性能时,build议除其他外推迟parsingJavaScript文件。 在带有<p:layout>的testing页面上,以及带有<p:watermark>和<p:fileUpload> ,如下所示: <p:layout> <p:layoutUnit position="west" size="100">Test</p:layoutUnit> <p:layoutUnit position="center"> <h:form enctype="multipart/form-data"> <p:inputText id="input" /> <p:watermark for="input" value="watermark" /> <p:focus for="input" /> <p:fileUpload/> <p:commandButton value="submit" /> </h:form> </p:layoutUnit> </p:layout> 它列出了以下可能被推迟的JavaScript文件: primefaces.js (219.5KiB) jquery-plugins.js (191.8KiB) jquery.js (95.3KiB) layout.js (76.4KiB) fileupload.js (23.8KiB) watermark.js (4.7KiB) 它链接到这个Google Developers文章,其中介绍了延迟加载以及如何实现它。 您基本上需要在window的onload事件期间dynamic创build所需的<script> 。 在最简单的forms下,旧的和bug的浏览器完全被忽略,看起来像这样: <script> window.addEventListener("load", function() […]

表单组件在其祖先中需要有一个UIForm。 build议:在<h:form>中包含必要的组件

这是我的forms: <form action="j_security_check"> <h:panelGrid columns="2" bgcolor="#eff5fa" cellspacing="5" frame="box" styleClass="center"> <h:outputLabel value="User ID:"/> <h:inputText id="j_username" tabindex="1" /> <h:outputLabel value="Password:"/> <h:inputSecret id="j_password"/> <h:outputLabel value=""/> <h:commandButton id="login" value="Login"/> </h:panelGrid> </form> Glassfish 3.0.1可以正常工作,但是由于Glassfish 3.1 b2在JSF页面中将这个警告显示为一个FacesMessage : 表单组件在其祖先中需要有一个UIForm。 build议:在<h:form>包含必要的组件 如果我将<form action="j_security_check">更改为<h:form> ,它不会修复它,我必须将<h:form>放在<h:panelGrid> 。

PrimeFaces commandButton不会导航或更新

我使用Primefaces使我的应用程序更漂亮一点。 我注意到, p:commandButton和h:commandButton工作方式不一样。 p:commandButton调用这个方法,没有别的东西需要处理。 h:commandButton调用该方法并返回一个导航。 使用p:commandButton时,按下loginbutton后redirect时遇到问题。 如何处理? 我有一个更新参数: <p:commandButton value="Login" action="#{login.login}" type="submit" update="msgs" />

h:link和h:outputLink之间的区别

我已经查看了这两个组件的API,但是我不太清楚为什么要使用其中一个。 http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/pdldocs/facelets/index.html http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/pdldocs/facelets/h/outputLink.html 有人可以举一个例子说明为什么你会select一个吗? 谢谢

在JSF页面上显示当前date

是否有可能在JSF中显示当前date(今天),而不使用支持bean? 我有以下代码片段,但它没有工作。 <div class="leftSide">Today's date #{currentDate}</div> 要么 <f:facet name="header"> <h:outputText value="Today's date" /> </f:facet> <h:outputText value="#currentDate"> <f:convertDateTime pattern="MM/dd/yyyy" type="date" /> </h:outputText>

什么是JSF 2.0中的STATE_SAVING_METHOD参数

我无法理解web.xml中这一行的function <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> 我已经读过,NetBeans默认是客户端 。 我刚刚遇到了一个问题,我的应用程序中有很多bean,并且<param-value>被设置为client,所以我得到 java.io.NotSerializableException 虽然我的bean是可序列化的(即他们实现了Serializable接口)。 我的豆在@ViewScope 。 但是当我把它改成服务器时,事情就会起作用。 为什么? 当我使用客户端和服务器时有什么不同。 任何人都可以借助一个例子来解释我。 谢谢

何时使用f:view和f:subview

我不确定使用<f:view>和<f:subview>什么好处。 我注意到可以编写JSF页面而不使用它们。 使用这些标签有什么好处?

如何debuggingJSF / EL

如何在JSF页面debuggingEL? 我想看variables值,函数调用等等。 最好的解决scheme是一个eclipse插件,但是任何其他的可能性都比猜测“为什么这个expression式不能正确渲染?”更好。

如何用outputText显示换行符?

我需要使用outputText呈现换行符,以便我可以使用rendered属性。 我试过了 <h:outputText value="<br/>" escape="false" /> 但是它产生了exception The value of attribute "value" associated with an element type "null" must not contain the '<' character.

在JSF中通过ID查找组件

我想通过我提供的id从托pipebean中find一些UIComponent 。 我写了下面的代码: private UIComponent getUIComponent(String id) { return FacesContext.getCurrentInstance().getViewRoot().findComponent(id) ; } 我已经定义了一个p:inputTextarea为: <p:inputTextarea id="activityDescription" value="#{adminController.activityDTO.activityDescription}" required="true" maxlength="120" autoResize="true" counter="counter" counterTemplate="{0} characters remaining." cols="80" rows="2" /> 现在,如果调用方法getUIComponent("activityDescription")它返回null ,但如果我把它称为getUIComponent("adminTabView:activityForm:activityDescription")那么我可以得到org.primefaces.component.inputtextarea.InputTextarea实例。 有没有什么办法让组件只有ID即“activityDescription”不是绝对的ID即“adminTabView:activityForm:activityDescription”?