Skip to main content

Unterschied FormData und RemoteFormData / Differences between FormData and RemoteFormData

Comments

9 comments

  • Zendesk API User
    Author: StefanSchulz - 8/29/2013 13:51

    Hi Benjamin,

    The RemoteFormData is not meant for accessing or manipulating an element's data directly, but provides live access to the element's form. Using the OpenElementMetaFormOperation, the given element's metadata form will be shown in the client's editorial area. If it was open, it will be brought to front. If setOpenEditable(true) is used, the form will be opened for editing (if possible). The returned RemoteFormData then allows you to read from the form or write to the form (if possible), so one can manipulate the form's fields as seen on screen. It does not, however, provide means to store the data to the original element.

    If you are looking for non-interactive form data manipulation, use the element's API to read its form data object and fields.

    Cheers,

    Stefan

    0
  • Zendesk API User
    Author: benjamin_nagel - 9/2/2013 11:04

    Hello Stefan,

    ok I thought something like this. But after I opened a MetaData form with setOpenEditable(true) I can't access the manipulated values.

    Currently I use the following code:

    OpenElementMetaFormOperation metaFormOperation = operationAgent.getOperation(OpenElementMetaFormOperation.TYPE);

    metaFormOperation.setOpenEditable(true);

    remoteFormData = metaFormOperation.perform(pageRef);

    permissions = remoteFormData.get(null, "meta_perms").get();

    context.logInfo("permissions: " + permissions.getAllowed("Read"));

    The result in the logger is everytime null. It doesn't matter if I execute this code in the JavaClient or WebClient. Is there something wrong in my code?

    My usecase is only to show a form with the current meta-values and to allow the editor to manipulate this meta values.

    Currently I use FS 5.0.318.

    0
  • Zendesk API User
    Author: StefanSchulz - 9/2/2013 11:46

    So it seems that permissions is not null, which is the value provided via the form field.

    What does logging permissions.get() result to?

    0
  • Zendesk API User
    Author: benjamin_nagel - 9/2/2013 12:47

    Ok I added also a normal CMS_INPUT_TEXT Komponent and changed the code a bit to have more debugging information:

            OpenElementMetaFormOperation metaFormOperation = operationAgent.getOperation(OpenElementMetaFormOperation.TYPE);

            metaFormOperation.setOpenEditable(true);

            remoteFormData = metaFormOperation.perform(pageRef);

            FormData metaFormData = pageRef.getMetaFormData();

            remotePermissions = remoteFormData.get(null, "meta_perms").get();

            permission = metaFormData.get(null, "meta_perms").get();

            StringBuilder sb = new StringBuilder(100);

            sb.append("Remote-Permissions (Read)" + remotePermissions.getAllowed("Read") + "\n");

            sb.append("Remote-Permissions (just get)" + remotePermissions.get() + "\n");

            sb.append("Remote-md_taxonomy: " + remoteFormData.get(null, "meta_taxonomy").get() + "\n");

            sb.append("Permissions (Read): " + permission.getAllowed("Read")+ " \n");

            sb.append("Permissions (just get): " + permission.get()+ " \n");

            sb.append("md_taxonomy: " + metaFormData.get(null, "meta_taxonomy").get() + "\n");

            RequestOperation requestOperation = operationAgent.getOperation(RequestOperation.TYPE);

            requestOperation.addOk();

            requestOperation.perform(sb.toString());

    the result is:

    Remote-Permissions (Read)[] 
    Remote-Permissions (just get)[PERMISSIONS: null] 
    Remote-md_taxonomy: null 

    Permissions (Read): [] 
    Permissions (just get): [PERMISSIONS: null] 
    md_taxonomy: null

    Sadly I can't see any probelms in the code. Do you have any kind of tipps for me?

    Kind regards

    Benjamin

    0
  • Zendesk API User
    Author: StefanSchulz - 9/2/2013 13:39

    Well, seems the object returned by permissions.get() does not provide a useful toString() ... It's actually some DOM-Element implementation, but the toString() only gives the top element information.

    What is metaFormData in the code above? Is it the result of getMetaFormData() on the element directly? The content looks the same to me for both cases. What exactly would you expect the content to be?

    Cheers, Stefan

    0
  • Zendesk API User
    Author: benjamin_nagel - 9/2/2013 14:34

    I added the missing piece of code for the metaFormData. It is just the metaFormData object of the pageRef object.

    When I open metaFormOperation.perform everything is fine. I fill in some values at meta_perms and meta_taxonomy and I close the new popup window. After this I expect to get the values that I typed in somehow, but everytime i get only empty or null values.

    But maybe I missunderstood you before

    Stefan Schulz schrieb:

    The RemoteFormData is not meant for accessing or manipulating an element's data directly, but provides live access to the element's form

    Do you mean that I can only acces the values of the metaFormOperation when the form is open?

    Kind reagrds

    Benjamin

    0
  • Zendesk API User
    Author: StefanSchulz - 9/2/2013 14:44

    Sorry, I am confused now. What popup window? What client are we talking about? :smileyconfused:

    0
  • Zendesk API User
    Author: benjamin_nagel - 9/2/2013 14:51

    I'm sorry!

    In this case I was speaking about the WebClient.

    Just to explain it for other people:

    When you start the MetaFormOperation in the WebClient you will get a popup window. When you start it in the JavaClient the pageRef element will be opened and the meta values tab is selected.

    I try it in both clients, but currently only the WebClient is important for me.

    0
  • Zendesk API User
    Author: StefanSchulz - 9/2/2013 15:10

    Argh, OK, I barked up the wrong tree.

    In that case, the operation's perform() returns after the popup is closed. If changes were made and committed, they should get stored to the element's data container afterwards. And the returned RemoteFormField provides a read-only access to the element's data container, at least it should. So remoteFormData and metaFormData both provide the same values, which they seem to do after all (cannot be sure about the permission element content, though).

    It's either a mistake I don't see or a bug in writing back the data. There seems no open issue at the moment, so, please, file an error report with as much information as possible to our support.

    Best,

    Stefan

    0

Please sign in to leave a comment.