vij*_*mar 1 jsf primefaces jsf-2
我有一个豆子如图所示
@ManagedBean
@RequestScoped
public class Demo {
private int value1;
private String value2;
..getter and setter..
Run Code Online (Sandbox Code Playgroud)
这是我的xhtml页面demo.xhtml
<h:form>
<p:panelGrid columns="2">
<p:outputLabel value="id"></p:outputLabel>
<p:inputText value="#{demo.value1}"></p:inputText>
<p:outputLabel value="name"></p:outputLabel>
<p:inputText value="#{demo.value2}"></p:inputText>
</p:panelGrid>
</h:form>
Run Code Online (Sandbox Code Playgroud)
如何在客户端页面中获取0值的整数值
我已经读过请求处理生命周期,对于第一次请求,jsf运行时将创建新视图并直接进入渲染阶段.如何在没有进程验证阶段将值设置为客户端页面.
我从jsf 2.0完整参考阅读这些行
*Initial request to view the register.xhtml page
Since this
is an initial request (also referred to as a “non-postback” request) to view the
registration page, the Restore View phase creates an empty View (UIViewRoot)
component tree and stores it in the FacesContext instance.
Run Code Online (Sandbox Code Playgroud)
创建视图后,生命周期会立即直接进入渲染响应阶段,因为请求中没有传入的字段数据需要验证或处理(也称为"非回发"请求).*
我认为这句话有助于理解我的问题.期待在生命周期的角度来回答
你的第一个问题是int
不能为空,它是一个原始问题.请改用Integer.
您的遗嘱会遇到与此处的几个帖子相关的问题COERCE_TO_ZERO
.
要防止此行为,您可以将web.xml中的上下文参数javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL配置为true
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
此外,您可能需要将VM参数添加到tomcat的启动脚本中.
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
关于这个主题,网上有几篇很好的文章
归档时间: |
|
查看次数: |
4835 次 |
最近记录: |