Main Content

Magnolia Community Forums: Get help with Magnolia: Making a remoteField readOnly breaks the fetching of the remoteField value


  • arthuroys
    arthuroys
    Full name: Arthur Oysgelt
    Posts: 3
    Last post: Jul 31, 2017 7:30:50 PM
    Registered on: Jul 19, 2017
    Making a remoteField readOnly breaks the fetching of the remoteField value
    #1 by arthuroys on Jul 19, 2017 4:06:02 PM

    Hi, I'm trying to create a form with the following yaml (partial) definition:

    editor:
    wide: true
    actions:
    - name: commit
    - name: cancel
    form:
    tabs:
    - name: english
    label: Answer
    fields:
    - name: jcr:uuid
    class: info.magnolia.ui.form.field.definition.TextFieldDefinition
    label: Answer ID
    readOnly: true
    - name: questionID
    remoteField: jcr:uuid
    remoteWorkspace: qna
    class: com.sharecare.cms.publishing.commons.ui.taglib.prefilledtext.PrefilledTextFiledDefinition
    label: Question ID
    editable: false
    # readOnly: true (when this is set to true, the field stops auto-populating from workspace)
    - name: questionText
    remoteWorkspace: qna
    remoteField: text
    class: com.sharecare.cms.publishing.commons.ui.taglib.prefilledtext.PrefilledTextFiledDefinition
    label: Question Text
    editable: false
    # readOnly: true (when this is set to true, the field stops auto-populating from workspace)
    - name: text
    class: info.magnolia.ui.form.field.definition.RichTextFieldDefinition
    label: Answer Text


    As I noted in this code, when I add the "readOnly" field, the form's questionID and questionText fields stop auto-populating in the form, but do make the field read-only.
    Is there any way to achieve both a disabled state of the input field and to auto-populate it with the remote workspace's text as I do with the Answer ID?

  • mgeljic
    mgeljic
    Full name: Mikaël Geljić
    Posts: 70
    Last post: Sep 22, 2017 4:11:20 PM
    Re: Making a remoteField readOnly breaks the fetching of the remoteField value
    #2 by mgeljic on Jul 21, 2017 4:43:24 PM

    Hi Arthur,

    The PrefilledTextField you're using, as well as its remoteField config are not part of Magnolia. :)
    The place to look for would be inside the related FieldFactory. Here's a couple pointers I could think of:

    - What method is being overridden there (at first, sounds like #initializeProperty or #setPropertyDataSource would be good candidates)
    - If the remote value is set on the field directly, or on its underlying Vaadin Property data-source

    Cheers,
    Mika

  • arthuroys
    arthuroys
    Full name: Arthur Oysgelt
    Posts: 3
    Last post: Jul 31, 2017 7:30:50 PM
    Registered on: Jul 19, 2017
    Re: Making a remoteField readOnly breaks the fetching of the remoteField value
    #3 by arthuroys on Jul 24, 2017 11:01:53 PM

    Ah, that must be it. Thank you!

  • arthuroys
    arthuroys
    Full name: Arthur Oysgelt
    Posts: 3
    Last post: Jul 31, 2017 7:30:50 PM
    Registered on: Jul 19, 2017
    Re: Making a remoteField readOnly breaks the fetching of the remoteField value
    #4 by arthuroys on Jul 31, 2017 7:30:50 PM

    Found the solution. I created a custom field called "remoteReadOnly" and then in the subclass of the TextFieldFactory that I use for the field I overwrote this method in this way:

    @Override
    public Field createField() {
    Field field = super.createField();
    try {
    field.setReadOnly(((PrefilledTextFiledDefinition) definition).getRemoteReadOnly());
    } catch (Exception e){
    log.warn("Unable make remote field uneditable", e);
    }
    return field;
    }

You don't have the permission to post on this thread

Sign in

To login on this forum, you can use your Magnolia Forge, Support or Partner account, or, below, your Google, Yahoo! or OpenID account. If you have trouble logging in, or any other sort of issue, please let us know in the Meta forum, on the user-list, or simply by email at forum-admin at magnolia-cms dot com.

* Required

... or sign in with:

  • icon http://{your-openid-url}
  • icon
  • icon https://me.yahoo.com/