Hi Antonio, I'll answer all questions here, and add the relevant code below (since it's an enormous lot of code). The "getObject()" function is something I get from my backend. It goes too far to explain it or to add the code (also a lot). I'll add the relevant part of the sitemap and the javascript files, although the login part is an almost exact copy of the "authentication with flow" sample in Cocoon.
[1] = sitemap [2] = login.js [3] = pids.js (my "use cases") [4] = authentication.xml (getuser) Several problems occur at once: 1. when the authentication context in the session is lost, the SessionTransformer throws an Exception. Since my error page includes a "cinclude:include src='cocoon:/getUser'" I cannot properly display the error. 2. If I go from one function to the next (e.g. from 'internal_addPerson' to 'prot_showDetails') I loose the session context (it references the internal pipeline). If I go "public" (i.e. through the protect() function) it works. Hope you have a clue. Thanks for bearing with me. Bye, Helma [1] sitemap <?xml version="1.0" encoding="UTF-8"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <map:components> <map:transformers default="xalan"> <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer"> <catalogues default="other"> <catalogue id="other" name="OtherMessages" location="messages"/> <catalogue id="forms" name="FormsMessages" location="messages"/> </catalogues> <cache-at-startup>true</cache-at-startup> </map:transformer> </map:transformers> <map:selectors default="browser"> <map:selector name="request-method" src="org.apache.cocoon.selection.RequestMethodSelector"/> </map:selectors> <map:pipes default="caching"/> </map:components> <map:resources> <!-- ========================================= --> <!-- html-layout - handles the conversion to html --> <!-- ========================================= --> <map:resource name="html-layout"> <map:transform src="stylesheets/layout.xslt"> <map:parameter name="hostname" value="http://{request:serverName}:{request:serverPort}/properweb/"/> <map:parameter name="use-request-parameters" value="true"/> <map:parameter name="sessionid" value="{session:./id}"/> <map:parameter name="sessionNew" value="{session:new}"/> </map:transform> <map:serialize type="html"/> </map:resource> </map:resources> <!-- ========================================= --> <!-- flow scripts --> <!-- ========================================= --> <map:flow language="javascript"> <map:script src="system/scripts/login.js"/> <map:script src="system/scripts/flowscripts.js"/> <!-- map:script src="system/scripts/test.js"/ --> <map:script src="system/scripts/pids.js"/> </map:flow> <map:pipelines> <!-- ========================================= --> <!-- flowAuthenticationHandler configuration --> <!-- ========================================= --> <map:component-configurations> <authentication-manager> <handlers> <handler name="flowAuthenticationHandler"> <!-- redirect-to uri="cocoon:/login"/> --> <!-- above should work, but doesn't because of bug in Cocoon 2.1.4-dev (prerelease), haven't checked since release --> <redirect-to uri="/properweb/login"/> <authentication uri="cocoon:raw:/authenticate"/> </handler> </handlers> </authentication-manager> </map:component-configurations> <map:pipeline> <!-- ========================================= --> <!-- flow script continuations --> <!-- ========================================= --> <map:match pattern="**/*.continue"> <map:call continuation="{2}"/> </map:match> <map:match pattern="*.continue"> <map:call continuation="{1}"/> </map:match> <!-- ========================================= --> <!-- about - information about the --> <!-- PropeR project and credits --> <!-- ========================================= --> <map:match pattern="about.html"> <map:call function="isLoggedIn"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="protected-redirect" value="general/about.form"/> <map:parameter name="failure-redirect" value="about"/> </map:call> </map:match> <map:match pattern="about"> <map:generate src="content/about.xml"/> <map:call resource="html-layout"/> </map:match> <!-- ========================================= --> <!-- news - news about the PropeR project --> <!-- ========================================= --> <map:match pattern="news.html"> <map:call function="isLoggedIn"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="protected-redirect" value="general/news.form"/> <map:parameter name="failure-redirect" value="news"/> </map:call> </map:match> <map:match pattern="news"> <map:generate src="content/news.xml"/> <map:call resource="html-layout"/> </map:match> <map:pipeline> <!-- ========================================= --> <!-- main pipeline for person related pages --> <!-- ========================================= --> <map:match pattern="person/**"> <map:call function="protect"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="protected-internal" value="internal/person/{1}"/> <map:parameter name="failure-redirect" value="login"/> <map:parameter name="failure-error" value="Eerst inloggen"/> </map:call> </map:match> <!-- ========================================= --> <!-- main pipeline for general pages --> <!-- ========================================= --> <map:match pattern="general/**"> <map:call function="protect"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="protected-internal" value="internal/{1}"/> <map:parameter name="failure-redirect" value="login"/> <map:parameter name="failure-error" value="Eerst inloggen"/> </map:call> </map:match> </map:pipeline> <!-- ========================================= --> <!-- pipeline handling the content of the --> <!-- person related pages --> <!-- ========================================= --> <map:pipeline internal-only="true"> <map:match pattern="internal/showError.form"> <map:generate type="jx" src="content/showError.jx"> <map:parameter name="errMsg" value="{session:errMsg}"/> </map:generate> <map:transform type="cinclude"/> <map:call resource="html-layout"/> <map:serialize type="xml"/> </map:match> <!-- ========================================= --> <!-- internal pipelines for person related --> <!-- forms --> <!-- ========================================= --> <map:match pattern="internal/person/**"> <map:match pattern="**/person/*.form"> <map:generate type="jx" src="content/{2}Template.jx"/> <map:transform type="cinclude"/> <map:transform type="forms"/> <map:transform src="stylesheets/resources/forms-samples-styling.xsl"> <map:parameter name="uri" value="stylesheets/resources"/> </map:transform> <map:call resource="html-layout"/> <map:serialize type="xml"/> </map:match> <!-- ========================================= --> <!-- internal pipelines for person related --> <!-- flow script forms --> <!-- match anything that calls a script with --> <!-- a fixed ending, e.g. .exec --> <!-- in case you forget: all functions are in --> <!-- system/flow/flowscripts.js --> <!-- ========================================= --> <map:match pattern="**/person/**.html"> <!-- ========================================= --> <!-- show all --> <!-- NOTE: it could be more efficient using --> <!-- more wildcard matching, but then invalid --> <!-- urls will be accepted too! --> <!-- ========================================= --> <map:match pattern="**/show/*.html"> <map:match pattern="**/patients.html"> <map:call function="prot_showAllPatients"/> </map:match> <map:match pattern="**/practitioners.html"> <map:call function="prot_showAllProviders"/> </map:match> <map:match pattern="**/team.html"> <map:call function="prot_showTeam"/> </map:match> <map:match pattern="**/result.html"> <map:call function="prot_showResult"/> </map:match> </map:match> <!-- ========================================= --> <!-- show details --> <!-- ========================================= --> <map:match pattern="**/showDetails/*.html"> <map:match pattern="**/patient*.html"> <map:call function="prot_showDetails"> <map:parameter name="key" value="patient"/> <map:parameter name="id" value="{request-param:findId}"/> </map:call> </map:match> <map:match pattern="**/practitioner*.html"> <map:call function="prot_showDetails"> <map:parameter name="key" value="provider"/> <map:parameter name="id" value="{request-param:findId}"/> </map:call> </map:match> </map:match> <!-- ========================================= --> <!-- edit --> <!-- ========================================= --> <map:match pattern="**/edit/*.html"> <map:match pattern="**/patient.html"> <map:call function="prot_editPatient"> <map:parameter value="patientid" name="{request-param:findId}"/> </map:call> </map:match> <map:match pattern="**/practitioner.html"> <map:call function="prot_editProvider"> <map:parameter value="id" name="{request-param:findId}"/> <map:parameter value="globalvar" name="{global:properweb}"/> </map:call> </map:match> <map:match pattern="**/team.html"> <map:call function="prot_modifyTeam"/> </map:match> </map:match> <!-- ========================================= --> <!-- add --> <!-- ========================================= --> <map:match pattern="**/add/*.html"> <map:match pattern="**/patient.html"> <map:call function="prot_addPatient"/> </map:match> <map:match pattern="**/practitioner.html"> <map:call function="prot_addProvider"/> </map:match> </map:match> <!-- ========================================= --> <!-- search --> <!-- ========================================= --> <map:match pattern="**/search/*.html"> <map:match pattern="**/patient.html"> <map:call function="prot_searchPatient"/> </map:match> <map:match pattern="**/practitioner.html"> <map:call function="prot_searchProvider"/> </map:match> </map:match> <!-- ========================================= --> <!-- select --> <!-- ========================================= --> <map:match pattern="**/select/*.html"> <map:match pattern="**/patient.html"> <map:call function="prot_selectPatient"/> </map:match> <map:match pattern="**/practitioner.html"> <map:call function="prot_selectProvider"/> </map:match> </map:match> </map:match> </map:match> <!-- ========================================= --> <!-- getSelectedPatientInNavbar --> <!-- ========================================= --> <map:match pattern="getSelectedPatientInNavbar"> <map:generate type="jx" src="content/showPatientInNavbar.jx"/> <map:serialize type="xml"/> </map:match> <!-- ========================================= --> <!-- generate list of forms based on xml --> <!-- files in directory --> <!-- ========================================= --> <map:match pattern="formlist"> <map:generate type="xpathdirectory" src="content/xmlforms" label="debug1"> <map:parameter name="xpath" value="/form/label | /form/code"/> <map:parameter name="include" value=".*\.xml$"/> <map:parameter name="exclude" value="elements.xml"/> <map:parameter name="sort" value="//label"/> </map:generate> <map:transform src="stylesheets/formlist.xslt"/> <map:serialize type="xml"/> </map:match> </map:pipeline> <!-- ========================================= --> <!-- Authentication pipelines --> <!-- ========================================= --> <map:pipeline> <!-- ========================================= --> <!-- Redirections for page requests on homepage --> <!-- ========================================= --> <map:match pattern=""> <map:redirect-to session="true" uri="login"/> </map:match> <map:match pattern="/"> <map:redirect-to session="true" uri="login"/> </map:match> <map:match pattern="*.html"> <map:redirect-to session="true" uri="login"/> </map:match> <!-- ========================================= --> <!-- Login page --> <!-- ========================================= --> <map:match pattern="login"> <map:call function="isLoggedIn"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="protected-redirect" value="person/search/patient.html"/> <map:parameter name="failure-internal" value="internal/login"/> </map:call> </map:match> <!-- ========================================= --> <!-- Form target which performs auth service --> <!-- ========================================= --> <map:match pattern="do-login"> <!-- try to login --> <map:call function="login"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="parameter_name" value="{request-param:username}"/> <map:parameter name="parameter_password" value="{request-param:password}"/> <map:parameter name="protected-redirect" value="{request-param:resource}"/> <map:parameter name="failure-redirect" value="login"/> <map:parameter name="failure-error" value="Verkeerde login"/> </map:call> </map:match> <!-- ========================================= --> <!-- Logout link which invalidates the session --> <!-- ========================================= --> <map:match pattern="do-logout"> <map:call function="logout"> <map:parameter name="handler" value="flowAuthenticationHandler"/> <map:parameter name="failure-redirect" value="login"/> <map:parameter name="failure-error" value=""/> </map:call> </map:match> </map:pipeline> <map:pipeline internal-only="true"> <!-- ========================================= --> <!-- This is the authentication resource --> <!-- ========================================= --> <map:match pattern="authenticate"> <map:generate src="system/authenticate/userlist.xml"/> <map:transform src="system/authenticate/authenticate.xslt"> <map:parameter name="use-request-parameters" value="true"/> </map:transform> <map:serialize type="xml"/> </map:match> <!-- ========================================= --> <!-- getUser --> <!-- put user info in an XML file --> <!-- ========================================= --> <map:match pattern="getUser"> <map:generate src="system/authentication.xml"/> <map:transform type="session"/> <map:serialize type="xml"/> </map:match> <!-- ========================================= --> <!-- handle the actual login --> <!-- ========================================= --> <map:match pattern="internal/login"> <map:generate src="content/main.jx" type="jx"/> <map:transform type="encodeURL"/> <map:call resource="html-layout"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> <!-- end of file --> [2] login.js cocoon.load("resource://org/apache/cocoon/webapps/authentication/flow/javasc ript/auth.js"); function isLoggedIn() { var handler = cocoon.parameters["handler"]; var resource = cocoon.parameters["resource"]; // resource contains the URL where the request came from, so you can redirect to there if (auth_isAuthenticated(handler, resource)) { <---- neither redirection work if (resource != undefined) { | cocoon.sendPage(resource); <---+ } else { success(); } } else { failure(); } } function protect() { var handler = cocoon.parameters["handler"]; if (auth_checkAuthentication(handler,"")) { success(); } else { // already redirected by auth_checkAuthentication } } function login() { var handler = cocoon.parameters["handler"]; if (auth_isAuthenticated(handler)) { success(); } else if (auth_login(handler, null, cocoon.parameters)) { success(); } else { failure(); } } function logout() { var handler = cocoon.parameters["handler"]; auth_logout(handler); failure(); } function success() { var internal = cocoon.parameters["protected-internal"]; var redirect = cocoon.parameters["protected-redirect"]; if (internal != null) { print("authentication success, redirecting to " + internal); cocoon.sendPage(internal); } else if (redirect != null) { print("authentication success, redirecting to " + redirect); cocoon.redirectTo(redirect); } else { throw new Error("No protected redirection parameter given"); } } function failure() { var internal = cocoon.parameters["failure-internal"]; var redirect = cocoon.parameters["failure-redirect"]; var errMessage = cocoon.parameters["failure-error"]; if (internal != null) { print("authentication failure, redirecting to " + internal); cocoon.sendPage(internal, {errMsg : errMessage}); } else if (redirect != null) { print("authentication failure, redirecting to " + redirect); cocoon.redirectTo(redirect); } else { // Why does this throw cause an error? throw new Error("No failure redirection parameter given"); } } [3] pids.js /* * File pids.js * * This script contains use cases dealing with the PIDS servers */ cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/v3/Form.js") ; var PATIENT_SERVER = "patient"; var PROVIDER_SERVER = "provider"; var SORT_LAST_NAME = "name/last"; var SORT_FIRST_NAME = "name/first"; var PATIENT_FORMDEF = "content/patientDef.xml"; var PROVIDER_FORMDEF = "content/providerDef.xml"; var PERSON_FORMBIND = "content/personBind.xml"; var SEARCH_PERSON_FORMDEF = "content/searchPersonDef.xml"; var SEARCH_PERSON_FORMBIND = "content/searchPersonBind.xml"; var ADD_EDIT_PERSON_FORM_DISPLAY = "internal/person/person.form"; var ALL_PERSONS_FORM_DISPLAY = "internal/person/showAll.form"; var DETAILS_FORM_DISPLAY = "internal/person/showDetails.form"; var ERROR_FORM_DISPLAY = "general/showError.form"; var SEARCH_PERSON_FORM_DISPLAY = "internal/person/searchPatient.form"; var SEARCH_RESULT_FORM_DISPLAY = "internal/person/showResult.form"; var TEAM_FORM_DISPLAY = "internal/person/showTeam.form"; var SHOW_RESULT = "person/show/result.html"; var SHOW_DETAILS_PATIENT = "person/showDetails/patient.html"; var SHOW_DETAILS_PRACTITIONER = "person/showDetails/practitioner.html"; function prot_showAllPatients() { var serverKey = PATIENT_SERVER; var sort1 = SORT_LAST_NAME; var sort2 = SORT_FIRST_NAME; internal_showAllPersons(serverKey, sort1, sort2); } // showAllPatients function prot_showAllProviders(sort1, sort2) { var serverKey = PROVIDER_SERVER; if(sort1 == undefined) sort1 = SORT_LAST_NAME; if(sort2 == undefined) { if(sort1 == SORT_LAST_NAME) { sort2 = SORT_FIRST_NAME; } else { sort2 = SORT_LAST_NAME; } } internal_showAllPersons(serverKey, sort1, sort2); } // showAllPractitioners function prot_searchPatient() { var serverKey = PATIENT_SERVER; var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var searchPerson = pidsHelper.getNewPerson(); var form = new Form(SEARCH_PERSON_FORMDEF); form.createBinding(SEARCH_PERSON_FORMBIND); var success = false; var errMsg = ""; var count = 0; // to prevent endless loops while(!success && count < 10) { try { form.load(searchPerson); var viewData = { errMsg : errMsg }; form.showForm(SEARCH_PERSON_FORM_DISPLAY, viewData); form.save(searchPerson); // list = list of fully qualified IDS (strings) var list = pidsHelper.findPersons(serverKey, searchPerson); success = true; } catch(error) { errMsg = "Er is een fout opgetreden: " + error; print(errMsg); success = false; } count++; } cocoon.releaseComponent(pidsHelper); if(success) { internal_prepareResult(list, serverKey); } else { internal_showErrorPage(errMsg); } } // searchPatient function prot_addPatient() { var serverKey = PATIENT_SERVER; internal_addPerson(serverKey); } // addPatient function prot_addProvider() { var serverKey = PROVIDER_SERVER; internal_addPerson(serverKey); } // addProvider function prot_editPatient() { // TODO make sure it works properly when the function is ended by the user before it is finished // to avoid memory leaks of unreleased objects floating around. var serverKey = PATIENT_SERVER; var patientid = cocoon.request.getParameter("findId"); if(patientid == null || patientid == undefined) { var errMsg = "onbekend id, het is niet duidelijk welke patient gezocht moet worden"; internal_showErrorPage(errMsg); } if(patientid != undefined && patientid != null) { internal_editPerson(serverKey, patientid); } } // editPatient function prot_editProvider(id) { // TODO make sure it works properly when the function is ended by the user before it is finished // to avoid memory leaks of unreleased objects floating around. var serverKey = PROVIDER_SERVER; if(id == undefined) { id = cocoon.request.getParameter("findId"); if(id == null || id == undefined) { var errMsg = "onbekend id, het is niet duidelijk welke zorgverlener gezocht moet worden"; internal_showErrorPage(errMsg); } } if(id != undefined) { internal_editPerson(serverKey, id); } } // editProvider function prot_showDetails(key, id, person) { if(key == undefined) { key = cocoon.request.getParameter("key"); if(key == null || key == undefined) { var errMsg = "onbekende server, het is niet duidelijk waar gezocht moet worden"; internal_showErrorPage(errMsg); } } if (person == undefined) { if(id == undefined) { id = cocoon.request.getParameter("id"); if(id == null || id == undefined) { var errMsg = "onbekend id, het is niet duidelijk welke persoon gezocht moet worden"; internal_showErrorPage(errMsg); } } var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); person = pidsHelper.findIdentity(key, id); cocoon.releaseComponent(pidsHelper); } var viewData = { person : person, src : key }; cocoon.sendPage(DETAILS_FORM_DISPLAY, viewData); } // showDetails function prot_showResult() { var list = cocoon.session.getAttribute("personsFound"); var key = cocoon.session.getAttribute("key"); var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var persons = new Packages.java.util.Vector(); for (var i = 0; i < list.size(); i++) { var id = list.get(i); var person = pidsHelper.findIdentity(key, id); persons.add(person); } cocoon.session.removeAttribute("key"); cocoon.session.removeAttribute("personsFound"); cocoon.releaseComponent(pidsHelper); var size = persons.size(); var viewData = { list : persons, nr : size, src : key }; cocoon.sendPage(SEARCH_RESULT_FORM_DISPLAY, viewData); } function prot_selectPatient() { // add the selected person to the session var id = cocoon.request.getParameter("findId"); var key = PATIENT_SERVER; var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var person = pidsHelper.findIdentity(key, id); cocoon.releaseComponent(pidsHelper); cocoon.session.setAttribute("selectedPatient", person); prot_showDetails(key, id, person); } // prot_selectPatient function prot_showTeam() { var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var session = cocoon.session; var person = session.getAttribute("selectedPatient"); var patientid = person.getFullID(); var serverKey = PROVIDER_SERVER; var persons = pidsHelper.findTeam(patientid); var size = persons.size(); var viewData = { list : persons, src : serverKey }; cocoon.releaseComponent(pidsHelper); cocoon.sendPage(TEAM_FORM_DISPLAY, viewData); } // showTeam function prot_modifyTeam() { var errMsg = "Not yet implemented!"; internal_showErrorPage(errMsg); } // modifyTeam function internal_showAllPersons(serverKey, sort1, sort2) { var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var persons = pidsHelper.getAllPersons(serverKey, sort1, sort2); var size = persons.size(); var viewData = { list : persons, src : serverKey }; cocoon.releaseComponent(pidsHelper); cocoon.sendPage(ALL_PERSONS_FORM_DISPLAY, viewData); } // showAllPersons function internal_addPerson(serverKey) { // TODO make sure it works properly when the function is ended by the user before it is finished // to avoid memory leaks of unreleased objects floating around. var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var person = pidsHelper.getNewPerson(); // set the country of the address default to Nederland person.getTraits().get("address").getValues().get("country").setValue("Neder land"); if (serverKey == PATIENT_SERVER) { var form = new Form(PATIENT_FORMDEF); } else { var form = new Form(PROVIDER_FORMDEF); } form.createBinding(PERSON_FORMBIND); var success = false; var errMsg = ""; var count = 0; // to prevent endless loops while(!success && count < 10) { try { form.load(person); print("going to display the input form"); var viewData = { errMsg : errMsg, src : serverKey, action : "add" }; form.showForm(ADD_EDIT_PERSON_FORM_DISPLAY, viewData); print("about to save the info"); form.save(person); var ids = pidsHelper.storeNewPerson(serverKey, person); var id = ids[0]; for (var i in ids) { print("ids found: " + i); } success = true; } catch(error) { errMsg = "other error: " + error; print(errMsg); success = false; } count++; } cocoon.releaseComponent(pidsHelper); internal_prepareShowDetails(success, serverKey, id); } // addPerson function internal_editPerson(serverKey, id) { var pidsHelper = cocoon.getComponent(Packages.nl.unimaas.mi.proper.cocoon.PIDSHelper.ROLE); var person = pidsHelper.findIdentity(serverKey, id); if (serverKey == PATIENT_SERVER) { var form = new Form(PATIENT_FORMDEF); } else { var form = new Form(PROVIDER_FORMDEF); } form.createBinding(PERSON_FORMBIND); var success = false; var errMsg = ""; var count = 0; // to prevent endless loops while(!success && count < 10) { try { form.load(person); var viewData = { errMsg : errMsg, src : serverKey, action : "edit" }; form.showForm(ADD_EDIT_PERSON_FORM_DISPLAY, viewData); form.save(person); success = pidsHelper.updatePerson(serverKey, person); } catch(error) { errMsg = "Er is een fout opgetreden: " + error; print(errMsg); success = false; } count++; } cocoon.releaseComponent(pidsHelper); internal_prepareShowDetails(success, serverKey, id); } // editPerson function internal_prepareResult(list, key) { var size = list.size(); var viewData = { list : list, nr : size }; cocoon.session.setAttribute("personsFound", list); cocoon.session.setAttribute("key", key); cocoon.sendPage(SHOW_RESULT); } // showResult function internal_prepareShowDetails(success, serverKey, id) { if(success) { if (serverKey == PATIENT_SERVER) { var url = SHOW_DETAILS_PATIENT + "?findId=" + id; } else { var url = SHOW_DETAILS_PRACTITIONER + "?findId=" + id; } print("sending to: " + url); cocoon.sendPage(url); } else { internal_showErrorPage(errMsg); } } //showDetails function internal_showErrorPage(error) { cocoon.session.setAttribute("errMsg", error); cocoon.redirectTo(ERROR_FORM_DISPLAY); } // showErrorPage [4] authentication.xml <?xml version="1.0" encoding="UTF-8"?> <authentication xmlns:session="http://apache.org/cocoon/session/1.0" > <session:getxml context="authentication" path="/"/> </authentication> > -----Original Message----- > From: Antonio Gallardo [mailto:[EMAIL PROTECTED] > Sent: Thursday, 13 May 2004 15:21 > To: [EMAIL PROTECTED] > Subject: RE: Problem with losing session context > 'authentication' - looking fo r workaround or bugfix > > > Hi Helma: > > > > [EMAIL PROTECTED] dijo: > >> > Setup: > >> > - default Cocoon root sitemap with automounted subsitemap of my > >> > app. > > Hmm. Maybe here is the problem. Can you provide the > sitemap.xmap of configured auth-fw? > > >> > - authentication-fw setup like the sample with the > >> flowscripts (auth.js). > >> > Works. > >> > - all "public" urls go through the "protect" function to > >> their "internal" > >> > counterpart. > >> > - all internal/*.html urls go to an appropriate > javascript function > >> > - all internal/*.form urls generate a form: > >> > > >> > <map:match pattern="**/internal/*.form"> > >> > <map:generate type="jx" src="content/{2}Template.jx"/> > >> > <map:transform type="cinclude"/> > >> > <map:transform type="forms"/> > >> > <map:transform > >> src="stylesheets/resources/forms-samples-styling.xsl"> > >> > <map:parameter name="uri" value="stylesheets/resources"/> > >> > </map:transform> > >> > <map:call resource="html-layout"/> > >> > <map:serialize type="xml"/> > >> > </map:match> > >> > > >> > - one of the cincludes is getUser: > >> > <map:match pattern="getUser"> > >> > <map:generate src="system/authentication.xml"/> > >> > <!-- this is <session:getxml context="authentication" > >> path="/"/> --> > >> > <map:transform type="session"/> > >> > <map:serialize type="xml"/> > >> > </map:match> > > I will try to find/debug the problem in the above match too. > > >> > Function doSomething() { > >> > var obj = getObject(); > >> > form.load(obj); > >> > form.showForm("internal/someForm.form"); > >> > form.save(obj); > >> > storeObject(obj); > >> cocoon.sendPage("internal/anotherForm.html"); <-- > >> > ERROR!! } > > What kind of Object the getObject() retrieve? It is related > to sessions? > > >> > The last line throws an exception which boils down to > "cannot find > >> > 'authetication' context". I'm fairly sure the exception > originates > >> > from the sessionTransformer. > > It could be. I think we need to review it. > > >> > I have to rewrite it to > cocoon.sendPage("public/anotherForm.html"). > >> > > >> > This works in simple cases, but when I add bizData they > get lost in > >> > the process. I.e.: > > It is weird. > > >> > > >> > Function doSomething() { > >> > var obj = getObject(); > >> > form.load(obj); > >> > form.showForm("internal/someForm.form"); > >> > form.save(obj); > >> > storeObject(obj); > >> > var bizData = { object: obj} > >> > cocoon.sendPage("public/anotherForm.html", bizData); <-- > bizData is > >> > lost!! } > >> > > >> > To make things even worse: > >> > > >> > I log in successfully and my first redirected page shows. > >> Everything > >> > ok. I now click on a menu item (-> > >> public/doSomething.html). The forms > >> > shows ok, but when I press submit I get the authentication error > >> > again. When studying what happens it looks like a second > thread is > >> > started (i.e. the function is executed twice) and the error > >> seems to occur when the second thread tries to display the form. > >> > > > Best Regards, > > Antonio Gallardo > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]