Search code examples
xpages

defaultvalue in inputText overwritten when disabled?


I don't know if this is a feature or a bug: In an inputText control, bound to an item of a notes document, the value is overwritten each time the xpage is reopened and saved by the defaultvalue when the inputText control is flagged as disabled:

                        <xp:inputText
                            value="#{fback.EmployeeIDCreator}" id="EmployeeIDCreator1"
                            defaultValue="#{javascript:sessionScope.meUser.EmployeeID}"
                            style="width:94px" disabled="true" />

I expected the same behaviour as in "normal" (=enabled) items:

  • defaultValue assigned when document/xpage is new and the item is created,

  • field value when xpage is reopened and reedited.

Is this the "wished" behaviour?

thx in advance, Uwe


Solution

  • We'd run into this problem with fields that were marked 'readonly' as well. Set the style on the inputText to "display:none;" and have a separate control that displays the value. That way, your default value is saved in the field, but the user cannot edit it.