[xwiki-users] Howto getprefix in a Sheet?
Hello,I have a docClass with some properties and use a linked Sheet to display my data.On this thread http://xwiki.475771.n2.nabble.com/Help-with-custom-display-td508630.htmlI saw we can get this value in "custom display" field of docClass properties.- $name = the name of the displayed field - $prefix = a prefix for the form field - $object = the displayed object - $type = the intended display mode (view, edit, hidden, search...) - $value = the property value I try to have same value from mydocSheet (in particulary prefix the id of the field in edit form) There Velocity code in my docSheet: #set($class = $doc.getObject('MySpace.docClass').xWikiClass) #foreach($prop in $class.properties) * "$prop.Name" * $prop.?????? How to obtain the prefix ??? * $object (it doesn't matter) * $xcontext.action * $doc.getValue($prop.Name) $prop.prettyName $doc.display($prop.getName()) #end #break If any have an (or many) idea how I can obtain this prefix in my Sheet (If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_) Thxs Pascal B
No way to catch $prefix with velocity in my docSheet, then? :-( Finally I adopt another 'ugly'? way to add some class and stuf in some DIV on my form: I reconstruct some DIV elements with velocity in "Custom Display" field of my docClass properties. My purpose, I wanted add some nice bootstrap tooltips on my radio button generate by my docSheet.http://getbootstrap.com/javascript/#tooltips-examples Here my example I can paste in XWIKI FAQ if it is a good way (I doubt it :-) ):- I add a "Boolean" property in my docClass with form type "radio" and I paste this code in "Custom Display":***************************{{velocity}} {{html clean=false}} #if($type == "edit") #set ($MyToolTipText="Tooltip on top de mon bouton radio") #foreach( $i in [1..0] ) <div> #if ($i==0) #set($LibReponse='Non') #set($SuffxLabel='_false') #if ($!value==0) #set($IsChecked='checked="checked"') #end #else #set($LibReponse='Oui') #if ($!value==1) #set($IsChecked='checked="checked"') #end #end <label for="${prefix}${name}$!{SuffxLabel}"> <input id="${prefix}${name}$!{SuffxLabel}" type="radio" name="${prefix}${name}" value="$i" $!IsChecked data-toggle="tooltip" data-placement="right" title="$!{MyToolTipText}"> $LibReponse </label> </div> #set($IsChecked='') #end #elseif ($type == "view") #if ($!value==0) <strong>Non</strong> #elseif ($!value==1) <strong>Oui</strong> #end #end {{/html}} {{/velocity}} ***************************I paste this xwiki.javascriptExtension to initiate Tooltips:require(['jquery'], function ($) { $(function () { $('[data-toggle="tooltip"]').tooltip() }) }); (Notice: I didn't use full JS because I don't like the blinking effect or errors who's crash Xwiki menu) Pascal B De : Pascal BASTIEN <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Jeudi 29 janvier 2015 12h05 Objet : [xwiki-users] Howto getprefix in a Sheet? Hello,I have a docClass with some properties and use a linked Sheet to display my data.On this thread http://xwiki.475771.n2.nabble.com/Help-with-custom-display-td508630.htmlI saw we can get this value in "custom display" field of docClass properties.- $name = the name of the displayed field - $prefix = a prefix for the form field - $object = the displayed object - $type = the intended display mode (view, edit, hidden, search...) - $value = the property value I try to have same value from mydocSheet (in particulary prefix the id of the field in edit form) There Velocity code in my docSheet: #set($class = $doc.getObject('MySpace.docClass').xWikiClass) #foreach($prop in $class.properties) * "$prop.Name" * $prop.?????? How to obtain the prefix ??? * $object (it doesn't matter) * $xcontext.action * $doc.getValue($prop.Name) $prop.prettyName $doc.display($prop.getName()) #end #break If any have an (or many) idea how I can obtain this prefix in my Sheet (If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_) Thxs Pascal B _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On Thu, Jan 29, 2015 at 1:05 PM, Pascal BASTIEN <[email protected]> wrote:
Hello,I have a docClass with some properties and use a linked Sheet to display my data.On this thread http://xwiki.475771.n2.nabble.com/Help-with-custom-display-td508630.htmlI saw we can get this value in "custom display" field of docClass properties.- $name = the name of the displayed field - $prefix = a prefix for the form field - $object = the displayed object - $type = the intended display mode (view, edit, hidden, search...) - $value = the property value
I try to have same value from mydocSheet (in particulary prefix the id of the field in edit form) There Velocity code in my docSheet:
#set($class = $doc.getObject('MySpace.docClass').xWikiClass)
#foreach($prop in $class.properties) * "$prop.Name" * $prop.?????? How to obtain the prefix ??? * $object (it doesn't matter) * $xcontext.action * $doc.getValue($prop.Name) $prop.prettyName $doc.display($prop.getName()) #end #break If any have an (or many) idea how I can obtain this prefix in my Sheet
(If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_)
I'm afraid you have to compute the prefix yourself. 0 represents the object number. So MySpace.MyClass_4_age refers to the 'age' property of the MySpace.MyClass object with number 4 (normally the fifth object of that type from the target document). Hope this helps, Marius
Thxs Pascal B _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
ThxsI verified and it seem it is always _0_ for each properties (even for multiple properties of same type)ie If I have 2 properties with 'date' type in MySpace.MyClass (date_entry and birthday), $doc.display($prop.getName() will generate this form <input id="MySpace.MyClass_0_date_entry" xxxx<input id="MySpace.MyClass_0_birthday" xx But If I have a 'database list' with checkbox property "BirthdayYear" in MySpace.MyClass, $doc.display($prop.getName() will generate this form (with 2 similar hidden input field ! Maybe a bug?) :<label class="xwiki-form-listclass" for="xwiki-form-A_Expert-0-0"><input id="xwiki-form-A_Expert-0-0" type="checkbox" value="1980" name="MySpace.MyClass_0_BirthdayYear">1980</label><label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-1"><input id="xwiki-form-A_Expert-0-1" type="checkbox" value="1981" name="MySpace.MyClass_0_BirthdayYear">1981</label>... <label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-n"><input id="xwiki-form-A_Expert-0-n" type="checkbox" value="20nn" name="MySpace.MyClass_0_BirthdayYear"> 20nn</label><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"> I didn't find what is generate this _0_ (macro or java stuf) ThxsPascal B De : Marius Dumitru Florea <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Mardi 3 février 2015 8h16 Objet : Re: [xwiki-users] Howto getprefix in a Sheet? ...
If any have an (or many) idea how I can obtain this prefix in my Sheet
(If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_)
I'm afraid you have to compute the prefix yourself. 0 represents the object number. So MySpace.MyClass_4_age refers to the 'age' property of the MySpace.MyClass object with number 4 (normally the fifth object of that type from the target document). Hope this helps, Marius
Thxs Pascal B _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
The number is not the number of the property in the class, but the number of the object on the page. I.e. you can have one, two, or manye objects of the same type MySpace.MyClass on the same page. A Macro where you can see how the ID gets rendered is in templates/editobject.vm and/or webapps/xwiki/skins/flamingo/editobject.vm see the #macro displayObject On 02/03/2015 10:12 AM, Pascal BASTIEN wrote:
ThxsI verified and it seem it is always _0_ for each properties (even for multiple properties of same type)ie If I have 2 properties with 'date' type in MySpace.MyClass (date_entry and birthday), $doc.display($prop.getName() will generate this form <input id="MySpace.MyClass_0_date_entry" xxxx<input id="MySpace.MyClass_0_birthday" xx But If I have a 'database list' with checkbox property "BirthdayYear" in MySpace.MyClass, $doc.display($prop.getName() will generate this form (with 2 similar hidden input field ! Maybe a bug?) :<label class="xwiki-form-listclass" for="xwiki-form-A_Expert-0-0"><input id="xwiki-form-A_Expert-0-0" type="checkbox" value="1980" name="MySpace.MyClass_0_BirthdayYear">1980</label><label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-1"><input id="xwiki-form-A_Expert-0-1" type="checkbox" value="1981" name="MySpace.MyClass_0_BirthdayYear">1981</label>... <label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-n"><input id="xwiki-form-A_Expert-0-n" type="checkbox" value="20nn" name="MySpace.MyClass_0_BirthdayYear"> 20nn</label><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"> I didn't find what is generate this _0_ (macro or java stuf) ThxsPascal B
De : Marius Dumitru Florea <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Mardi 3 février 2015 8h16 Objet : Re: [xwiki-users] Howto getprefix in a Sheet?
...
If any have an (or many) idea how I can obtain this prefix in my Sheet
(If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_)
I'm afraid you have to compute the prefix yourself. 0 represents the object number. So MySpace.MyClass_4_age refers to the 'age' property of the MySpace.MyClass object with number 4 (normally the fifth object of that type from the target document).
Hope this helps, Marius
Thxs Pascal B _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
mit freundlichen Grüßen Clemens Klein-Robbenhaar -- Clemens Klein-Robbenhaar Software Development EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.763 Fax: +49.(0)30.90 226.760 [email protected] HRB 77554 B - Berlin-Charlottenburg Vorstand: Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber Zertifiziert nach ISO 9001:2008
Yes thanks you both. In editobject.vm #macro(displayObject $obj $class $props $firstField) <div id="xobject_${escapetool.xml($class.name)}_${obj.number}" class="xobject"> Then i think, I found the solution to get prefix in a sheet: #set ($DocClass= 'MySpace.MydocClass') #set($class = $doc.getObject(${DocClass}).xWikiClass) ##Boucle sur toutes les properties de la classe DocClass #foreach($prop in $class.properties) * ${escapetool.xml($class.name)}_${class.number}_$prop.Name #end Notice: sorry about miss formating mail, I think it is yahoo webmail fault? Pascal B. -------------------------------------------- En date de : Mar 3.2.15, Clemens Klein-Robbenhaar <[email protected]> a écrit : Objet: Re: [xwiki-users] Howto getprefix in a Sheet? À: [email protected] Date: Mardi 3 février 2015, 10h38 The number is not the number of the property in the class, but the number of the object on the page. I.e. you can have one, two, or manye objects of the same type MySpace.MyClass on the same page. A Macro where you can see how the ID gets rendered is in templates/editobject.vm and/or webapps/xwiki/skins/flamingo/editobject.vm see the #macro displayObject On 02/03/2015 10:12 AM, Pascal BASTIEN wrote:
ThxsI verified and it seem it is always _0_ for each properties (even for multiple properties of same type)ie If I have 2 properties with 'date' type in MySpace.MyClass (date_entry and birthday), $doc.display($prop.getName() will generate this form <input id="MySpace.MyClass_0_date_entry" xxxx<input id="MySpace.MyClass_0_birthday" xx But If I have a 'database list' with checkbox property "BirthdayYear" in MySpace.MyClass, $doc.display($prop.getName() will generate this form (with 2 similar hidden input field ! Maybe a bug?) :<label class="xwiki-form-listclass" for="xwiki-form-A_Expert-0-0"><input id="xwiki-form-A_Expert-0-0" type="checkbox" value="1980" name="MySpace.MyClass_0_BirthdayYear">1980</label><label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-1"><input id="xwiki-form-A_Expert-0-1" type="checkbox" value="1981" name="MySpace.MyClass_0_BirthdayYear">1981</label>... <label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-n"><input id="xwiki-form-A_Expert-0-n" type="checkbox" value="20nn" name="MySpace.MyClass_0_BirthdayYear"> 20nn</label><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"> I didn't find what is generate this _0_ (macro or java stuf) ThxsPascal B
De : Marius Dumitru Florea <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]>
Envoyé le : Mardi 3 février 2015 8h16 Objet : Re: [xwiki-users] Howto getprefix in a Sheet? ...
If any have an (or many) idea how I can obtain this prefix in my Sheet
(If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_)
I'm afraid you have to compute the prefix yourself. 0 represents the
object number. So MySpace.MyClass_4_age refers to the 'age' property of the MySpace.MyClass object with number 4 (normally the fifth object of that type from the target document).
Hope this helps, Marius
Thxs Pascal B
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
mit freundlichen Grüßen Clemens Klein-Robbenhaar -- Clemens Klein-Robbenhaar Software Development EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.763 Fax: +49.(0)30.90 226.760 [email protected] HRB 77554 B - Berlin-Charlottenburg Vorstand: Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber Zertifiziert nach ISO 9001:2008 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On Tue, Feb 3, 2015 at 3:35 PM, Pascal BASTIEN <[email protected]> wrote:
Yes thanks you both.
In editobject.vm
#macro(displayObject $obj $class $props $firstField) <div id="xobject_${escapetool.xml($class.name)}_${obj.number}" class="xobject">
Then i think, I found the solution to get prefix in a sheet:
#set ($DocClass= 'MySpace.MydocClass') #set($class = $doc.getObject(${DocClass}).xWikiClass) ##Boucle sur toutes les properties de la classe DocClass #foreach($prop in $class.properties)
* ${escapetool.xml($class.name)}_${class.number}_$prop.Name
The XML escaping is needed above because the class name is used inside HTML. In your case you seem to have only wiki syntax (unless you have a {{html wiki="true"}} somewhere). And the $class doesn't have any number. As I said in my first reply and as Clemens has emphasized the object has the number, because you can have multiple objects of the same type/class on the same wiki page.
#end
Notice: sorry about miss formating mail, I think it is yahoo webmail fault?
Pascal B.
-------------------------------------------- En date de : Mar 3.2.15, Clemens Klein-Robbenhaar <[email protected]> a écrit :
Objet: Re: [xwiki-users] Howto getprefix in a Sheet? À: [email protected] Date: Mardi 3 février 2015, 10h38
The number is not the number of the property in the class, but the number of the object on the page. I.e. you can have one, two, or manye objects of the same type MySpace.MyClass on the same page.
A Macro where you can see how the ID gets rendered is in templates/editobject.vm and/or webapps/xwiki/skins/flamingo/editobject.vm see the #macro displayObject
On 02/03/2015 10:12 AM, Pascal BASTIEN wrote:
ThxsI verified and it seem it is always _0_ for each properties (even for multiple properties of same type)ie If I have 2 properties with 'date' type in MySpace.MyClass (date_entry and birthday), $doc.display($prop.getName() will generate this form <input id="MySpace.MyClass_0_date_entry" xxxx<input id="MySpace.MyClass_0_birthday" xx But If I have a 'database list' with checkbox property "BirthdayYear" in MySpace.MyClass, $doc.display($prop.getName() will generate this form (with 2 similar hidden input field ! Maybe a bug?) :<label class="xwiki-form-listclass" for="xwiki-form-A_Expert-0-0"><input id="xwiki-form-A_Expert-0-0" type="checkbox" value="1980" name="MySpace.MyClass_0_BirthdayYear">1980</label><label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-1"><input id="xwiki-form-A_Expert-0-1" type="checkbox" value="1981" name="MySpace.MyClass_0_BirthdayYear">1981</label>... <label class="xwiki-form-listclass" for="xwiki-form-BirthdayYear-0-n"><input id="xwiki-form-A_Expert-0-n" type="checkbox" value="20nn" name="MySpace.MyClass_0_BirthdayYear"> 20nn</label><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"><input type="hidden" value="" name="MySpace.MyClass_0_BirthdayYear"> I didn't find what is generate this _0_ (macro or java stuf) ThxsPascal B
De : Marius Dumitru
Florea <[email protected]>
À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]>
Envoyé le : Mardi 3 février 2015 8h16 Objet : Re: [xwiki-users] Howto getprefix in a Sheet?
...
If any have an (or many) idea how I can obtain this prefix in my Sheet
(If not I can concanet MySpace.docClass_0_$prop.Name but I'm not sure about _0_)
I'm afraid you have to compute the prefix yourself. 0 represents the
object number. So MySpace.MyClass_4_age refers to the 'age' property of the MySpace.MyClass object with number 4 (normally the fifth object of that type from the target document).
Hope this helps, Marius
Thxs Pascal B
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
mit freundlichen Grüßen Clemens Klein-Robbenhaar
-- Clemens Klein-Robbenhaar Software Development EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.763 Fax: +49.(0)30.90 226.760 [email protected]
HRB 77554 B - Berlin-Charlottenburg Vorstand: Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber Zertifiziert nach ISO 9001:2008 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Clemens Klein-Robbenhaar -
Marius Dumitru Florea -
Pascal BASTIEN