This question about Using an extension: Asked

How does inheritance work? And DataForms/Attributes

I'm trying to get to grips with WikiWorkbench. The documentation doesn't cover the design principles or full use of the framework, so I'm trying to figure out how ClassificationPlugin works, and to play with anything existing that uses it, so I can figure out how to properly implement with it.

I'm trying to figure out how inheritance actually works - I've found from trial and error, that each of the parent TopicTypes has to be listed in order within the TopicTypes dataform field. But what is actually inherited? Is it purely the fallback of edit/view/template forms?

DataForms is also undocumented along with DataFormAttributes. I can only hazzard a guess that its a DRY way of building the dataforms, but how am I supposed to include them within a TopicType?

What I originally enivisioned, was that DataForms are fragments of forms related to a topictype, and that they would combine together through inheritance. For example, if I have a Party object, and then two child objects Person and Organisation, the Party object would have common fields such as Name, Address, Phone etc, and then the Person/Org objects would add additional fields or change defaults etc. Is that the gist, or am I way off? Can inheritance work in this way or is it not that similar to programatic class inheritance?

And finally, what are DataFormAttributes? and how do they work?

PS: As I'm learning about it, I'm making notes, and would be happy to expand the existing documentation on the module.

-- JonMcCoy - 02 Mar 2024

Hey Jon - I'm keenly interested in helping you (and others) understand how the WikiWorkBench works as it's a offers a great boost to creating Foswiki applications. To be honest, there are aspects of "inheritance" in WikiWorkbenchContrib which I don't fully understand myself, however I do think I can clarify some of the terms you mention above and how they work.

Let's start with TopicTypes and I will illustrate it using a simple project planning application. TopicTypes are the different kinds of topics that are needed to build your application. So for a planning application, you might have Milestone, Objective, and Task topic types. In the case of WikiWorkbenchContrib (which is itself an application - an application for building applications), there are TopicTypes for all the components you might need to build an application and these are listed in the right sidebar of the WikiWorkbenchContrib "Applications" web. Note that a particular topic might be more than one TopicType. For example, in WikiWorkbenchContrib, TopicType topics are classified as TopicType, DataForm (which I'lll explain next), DocuTopic (any topic containing documentation), ApplicationTopic (a topic that is part of an application), and WikiTopic (a generic wiki topic). I should also note that some of this is kind of hidden in the way WikiWorkbenchContrib itself is set up, in that when you edit a TopicType topic, you won't see the TopicType field. However, if you view the "raw" topic (by adding "?raw=all) to the topic url, you can see the assigned TopicTypes.

Now let's look at the DataForm TopicType. These are simply application topics which contain a data form definition (as defined in the core Foswiki documentation - see System.DataForms). TopicType topics pretty much always include a data form definition table to hold information associated with that kind of topic, so in WikiWorkbenchContrib, TopicType topics are also DataForm topics. In regards to using the TopicType field in a particular Data form, you typically pre-assign that value in the data form definition because it rarely if ever gets changed but serves as an easy way to find all topics of that type using a query like TopicType = 'Milestone'.

Next, DataFormAttributes are a TopicType that offers an alternative way to define a particular field's values, via the mechanism outlined in Foswiki documentation under Data Forms > How to retrieve values from other topics. So essentially these are simply topics that contain a list of values that are referenced by a field in a Data Form. I personally don't use these much however it could be useful in a case where a particular value list is used in more than one TopicType so that you can update the list in one place rather than in each separate data form. One application I created that did use this had a DataFormAttributes topic for "Department" and listed all the organization's departments and this value list was referenced by multiple different data forms that needed to include a department reference.

In regards to "inheritance", one form of inheritance that WikiWorkbenchContrib uses extensively which I do understand well, is how TopicTypes inherit TopicViews (another TopicType in WikiWorkbenchContrib) with the help of AutoTemplatePlugin. If you have a TopicType called "Milestone" for example and then create a ViewTemplate called "MilestoneViewTemplate", that view template will automagically be applied to any topic using the Milestone data form.

I know there's a lot more to unpack here but perhaps this is a start to get you going.

-- LynnwoodBrown - 03 Mar 2024

Thanks for the response Lynnwood!

The biggest form of inheritance I want/would love, is the DataForm structure. Define once for each Topic, and then any Topics that 'inherit' get those non-standard DataForm elements (ie excluding summary, topictype etc).

I didn't see your reply over the weekend, but ended up figuring out the DataFormAttributes via that DataForm topic you mentioned. I also found that inheritance was mostly template only by a comment in the DBcall docs I think. I've found that just having to repeat the DataForm attribute for 'inherited' Topics, has made the DataFormAttributes function essential! I can see problems cropping up quickly if each Topic has varying attributes from edits/updates.

With DataForms, I was really hoping there'd be some form of reusability there, hence a dedicated DataForms TopicType. When you click "New" as well, it comes up with a blank topic template with just a DataForm in it - I wasn't sure if this was some automagic way of building reusable forms.

On that note, is there a reliable way of getting table rows from another topic? To kind of implement a form of inheritance... I've not tried this yet, but in the most basic way wondering if a section block wrapped around the rows I want to share would work? Then just have a DBcall for each of the 'parent' tables I want to include. Not sure if they work mixed with table markup or not. Likewise, wonder if the renderer that generates the DataForms can handle multiple tables, or is it just the first table with the right header cells that gets read? Obviously not automagic, but a couple of includes that match the TopicTypes listed seems much easier than repeating the DataForm elements each time...

I've already had a few snags, where I've made changes to a DataForm, and not changed everything that 'inherits' from it, so I'd love to figure it out.

Thanks for the detailed response! It's got me thinking!

-- JonMcCoy - 05 Mar 2024
 

QuestionForm edit

Subject Using an extension
Extension WikiWorkbenchContrib
Version Foswiki 2.1.8
Status Asked
Related Topics
Topic revision: r3 - 05 Mar 2024, JonMcCoy
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy