Global xWikiClass used to create page in subwiki

Hi All,

I’ve been playing around more with classes and objects and found this tutorial very helpful in understanding how they work. (I also found a link to the article mentioned where the server doesn’t exist any more but can’t remember where)

I’ve setup a couple things like ‘Account Managers’ on the main wiki and displaying them how I want and am pretty comfortable with that now.

What I haven’t been able to work out is if I have defined an xWikiClass including the sheets and templates on the main wiki, can I use them in a sub wiki? I’ve copied the Template Provider to a subwiki and changed the “Template to use” to include’xwiki:’ to refer to the main wiki. but after selecting the template and creating in a subwiki it is empty.

Have I just missed a reference to the main wiki somewhere or does it not work that way?

E.g. have ‘Servers’ class setup in the main wiki, then in each subwiki for a customer use the template provider to setup and save the page local to the subwiki using the class and templates from the main wiki.

You cannot use a class from a different wiki (but you can configure a class with a sheet from a different wiki).

Thank you.

So, then by using the the sheet from a different wiki, you can change the layout on that one sheet and all wikis with a class using that sheet will update pages on the next load?

If you were to add an extra property, you would need to add it to each wiki that you have set that class up on?

Yes, you have to update the classes on all wikis, there is no way to have a shared set of properties between wikis right now. All you can share is the displayer (the sheet).

1 Like

Thanks heaps @tmortagne, I can live with that. I’ll just make sure to think of all the properties we’ll need before rolling it out.

Note that if you distribute and install your class as part of a XAR extension you can install it “On Farm” which mean it’s installed (and upgraded) on all wikis automatically.

And just like that, a new rabbit hole to fall down :sweat_smile:

Thank you though!

Sorry @tmortagne but I’m going to bother you with another couple of questions about this.

Would Custom Mapping work using the same class across all wikis?

Would all wikis need to have the xClass setup with custom mapping to the same Database Table?

No, custom mapping won’t help with that as all it does is storing data in a dedicated table instead of generic ones, but the class logic stay the same for XWiki API point of view.