Hey guys - I´m working on a workaround regarding the XWIKI-69 issue. I created a script service that does a quite comfortable translation-handling for me using several objects all having a “lang” property where I store the language-key. So for example I have two objects, one with “en” and one with “de”. I select the right one based on the current local and display it´s content (the pages I create like this are based on a template, this as a side-note…)
The problem I face now is the edit-mode. If I click on edit, the inline form edit mode opens and I can edit the object I displayed before (based on current language) - this works so far. If I want to save it, it does not work properly. I saw that it only works for the first object contained in the document´s object-list of the specific class. So it tries to save only the first object - if I try to edit the second one for example, no content changes, no exception is thrown.
Am I able to tell the save-button (or the underlying URL…) somehow that I want to edit and save a specific object and not the first one of its class?
Another possibility would be that I write my own fully-custom edit mode, etc. if that´s possible at all…
I have in mind that this already worked fine in the past for me, too - but somehow it doesn´t anymore. I encountered a very strange behavior: If I have two objects, say one with “de” and one with “en”, (whether first object or not, makes no difference), then the edit and save only works for the english object. If I change the property “lang” from “en” to “fr”, none of them is able to be saved anymore. Do I maybe have some strange system settings or something? My standard language is english, supported are german and english. I also changed standard language to german, but same effect.
It seems like this is also not the root-cause… I now created a completely new page, added two XWiki.Mail objects, inserted your code and the problem is the same.
…additional information: If I use english as standard language, this effect occurs. But if I change the settings of the wiki and create a new page whose standard language is german, it works - means, it saves the data. In the english version only the english object can be saved. Even with this “hard-coded” language it does not work on the english page for the german object - this is strange!
Update: Which object is saveable properly depends on the language of the document the object is attached to and the language I currently use for viewing the content.
Example: I have a page (regardless if template sheet or not) and it´s standard language is english. If I use the code you see below to display a specific object (regardless which one, all objects selected by ‘de’, ‘en’, etc. will work), the object can be edited and saved without problems in inline form mode if I display the page in english, too.
If I now switch to german (means I display xwiki in german, using ?language=de), the object is displayed, too, because the selection $doc.getObject('XWiki.Mail', 'language', 'de') is static. But the funny thing now is that i´m not able to save it anymore! Saving of edited stuff is only possible if displaying in english.
I tested the opposite case using a document created in german with the same code (also tried ‘de’ and ‘en’ selection, but both act same) - and the result is equal. This means in this case I´m only able to save the object´s new contents after editing if I display the document in german. English brings the same effect as before using German.
So it seems like I´m only allowed to edit objects if I´m on the original page and translations cause problems.
Has anyone a rough idea maybe? I´m kind of at the end already…
Many thanks in advance, guys. Have a nice weekend so far!