相关疑难解决方法(0)

h:button和h:commandButton之间的区别

在JSF 2中,h:button和之间有什么区别h:commandButton

jsf button jsf-2

69
推荐指数
2
解决办法
11万
查看次数

如何在单击特定按钮时跳过验证?

我在一个字段上有一个带验证器的表单.我有两个h:commandButtons:Ok和Cancel.当我输入错误的数据并单击取消时,我会收到验证消息.当我点击取消时,我必须做什么验证器不运行?

validation jsf button jsf-2

28
推荐指数
1
解决办法
3万
查看次数

PrimeFaces禁用取消按钮验证

在一个表单中,我有一些带有两个commandButton的inputText,一个用于accept,一个用于cancel.如何仅对取消按钮禁用验证?

<h:form id="detailsForm">
  <p:inputText id="editUsername" value="#{userController.editUser.usrUsername}" />
  <p:inputText id="editFirstName" value="#{userController.editUser.usrFirstName}" />
  <p:inputText id="editLastName" value="#{userController.editUser.usrLastName}" />
  <p:commandButton value="Accept" update=":detailsForm" actionListener="#{userController.onDetailsEditAccept}" />
  <p:commandButton value="Cancel" update=":detailsForm" actionListener="#{userController.onDetailsEditCancel}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

我已经尝试required="false"在字段上插入但它没有用.我也尝试<f:validateBean disabled="true" />在字段上插入但它没有用.

validation primefaces jsf-2

22
推荐指数
2
解决办法
3万
查看次数

为什么p:resetInput要求在提交表单后首先将托管bean的属性设置为null?

在视图范围内的托管bean中,我<p:resetInput>用来清除相应的manged bean中属性所持有的值,比如

<p:commandButton value="Reset" update="panel" process="@this">
    <p:resetInput target="panel" />
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)

这很好用.


我有一个提交按钮<p:commandButton>,按下该按钮会导致提交的值插入到数据库中,如果验证成功.

<p:remoteCommand name="updateTable" update="dataTable"/>

<p:panel id="panel" header="New">
    <p:outputLabel for="property1" value="property1"/>

    <p:inputText id="property1" value="#{bean.property1}" required="true">
        <f:validateLength minimum="2" maximum="100"/>
    </p:inputText>

    <p:message for="property1" showSummary="false"/>

    <p:commandButton id="btnSubmit"
                     update="panel messages"
                     oncomplete="if(!args.validationFailed) {updateTable();}"
                     actionListener="#{bean.insert}"
                     value="Save"/>

    <p:commandButton value="Reset" update="panel" process="@this">
        <p:resetInput target="panel" />
    </p:commandButton>
</p:panel>
Run Code Online (Sandbox Code Playgroud)

命令按钮调用insert()托管bean中的方法,该方法定义如下.

public void insert() {
    if (service.insert(property1)) {
        //...Popup a success message.
        reset(); //Invoke the following private method.
    } else {
        //...Show the cause of …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces jsf-2

3
推荐指数
1
解决办法
5612
查看次数

标签 统计

jsf-2 ×4

jsf ×3

button ×2

primefaces ×2

validation ×2