Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JSF f:convertNumber在面板中工作,但在对话框中不工作_Java_Jsf_Primefaces_Java 7_Jsf 2.2 - Fatal编程技术网

Java JSF f:convertNumber在面板中工作,但在对话框中不工作

Java JSF f:convertNumber在面板中工作,但在对话框中不工作,java,jsf,primefaces,java-7,jsf-2.2,Java,Jsf,Primefaces,Java 7,Jsf 2.2,我有两个的几乎相同的代码,每个都包装了一个和一个。My使用最小/最大整数和小数位数以及拒绝字母(a-z)操作正确。但是,My似乎完全忽略了。它接受字母,并允许数字包含过多的小数位数。我已尝试删除对话框中的所有其他字段,并插入一个来括住,但无效。对字母、输入(如2erf和224356)正确触发验证,因此我知道这种输入将不允许进入数据库。有人对在对话中成功使用有什么想法吗?我使用的是(JSF2.2、JDK7、JavaEE6Web和PrimesFaces5.3) 代码如下: 多谢各位 <

我有两个
的几乎相同的代码,每个都包装了一个
和一个
。My
使用最小/最大整数和小数位数以及拒绝字母(a-z)操作正确。但是,My
似乎完全忽略了
。它接受字母,并允许数字包含过多的小数位数。我已尝试删除对话框中的所有其他字段,并插入一个
来括住
,但无效。对字母、输入(如2erf和224356)正确触发验证,因此我知道这种输入将不允许进入数据库。有人对在对话中成功使用
有什么想法吗?我使用的是(JSF2.2、JDK7、JavaEE6Web和PrimesFaces5.3) 代码如下:

多谢各位

    <!-- code here that does a <ui:include/> of the code below -->

**my-training.xhtml**
<p:dialog id="exampleFileDlg" 
    header="This is for JSF"
    widgetVar="appleUploadFileDialog"
    >

    <p:outputPanel id="dlgContent"
        <iframe..../>
        <p:panel: id="reviewInfoPanel">
            <h:panelGrid columns="2">
                <h:outputLabel for="applesInner"  value="# of apples:"/>
                 <h:panelGroup>
                     <p:inputText id="applesInner" 
                                  value="#{fruitman.cart.numApples}"
                                  type="number"
                                  required="true" 
                                  placeholder="Apples between 0.1 and 99.9"
                                  requiredMessage="# Apples is required" 
                                  validatorMessage="Please enter a number between 0.1 and 99.9" 
                                  converterMessage="Apple # is not valid. Please enter a number between 0.1 and 99.9">
                         <f:convertNumber maxIntegerDigits="2"   
                                          minIntegerDigits="1"
                                          minFractionDigits="0"
                                          maxFractionDigits="1"
                                          groupingUsed="true"/>
                         <f:validateDoubleRange minimum="0.1" maximum="99.9"/>
                         <p:ajax event="blur" update="msgApplesInner"/>
                     </p:inputText>                        
                     <p:message id="msgApplesInner" for="applesInner"/>
                </h:panelGroup>        
            <h:panelGrid>
        </p:panel>   
    <p/:outputPanel>
</p:dialog> 


    <p:confirmDialog widgetVar="approveNumberOfApples" 
                     header="Approving Apples" message="Are you sure you want to approve this number of apples?" closable="false">
        <center>
            <h:panelGrid columns="2" styleClass="courseHeader" >
                <p:commandButton 
                    value="Yes" 
                    id="yesApproveApples"
                    actionListener="#{fruitman.cart.approveApples}"
                    onstart="PF('saveDlg').show();" 
                    oncomplete="PF('saveDlg').hide(); 
                                PF('appleUploadFileDialog').hide();"                                               
                    onclick="PF('approveNumberOfApples').hide();"/>

                <p:commandButton value="No"
                                 id="noApproveApples" 
                                 process="@this"                                          
                               onclick="PF('approveNumberOfApples').hide();"/>
            </h:panelGrid>
        </center>
    </p:confirmDialog>


<p:panel id="fruitWorksPanel">
    <h:panelGrid columns="3">
        <h:outputLabel for="applesOutter"  
                       value="# of CEUs:" style="font-weight:bold"/>
        <h:panelGroup>
            <p:inputText id="applesOutter" 
                         value="#{fruitman.cart.customer.numApples}"
                         type="number"
                         required="true" 
                         placeholder="Apples between 0.1 and 99.9"
                         requiredMessage="# Apples is required" 
                         validatorMessage="Please enter a number between 0.1 
                                           and 99.9" 
                         converterMessage="Apple # is not valid. Please enter
                                            a number between 0.1 and 99.9">
                         <f:convertNumber maxIntegerDigits="2"
                                          minIntegerDigits="1"
                                          maxFractionDigits="1"
                                          groupingUsed="true"/>
                         <f:validateDoubleRange minimum="0.1" 
                                                maximum="99.9"/>
            </p:inputText>
            <p:message id="msgApplesOuter" 
                       for="applesOutter"/>
        </h:panelGroup>

        <h:panelGroup layout="inline-block"/>
        <h:panelGroup layout="inline-block">
            <p:commandButton value="Submit" 
                             id="submitCEUBtn"
            </p:commandButton>
        </h:panelGroup>
        <br/>                                      
   </h:panelGrid>
</p:panel>

**my-training.xhtml**

你有很多事情要做。为什么不试着缩小你的样本,直到你能缩小它呢。我觉得在这个对话中发生了这么多事情,你可能真的引起了这个问题。如果您能将其缩小到最简单的可重复示例,我们可以尝试并诊断它。嘿,Melloware,我删除了不必要的样式以及我的命令按钮的过程和更新属性,我确认该按钮没有更改convertNumber的操作。您仍然有一个
iframe
。。不知道是什么把事情搞砸了。对于这种情况,您最好从头开始实现一个新对话框,对
f:convertNumber
的要求最低。如果你让它工作,然后继续添加东西,直到你得到原始组件的状态,看看它在什么时候失败。更新。我的数据类型是BigDecimal,而它本应该是双精度的。实际代码(在3个不同的地方使用)除了对话框中的一个代码外,其他代码都正常工作。将数据类型更改为Double修复了最后一个代码块。