Re: [xwiki-users] A way to add some tags on saved page with class (resolved)
Here my working well :-) code to add a tag from a property ( database list) of my Class attached on my doc : ## Début section pour checker les tags ## Si champ x_CssTag alors rajout du tag et/ou suppression des anciens tags #if (($xcontext.action == 'view') && ($prop.Name.endsWith("_$!{SufxTag}")=='true')) #set ($NouveauTag=$doc.getValue($prop.Name)) #if ($!NouveauTag!='') ## Array de tous les tags du document #set ($TagsInMyDoc=$xwiki.tag.getTagsFromDocument($doc)) ## si tag n'est pas vide et n'est pas un tag du doc alors check des tags #if ($listtool.contains($TagsInMyDoc, $!NouveauTag)==false) ## Récup de toutes les valeurs de la liste #set($list = $class.get($prop.Name).getListValues()) ## $list $class.getName() $prop.Name #foreach($ATagFromClass in $list) ## * value: $ATagFromClass displayed ##Enlève tous les tags de la liste dans la page ## $ATagFromClass ## *** $listtool.isList($TagsInMyDoc) : $ATagFromClass est dans la liste: $TagsInMyDoc ## $listtool.contains($TagsInMyDoc, $ATagFromClass) ## efface les anciens tags si présents #if ($listtool.contains($TagsInMyDoc, $ATagFromClass)==true) #if ($!ATagFromClass!=$!NouveauTag) #set ($discard=$xwiki.tag.removeTagFromDocument($ATagFromClass, $doc)) ## = je supprime le tag $ATagFromClass = #end #elseif ($!ATagFromClass==$!NouveauTag) ## = j'ajoute le tag $NouveauTag sur $doc = ## Ajoute le nouveau Tag #set ($discard=$xwiki.tag.addTagToDocument($NouveauTag, $doc)) #end #end ## Fin à insérer #end ## #set($ClassTag=$ClassName) #end #end De : Pascal BASTIEN À : XWiki Users Envoyé le : Samedi 4 avril 2015 0h11 Objet : Re: [xwiki-users] A way to add some tags on saved page with class How silly am I! I was dealing with the problem in the wrong way. Instead to add some tag on saving page, some piece of velocity code in my Sheet (in view mode) must doing the right thinks... (I will paste the code when I finish it) ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] A way to add some tags on saved page with class
How silly am I! I was dealing with the problem in the wrong way. Instead to add some tag on saving page, some piece of velocity code in my Sheet (in view mode) must doing the right thinks... (I will paste the code when I finish it) (Anyway my batch working :-/) En date de : Ven 3.4.15, Pascal BASTIEN a écrit : Objet: Re: [xwiki-users] A way to add some tags on saved page with class À: "XWiki Users" Date: Vendredi 3 avril 2015, 15h45 FI with JS document.observe("xwiki:actions:save"). method my script doesn't work well... When I save and close my page: my tag is added OR my field are update OR the script going well OR I obtain a nice error message: Information détaillée: Error number 3201 in 3: Exception while saving document xwiki:FormSMQ.SMQ-P3-FPIAC-Jolie Fiche com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving document xwiki:FormSMQ.SMQ-P3-FPIAC-Jolie Fiche En date de : Ven 3.4.15, Pascal BASTIEN a écrit : Objet: Re : [xwiki-users] A way to add some tags on saved page with class À: "XWiki Users" Date: Vendredi 3 avril 2015, 11h00 Finally I added some CSS Id on my inline form (in my Sheet) and getProperty value with JS and document.observe("xwiki:actions:save"). I call my TagUpdater Page with AJAX var request=$.ajax({method: "POST", url: Url, data: UrlParams, dataType: "html", async: false}); My Ajax requests are sent synchronous if not sometimes my page is recorded before Tag added, and sometimes not, ... I know it is ugly way but I haven't choice. (Anyway, I will schedule some batch to fix my tags) ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] A way to add some tags on saved page with class
FI with JS document.observe("xwiki:actions:save"). method my script doesn't work well... When I save and close my page: my tag is added OR my field are update OR the script going well OR I obtain a nice error message: Information détaillée: Error number 3201 in 3: Exception while saving document xwiki:FormSMQ.SMQ-P3-FPIAC-Jolie Fiche com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving document xwiki:FormSMQ.SMQ-P3-FPIAC-Jolie Fiche at com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:780) at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:178) at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:171) at java.lang.Thread.run(Thread.java:745) Caused by: org.hibernate.HibernateException: Failed to commit or rollback transaction. Root cause [] at com.xpn.xwiki.store.XWikiHibernateBaseStore.endTransaction(XWikiHibernateBaseStore.java:1022) at com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:770) ... 69 more Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85) at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70) En date de : Ven 3.4.15, Pascal BASTIEN a écrit : Objet: Re : [xwiki-users] A way to add some tags on saved page with class À: "XWiki Users" Date: Vendredi 3 avril 2015, 11h00 Finally I added some CSS Id on my inline form (in my Sheet) and getProperty value with JS and document.observe("xwiki:actions:save"). I call my TagUpdater Page with AJAX var request=$.ajax({method: "POST", url: Url, data: UrlParams, dataType: "html", async: false}); My Ajax requests are sent synchronous if not sometimes my page is recorded before Tag added, and sometimes not, ... I know it is ugly way but I haven't choice. (Anyway, I will schedule some batch to fix my tags) ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] A way to add some tags on saved page with class
On Thu, Apr 2, 2015 at 5:51 PM, Pascal BASTIEN wrote: > Hello, > > I'm looking for advice about a way to add some tags on saved page with class. > What I have: > - a sheet page with an object Class ( with an object class + properties) + a > template page > - a velocity code in a page AddMyTag to add some tags on some page with this > URL parameters: > $!request.PageSource, $!request.ClassName > > What I'm trying to do, is: when a user save a page, a tag is added. The tag > to add is coming from a properties value (last character on property name is > _Tag). > If I call my 'AddMyTag' page, tags are correctly added on PageSource. > > To resume: > - the user save HisPage > - HisPage add tags from a properties value (name xxx_Tag) > > My problem is "how can I launch" automaticelly my 'AddMyTag' page when a user > record PageSource? > I tried with Ajax with > document.observe("xwiki:actions:save", function(event){ > (http://platform.xwiki.org/xwiki/bin/view/DevGuide/JavaScriptAPI#HActionevents28actionButtons.js29) > but the problem is: sometime xxx_Tag property value is updated after my > AJAX call (and the old tag is attached on page). > > A the moment, I'm looking for another way, I read > http://extensions.xwiki.org/xwiki/bin/view/Extension/WikiComponent+Module > But documentation indicate: "The goal is to listen ... DocumentUpdatingEvent > events (note that these events are fired before the page is saved and thus > our code doesn't need to perform the save itself ..." > Then I can not use this method either because I must add tag from new value > from my _Tag properties. It doesn't say the document doesn't have the changes. But that the event is fired before the changes are saved. So if you listen to this event you should be able to get the new property value and add the tag. Just don't call save() in the event handled because this is done automatically after the event is passed to all handlers (including yours). Hope this helps, Marius > > How can I launch a velocity script on a document after document is saved (to > add some tag from the document itself)? > > Thxs for any help > > Pascal B > > > > > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] A way to add some tags on saved page with class
Finally I added some CSS Id on my inline form (in my Sheet) and getProperty value with JS and document.observe("xwiki:actions:save"). I call my TagUpdater Page with AJAX var request=$.ajax({method: "POST", url: Url, data: UrlParams, dataType: "html", async: false}); My Ajax requests are sent synchronous if not sometimes my page is recorded before Tag added, and sometimes not, ... I know it is ugly way but I haven't choice. (Anyway, I will schedule some batch to fix my tags) En date de : Jeu 2.4.15, Pascal BASTIEN a écrit : Objet: [xwiki-users] A way to add some tags on saved page with class À: "XWiki Users" Date: Jeudi 2 avril 2015, 15h51 Hello, I'm looking for advice about a way to add some tags on saved page with class. What I have: - a sheet page with an object Class ( with an object class + properties) + a template page - a velocity code in a page AddMyTag to add some tags on some page with this URL parameters: $!request.PageSource, $!request.ClassName What I'm trying to do, is: when a user save a page, a tag is added. The tag to add is coming from a properties value (last character on property name is _Tag). If I call my 'AddMyTag' page, tags are correctly added on PageSource. To resume: - the user save HisPage - HisPage add tags from a properties value (name xxx_Tag) My problem is "how can I launch" automaticelly my 'AddMyTag' page when a user record PageSource? I tried with Ajax with document.observe("xwiki:actions:save", function(event){ (http://platform.xwiki.org/xwiki/bin/view/DevGuide/JavaScriptAPI#HActionevents28actionButtons.js29) but the problem is: sometime xxx_Tag property value is updated after my AJAX call (and the old tag is attached on page). A the moment, I'm looking for another way, I read http://extensions.xwiki.org/xwiki/bin/view/Extension/WikiComponent+Module But documentation indicate: "The goal is to listen ... DocumentUpdatingEvent events (note that these events are fired before the page is saved and thus our code doesn't need to perform the save itself ..." Then I can not use this method either because I must add tag from new value from my _Tag properties. How can I launch a velocity script on a document after document is saved (to add some tag from the document itself)? Thxs for any help Pascal B ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
[xwiki-users] A way to add some tags on saved page with class
Hello, I'm looking for advice about a way to add some tags on saved page with class. What I have: - a sheet page with an object Class ( with an object class + properties) + a template page - a velocity code in a page AddMyTag to add some tags on some page with this URL parameters: $!request.PageSource, $!request.ClassName What I'm trying to do, is: when a user save a page, a tag is added. The tag to add is coming from a properties value (last character on property name is _Tag). If I call my 'AddMyTag' page, tags are correctly added on PageSource. To resume: - the user save HisPage - HisPage add tags from a properties value (name xxx_Tag) My problem is "how can I launch" automaticelly my 'AddMyTag' page when a user record PageSource? I tried with Ajax with document.observe("xwiki:actions:save", function(event){ (http://platform.xwiki.org/xwiki/bin/view/DevGuide/JavaScriptAPI#HActionevents28actionButtons.js29) but the problem is: sometime xxx_Tag property value is updated after my AJAX call (and the old tag is attached on page). A the moment, I'm looking for another way, I read http://extensions.xwiki.org/xwiki/bin/view/Extension/WikiComponent+Module But documentation indicate: "The goal is to listen ... DocumentUpdatingEvent events (note that these events are fired before the page is saved and thus our code doesn't need to perform the save itself ..." Then I can not use this method either because I must add tag from new value from my _Tag properties. How can I launch a velocity script on a document after document is saved (to add some tag from the document itself)? Thxs for any help Pascal B ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users