我需要驗證<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