Hello, thank you Mr Friedman-Hill for your thorough response, it helped
out a lot. I followed he sequence but seem to be having some trouble.
Instructions for web-based interview:
On Sun, 1 Feb 2004 [EMAIL PROTECTED] wrote:
> Not sure what the question is, exactly. What you'd want to do would be
> to have a Rete object held in the Web application's session. When a
> form was submitted, it would go to a servlet which would
>
> 1) extract form data
> 2) create facts out of it
> 3) assert the facts
> 4) run the engine
> 5) query the engine for a list of questions to ask
> 6) Pass that list on to a JSP to create the next form.
> rules just need to store the list someplace where step 5 above can get
> it easily. For example:
> - Have the session init code store an ArrayList using Rete.store().
> - Have the servlet call list.clear() before running.
> - Have the rules call (fetch) to get the list, and just add the names
> of the questions to the list. Then the servlet can easily get
> the list of questions.
In my servlet I have:
Rete engine = (Rete) servletContext.getAttribute("engine");
//create array to store questions to be asked
ArrayList questionList = new java.util.ArrayList();
//clear the questionList so new questions can be added
questionList.clear();
//store the questionList in the Rete engine
engine.store("?questionList", questionList);
//run rules
engine.run();
//retrieve list -- not working, not sure why????
Value questions = engine.fetch("?questionList");
questionList = (ArrayList) questions.externalAddressValue(engine.getGlobalContext());
// sent back to jsp page
request.setAttribute("queryResult", questionList);
In my Jess file:
(import java.util.*)
;; history is question key
(defrule request-history
=>
(fetch ?questionList)
(call ?questionList add history)
;; not sure if I need to store again???
(store ?questionList))
Thanks for any comments.
--
Kathleen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"I've seen things you people wouldn't believe.
Attack ships on fire off the shoulder of Orion.
I watched c-beams, glitter in the dark near Tannhauser Gate.
All those... moments will be lost... in time... like tears... in rain.
Time... to die."
-- Roy Batty.
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------