<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I dynamically set the readOnly attribute for a field property? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244238#M197368</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to figure out how to dynamically set the readOnly attribute for several fields in a large form. My process and form are rather complicated, so I'm going to simplify it for this post:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My Users:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FormCompleter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FormReviewer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My Process:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Step 1: FormCompleter fills out the fields in the form.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Step 2: FormReviewer reviews the form and then indicates their approval/rejection of the form.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Both steps use the same form. In Step 2, I want to set the readOnly attributes to "true" for the form properties that the FormCompleter filled out in Step 1—i.e., in Step 2, the FormReviewer will not be able to edit any of the values entered by the FormCompleter in Step 1. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe I can use the formRendered JavaScript event to trigger this action. However, I have no idea how to access the readOnly attribute for a form property in JavaScript in order to change the readOnly value. (technically, I have no idea how to access the readOnly attribute at all because the only place I have seen the readOnly attribute is in the form's JSON file that I exported).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please Note: Making a separate form for Step 2 using DisplayText and DisplayValue properties is a non-starter for me because my actual process and form can require up to 5 different users that need access to the form, each with different read/write privileges. I've seen this suggested as a solution to a similar problem on the Activiti.org forum, but I do not want to maintain 5 different versions of what is essentially the same form. I'd much rather just dynamically set the readOnly attributes when a user accesses the form.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Nov 2016 22:36:44 GMT</pubDate>
    <dc:creator>joeblue</dc:creator>
    <dc:date>2016-11-07T22:36:44Z</dc:date>
    <item>
      <title>How do I dynamically set the readOnly attribute for a field property?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244238#M197368</link>
      <description>I am trying to figure out how to dynamically set the readOnly attribute for several fields in a large form. My process and form are rather complicated, so I'm going to simplify it for this post:My Users:FormCompleterFormReviewerMy Process&lt;IMG id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;tep 1: FormCompleter fills out the fields in the form.Step 2</description>
      <pubDate>Mon, 07 Nov 2016 22:36:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244238#M197368</guid>
      <dc:creator>joeblue</dc:creator>
      <dc:date>2016-11-07T22:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I dynamically set the readOnly attribute for a field property?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244239#M197369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you tried over-riding of in-build types and rendering services?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that should resolve your problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For e.g. for text field you may be using "string" as form type. you can build your own type like "custom_string" and your own form rendering service which will handle the logic for edit/ready only mode. Rendering Java class can be a spring bean that have access to user information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.activiti.engine.form.AbstractFormType;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public class TextAreaFormType extends AbstractFormType {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; private static final long serialVersionUID = 1L;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; private static final String TEXT_AREA_TYPE = "textarea";&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; @Override&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; public String getName() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return TEXT_AREA_TYPE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; public String getMimeType() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return "text/plain";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; @Override&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; public Object convertFormValueToModelValue(String propertyValue) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return propertyValue;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; @Override&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; public String convertModelValueToFormValue(Object modelValue) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return (String) modelValue;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.activiti.engine.form.FormProperty;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.activiti.explorer.ui.form.AbstractFormPropertyRenderer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.jpmorgan.bpm.activiti.form.type.TextAreaFormType;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.vaadin.ui.Field;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.vaadin.ui.TextArea;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public class TextAreaFormPropertyRenderer extends AbstractFormPropertyRenderer {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; private static final long serialVersionUID = 1L;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; public TextAreaFormPropertyRenderer() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; super(TextAreaFormType.class);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; public Field getPropertyField(FormProperty formProperty) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; TextArea textArea = new TextArea(getPropertyLabel(formProperty));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; textArea.setRequired(formProperty.isRequired());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; textArea.setEnabled(formProperty.isWritable());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; textArea.setRequiredError(getMessage("form.field.required", new Object[] { getPropertyLabel(formProperty) }));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if (formProperty.getValue() != null) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; textArea.setValue(formProperty.getValue());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; textArea.setHeight("100px");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; textArea.setWidth("608px");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return textArea;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/java&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Nov 2016 02:21:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244239#M197369</guid>
      <dc:creator>anilmann</dc:creator>
      <dc:date>2016-11-24T02:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I dynamically set the readOnly attribute for a field property?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244240#M197370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the tip. I have not tried that, and I had to move on because I'm on a short schedule.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the meantime, I'm just using different forms and using the Display Value fields in the second form. It's no fun keeping the forms in sync, but it was the best method given my time constraints.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll check out the override idea when I have a chance to refactor at a later time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Dec 2016 15:04:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-dynamically-set-the-readonly-attribute-for-a-field/m-p/244240#M197370</guid>
      <dc:creator>joeblue</dc:creator>
      <dc:date>2016-12-20T15:04:48Z</dc:date>
    </item>
  </channel>
</rss>

