我需要验证<p:spinner>
值是否在设定范围之间。确认消息不再显示
<p:spinner id="minutes" min="0" max="1000" value="#{printerSettings.t}" size ="1">
<f:validateLongRange minimum="0" maximum="1000" />
<p:ajax update="NewTime"/>
</p:spinner>
<h:message for="minutes" style="color:red" />
和
<p>Number of copies (Max of 50) :
<p:spinner id ="Copies" min="1" max="50" value="#{printerSettings.p}" size ="1"> <!-- allows the user a choice of up to 50, this is more than enough for any situation, if needed this can be removed or raised -->
<p:ajax update="p"/>
<f:validateLongRange minimum="1" maximum="50" />
</p:spinner>
<div class="whiteSpace"/>
<h:outputText value="Copies that will be printed: #{printerSettings.p}" id="p"/>
<h:message for="Copies" style="color:red" />
</p>
这是以前的工作,但现在没有验证发生,没有错误等等,这是怎么造成的,我该怎么解决呢?
编辑
<div id="site_content">
<div id="content">
<h:body>
<h:form onsubmit="return validateForm()">
<p>
In how many minutes time would you like to have your job sent to the printer ?
<div class="whiteSpace"/>
<p:spinner id="minutes" min="0" max="1000" value="#{printerSettings.t}" size ="1">
<p:ajax update="NewTime"/>
<f:validateLongRange minimum="1" maximum="1000" />
</p:spinner>
<h:message for="minutes" style="color:red" />
<br></br>
<br></br>
The time the print job will be sent to the printer will be :
<!--<p:button actionListener="{otherBean.setTValue(printerSettings.t)}" value="Set Val" /> Currently causing an error -->
<br></br>
<h:outputText value="#{printerSettings.getNewTime()}" id="NewTime"/>
<br></br>
<br></br>
<p:commandButton type="submit" action="#{email.mail(printerSettings.t, printerSettings.p, printerSettings.paperSize, printerSettings.duplex, printerSettings.orienation, printerSettings.printer)}" onclick="Thankyou()" value="Print" />
<p:button outcome="index" value="Homepage" icon="ui-icon-home">
</p:button>
</h:form>
</h:body>
</div>
</div>
<script type="text/javascript">
function Thankyou()
{
alert("Sent to the printing holding queue, you may close this app now or carry on using this app, your work will still print out ");
//location.href = 'index.xhtml';
}
是可以吗?我可以发布,如果需要更多的代码,在我的评论说,验证似乎是工作,它只是现在显示在所有
编辑
<p:commandButton type="submit" update ="minutes2 Copies2" action="#{email.mail(printerSettings.t, printerSettings.p, printerSettings.paperSize, printerSettings.duplex, printerSettings.orienation, printerSettings.printer)}" onclick="Thankyou()" value="Print" />
的可能重复的[如何验证提交的旋转器的值](http://stackoverflow.com/questions/16120189/how-to-validate-an-value-submitted-by-a-spinner )。如果那里提供的答案没有回答你所寻找的答案,那么你首先不应该接受。 – 2013-04-20 21:19:55
您是否希望在更改输入或提交表单时显示消息?目前,当您更改输入时,它们确实不会显示出来,但我不确定是否满足您的要求,因为代码不具备完整的SSCCE风格(您应该提供足够的代码,以便其他人(和您自己!)可以在将所有内容设置为默认值的情况下复制到完全空白的游乐场项目中时准确再现您的问题)。 – BalusC 2013-04-20 21:20:41
谢谢,我希望消息将在用户按下提交后显示,我已经通过测试代码发现了,它确实验证了输入,如果值超过验证的范围,将不会提交,但没有错误消息!将在一秒内发布代码 – user2292674 2013-04-20 21:31:34