ReadOnly field in Xpage not submitted

后端 未结 2 932
无人共我
无人共我 2020-12-07 05:43

I have a field in my Xpage that I want to be readOnly and submitted to the database upon Save. This field gets a value from a Ajax call

Setting the property ReadOnly

相关标签:
2条回答
  • 2020-12-07 06:01

    I think this is a bug. You are right, the read only field should get saved. In version 8.5.1 when the property of "Show disabled control for readonly" was not present I used to set the field as readonly through JavaScript. Here's the code snippet:

    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[function makeFieldReadOnly() {
        document.getElementById("#{id:inputText2}").readOnly = true;
    }
    window.onload = makeFieldReadOnly;]]></xp:this.value>
    </xp:scriptBlock>
    

    In the above snippet the function makeFieldReadOnly marks the edit box inputText2 as readonly when page is loaded.

    0 讨论(0)
  • 2020-12-07 06:04

    You can add the readonly attribute with the attr-property:

    <xp:inputText id="inputText2" value="#{document1.ReadOnly}">
       <xp:this.attrs>
          <xp:attr name="readonly" value="true" />
       </xp:this.attrs>
    </xp:inputText>
    

    Btw: The behaviour of the disabled and the readonly property is correct, because this is a definition on the server side. You want to edit the component with a value, that is why it must be allowed to accept values. Just disabling it on the client side has technically no effect.

    0 讨论(0)
提交回复
热议问题