Search the FirstSpirit Knowledge Base
FS-VErsion 5.0.318
English version below
Hallo liebe Community,
ich habe das Interface RemoteFormField und das Interface RemoteFormData in der API gefunden. Zum Beispiel bekommt man als Rückgabewert von de.espirit.firstspirit.ui.operations.OpenElementMetaFormOperation ein RemoteFormData-Objekt.
Leider verstehe ich das Konzept hinter diesen Remote-Elementen nicht.
Im Prinzip habe ich somit zwei Fragen:
1. Kann mir jemand erklären welches Konzept es hinter den Remote-Elementen gibt? Wenn ich mir die API ansehe gehe ich davon aus, dass es nur ein rein lesender Zugriff ist.
2. Wie kann ich das Ergebnis einer OpenElementMetaFormOperation.perform(...) Aufrufs speichern? Wenn ich rechte habe und es wirklich nur ein lesender Zugriff ist, muss ich die Daten manuell in das StoreElement speichern, oder?
Hier auch noch ein bisschen Code als Beispiel:
OperationAgent operationAgent = context.requestSpecialist(OperationAgent.TYPE); OpenElementMetaFormOperation metaFormOperation = operationAgent.getOperation(OpenElementMetaFormOperation.TYPE); |
metaFormOperation.setOpenEditable(true); |
remoteFormData = metaFormOperation.perform(destinationPageRef); |
Liebe Grüße
Benjamin
--------------------------------------
Hello dear community,
i found the interfaces RemoteFormField and RemoteFormData in the public API. For example, you get from de.espirit.firstspirit.ui.operations.OpenElementMetaFormOperation a RemoteFormData objekt.
Unfortunately, I do not understand the concept behind these remote elements.
Basically I have two questions:
1. Can someone explain to me what is the concept behind this remote objects? When I look at the API, I'm assuming that it's just a pure read access.
2. How can I save the result of a OpenElementMetaFormOperation.perform (...) call? If I'm right and it's really only read access, I have to manually save the data in the Store item, right?
Here also a little code as an example:
OperationAgent operationAgent = context.requestSpecialist(OperationAgent.TYPE); OpenElementMetaFormOperation metaFormOperation = operationAgent.getOperation(OpenElementMetaFormOperation.TYPE); |
metaFormOperation.setOpenEditable(true); |
remoteFormData = metaFormOperation.perform(destinationPageRef); |
Kind regards
Benjamin
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
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.
So it seems that permissions is not null, which is the value provided via the form field.
What does logging permissions.get() result to?
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
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
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
Sorry, I am confused now. What popup window? What client are we talking about? :smileyconfused:
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.
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