0

I am facing this problem where when I leave everything blank for inputText, click on the Save button, one of the inputText field will be auto set with 0.000000. I have been looking at this for sometime but I still couldn't figure out what is wrong with it. By right, it should remain blank.

<tr>
<td><p:commandButton type="button"
     value="#{msg.cr1002_command_save}" onclick="confirmation.show()"
     id="cr1002_command_save" styleClass="commandButton">
  </p:commandButton> <p:confirmDialog id="confirmDialog"
     message="#{msg.cr1002_prompt_confirm_save}" severity="alert"
     widgetVar="confirmation">
     <p:commandButton id="confirm" value="OK"
    oncomplete="confirmation.hide()"
    action="#{pc_Cr1002.doCr1002_command_saveAction}" ajax="false"
    styleClass="commandButton" />
     <p:commandButton id="decline" value="Cancel"
    onclick="confirmation.hide()" type="button"
    styleClass="commandButton" />
  </p:confirmDialog>
</td>
</tr>

<tr>
   <td><h:outputText styleClass="outputText"
     id="cr1002_output_sample_value"
     value="#{msg.cr1002_output_sample_value}"></h:outputText>
   </td>
   <td></td>
   <td><p:inputText styleClass="inputTextRefresh"
     id="cr1002_input_sample_value" onchange="this.form.submit()"
     valueChangeListener="#{pc_Cr1002.handleCr1002_input_sample_valueValueChange}"
     style="text-align: right"
     value="#{pc_Cr1002.w_currency.sample_value}">
     <f:convertNumber pattern="##0.000000" />
  </p:inputText>
   </td>
   <td></td>
   <td><p:message styleClass="message_200px"
     id="cr1002_error_sample_value" for="cr1002_input_sample_value"
     display="text"></p:message>
   </td>
   <td></td>
</tr>
4

1 回答 1

1
#{pc_Cr1002.w_currency.sample_value}

我想您的字段sample_value是原始的(可能是浮点数)而不是包装类(浮点数)

实例级别的原语的默认值为0or0.0而包装类的默认值为null. 因此,如果这些假设是正确的,并且更改数据类型不会对您造成伤害,那么这可能会解决您的问题。

于 2013-06-12T06:57:11.240 回答