I think I understand now.  You want to leverage the rules part of Tohu to model a questionnaire but not the UI part of it?

In this case you would use tohu-core only, and instead of tohu-xml you would write your own code to interact with the Drools knowledge session.  Have a look at the code in tohu-xml to see how it works.

tohu-core just provides the object model and the rules.  KnowledgeSessionHelper.getActiveObjects()  will return you all the active (i.e. visible) questions.  When the user responds by answering questions you will have to insert them into the session by creating Answer objects.  This will then trigger the rules and change what is returned by getActiveObjects.

Tohu is stateful so you'd need to maintain a knowledge session per user session.  tohu-xml contains a ChangeCollector class which allows it determine which objects have changed and only the changes (inserts/updates/deletes) are sent back to the JQuery UI.  You'll need to work out how you want to handle this, whether you just ignore it and always re-render the whole screen, or whether you use a similar mechanism to only update what has changed.


From: Jelle Victoor <jelle.victoor@conundra.eu>
To: Damon Horrell <damonnomad71@yahoo.co.nz>
Cc: "tohu-users@lists.jboss.org" <tohu-users@lists.jboss.org>
Sent:
Subject: Re: [tohu-users] questionair to include into larger application

Hey Damon, thanks for tour awnser.
I think I asked my question the wrong way.
I want to replace the generated ui by my own rest interface so that tohu is encapsulated on my service layer.
It looks like a fine product but overall it was hard to find the right maven repo (jboss developer) and I had to build it from svn. I got it working but a more 'out-of-the-box' approach would help it getting spread. The examples included are very good and I found some good YouTube video's so kudos for that :)
On 1 Sep 2014 22:03, Damon Horrell <damonnomad71@yahoo.co.nz> wrote:
Hi Jelle,

You can write any Java code within the rules so for example you can call one of your REST apis to fetch the values to display for the multiple choice answers.  You'll need to convert whatever this returns into various PossibleAnswer objects.  It'll be cleaner if you put most of the code in a Java class and then declare this as a global within the rules.

Also if you wish to persist the data that the user enters then use KnowledgeSessionHelper.getAnswers() to get the values for saving.  Then to recreate a questionnaire from saved data you need to instantiate Answer objects and insert them into the session.  xml-example illustrates both of these using a dummy textarea containing XML as the "persisted storage".  See OutputServlet for saving and submit.jsp for reading back.  In your case you'll probably want to convert the Map returned by getAnswers() into JSON which you can pass to your REST backend.

Re documentation, I'm sorry but there is only what's on the WIki (https://developer.jboss.org/wiki/Tohu) plus the examples and Javadoc.  But I'm happy to answer any questions.

Regards, Damon


From: Jelle Victoor <jelle.victoor@conundra.eu>
To: "tohu-users@lists.jboss.org" <tohu-users@lists.jboss.org>
Sent: Monday, 1 September 2014 8:24 PM
Subject: [tohu-users] questionair to include into larger application

Hi
 
I’m building large application with angularjs. Now I have a need to use a questionair and I’ve been looking at tohu and decided that this seems a solid framework for the job. The only question is how this will integrate with the rest of my application which is a pure rest based back-end with a angularjs front-end.
Any suggestions? Is there also more documentation to be found? Now I’m just engineering on top of the examples to build something I want. Everything works as long as I stay inside the tohu framework, but what if I want to get my multiple choice answers from my database etc?
 
 

_______________________________________________
tohu-users mailing list
tohu-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/tohu-users