Abel Solórzano Astorga wrote: > Thanks Caleb, > > I follow your recommendation, but I am getting a BaseClass with no > properties. > The class I am creating it is supposed to have 4 properties. > > I am using the folling code to use the class: > > *...* > > *docname = xwiki.getUniquePageName("ValidationSample", "TestClass") > valdoc = xwiki.getDocument("ValidationSample." + docname) > ok = valdoc.newObject("ValidationSample.TestClass") > ok = valdoc.updateObjectFromRequest("ValidationSample.TestClass")* > * > ... > > valdoc.use("ValidationSample.TestClass")* > > ValidationSample.TestClass has 4 properties (2 TextAreas and 2 a Static > Lists). > > Then to get the property that I need to dynamically change: > > *field = valdoc.getDocument().getxWikiClass().get("Project")* > > But I get a null value from * > valdoc.getDocument().getxWikiClass().get("Project")*. The BaseClass returned "get" calls getField().getValue() maybe the problem is that BaseCollection is used for objects and xclasses and get is only useful for objects. Try getField()
> by *valdoc.getDocument().getxWikiClass() *is a > *ValidationSample.TestClass *class > but the Properties collection is empty. Because of a bug in groovy you can view private fields so you can look directly at the fields in the class with for(String name : valdoc.getDocument().getxWikiClass().fields.keySet()) { println(name); } Also if you want to change the prettyName of a class property (for example), you would have to cast the field to PropertyClass (didn't test this but it should work.) ((PropertyClass) valdoc.getDocument().getxWikiClass().getField()).setPrettyName("new name"); Caleb > > Regards, > > Abel > > On Wed, Mar 3, 2010 at 1:04 AM, Caleb James DeLisle < > calebdeli...@lavabit.com> wrote: > >> I can tell you that it can be done, anything which can be done by >> the user can be done with groovy. >> >> document.getxWikiClass().get("propertyName") returns an object of >> type element. >> >> http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/api/Element.html >> >> I think you need to drop out of the api section into the core (which >> requires programming rights but so does groovy) >> document.getDocument().getxWikiClass() >> gives you an object of type BaseClass which I think is what you are >> after. >> >> http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/objects/classes/BaseClass.html >> >> >> Caleb >> >> >> Abel Solórzano Astorga wrote: >>> Hi everybody, >>> >>> Is there a way to dynamically (through groovy code) change the values on >> a >>> static list or on any other property of a xwiki class? >>> >>> I am using *field = document.getxWikiClass().get("propertyName")* to get >> the >>> property. >>> >>> document is of type* com.xpn.xwiki.api.Document*. >>> >>> But when I try to change the value using * >>> field.getPropertyClass().setValues("val1|val2|val3")* I get a *null* >> value >>> from* field.getPropertyClass()* >>> >>> I am following the information on >>> http://www.mail-archive.com/users@xwiki.org/msg10692.html >>> >>> I am using groovy on xwiki 2.0.2.24645 >>> >>> Regards >>> >>> Abel >>> _______________________________________________ >>> 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 >> > _______________________________________________ > 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