我有一个表格,我输入一些细节,所有细节都很重要。我使用required = true来确保它不会遗漏基本信息但是当我点击提交按钮时它会跳过验证阶段..
我该怎么办?
<h:panelGrid id="offline" columns="2" cellspacing="5"
cellpadding="4" style="position:relative;top:25px;left:40%;">
<p:outputLabel value="Cheque / Draft No :"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 15px;height:23px;widht:255px;'></p:outputLabel>
<p:outputLabel value="Cheque / Draft Date :"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 15px;height:23px;widht:255px;'></p:outputLabel>
<p:inputText id="number"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 13px;height:20px;widht:320px;'
value="#{Offline_Payment.chequedraftno}" required="true"
requiredMessage="Please Enter The Details">
<p:ajax process="@this" immediate="true"></p:ajax>
</p:inputText>
<p:calendar id="date"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 13px;height:20px;widht:320px;'
pattern="yyyy-MM-dd" disabledWeekends="true" navigator="true"
value="#{Offline_Payment.chequedraftdate}"
title="Please Enter the date in yyyy-MM-dd" required="true"
requiredMessage="Please Enter The Details">
</p:calendar>
<p:outputLabel value="Bank Name :"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 15px;height:23px;widht:255px;'></p:outputLabel>
<p:outputLabel value="Bank Code :"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 15px;height:23px;widht:255px;'></p:outputLabel>
<p:inputText id="banknane"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 13px;height:20px;widht:320px;'
value="#{Offline_Payment.bankname}" required="true"
requiredMessage="Please Enter The Details">
<p:ajax process="@this" immediate="true"></p:ajax>
</p:inputText>
<p:inputText
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 13px;height:20px;widht:320px;'
value="#{Offline_Payment.bankcode}" required="true"
requiredMessage="Please Enter The Required Details">
<p:ajax process="@this" immediate="true"></p:ajax>
</p:inputText>
<p:commandButton value="Cancel"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 14px;'
immediate="true"
action="/User/orderdetail.xhtml?faces-redirect=true"></p:commandButton>
<p:commandButton value="Proceed"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;;
font-size: 14px;'
action="#{Offline_Payment.offline}" update="@this,growl"
immediate="false" validateClient="true" process="@this"></p:commandButton>
</h:panelGrid>
答案 0 :(得分:0)
问题是您使用immediate="true"
属性。
查看以下链接:
答案 1 :(得分:0)
“立即指出该听众之前开火 执行验证或从文档中填充bean,但我在这里看不到actionlisteners! 如果你使用了必需的,并且你的代码完全正常工作,当我把它放在一个但没有显示requiredMessage时,我也没有看到对ajax语句的任何影响,我删除了所有并且没有任何改变,你可以把那个requiredMessage放在一个其他outputText的bean字符串,并使用该ajax动作以编程方式清除它,所以尝试将每个放在一个表单中,:
<h:form>
<p:inputText
value="#{Offline_Payment.bankcode}" required="true"
requiredMessage="Please Enter The Required Details">
<p:ajax process="@this" immediate="true"></p:ajax>
</p:inputText>
</h:form>
祝你好运。