Question

Custom control editable or read-only

Question:

I'm creating a custom control for input fields and I need to know if the field is read-only or editable. How do I do this with JSP tags or in Java?

Details:

The JSP when tag documentation says to use the following but I get an error when trying to save the rule.

<pega:when test="$THIS:isModifiable" >

The error I get when trying to save is:

content of stream definition—
when tag: :isModifiable is not recognized as a valid method of a ClipboardProperty

Correct Answer
October 21, 2019 - 4:18pm

I went back and retested with the mode-input tag and it is working. I must have done something wrong before. Thanks for the help!

Comments

Keep up to date on this post and subscribe to comments

October 4, 2019 - 12:17pm

I also tried the following but that always returns true (meaninig it evidently thinks it's always in a read-only section according to the documentation).

<pega:when test="!$mode-input">

I also tried the following but it also always returned true.

<pega:when test="$input-enabled">

 

Pega
October 17, 2019 - 4:08pm
Response to HermyR98

I tried a quick example in the UI gallery and made some observations.

I wrote a custom control with the below code...

<pega:choose>
  <pega:when test='$mode-input'>
    <input type="text" value="abc">
  </pega:when>
  <pega:when test='!$mode-input'>
    <input type="text" value="abc" readonly>
  </pega:when>
  <pega:otherwise>
    <input type="text" value="xyz">
  </pega:otherwise>
</pega:choose>

 

When I reference the control on a property that is within a section/container that is EDITABLE at runtime, below is rendered as expected.

<input type="text" value="abc">

When I reference the control on a property that is within a section/container that is READONLY at runtime, below is rendered as expected.

<input type="text" value="abc" readonly>

So it worked as expected for me. Can you share what your container configuration looks like that hosts your property with your custom control?

October 21, 2019 - 4:18pm
Response to Sunny_GCS

I went back and retested with the mode-input tag and it is working. I must have done something wrong before. Thanks for the help!

October 17, 2019 - 4:11pm
Response to HermyR98

Hmm, according to the documention the input enabled test should return true if all of the following are satisfied.
Can you sanity check if all of these criteria have been met?

The $MODE-INPUT keyword is true when all of the following are true:

  • The current stream is an input-enabled stream.
  • The keyword is part of the processing of a <pega:reference > tag that specifies the INPUT option, with or without a stream name value.
  • The current property identified in the <pega:reference > tag is modifiable.

October 21, 2019 - 4:26pm
Response to Rett_Hean_GCS

I must have done something else wrong when I first tested this as it is working now. Thanks.