|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
how to use redirect-to() with xformsI'm trying to build an application with only XForms and XQueries. I store both the XForms and XQueries in eXist. It works great for storing data etc. I use FireFox as my XForms client.
Now I'm trying to build in some (simple) redirect logic. For example if a user login is succesfull, go to a certain page. I can get the redirect-to() to work when I embed my html in the xquery (i.e. the xquery produces html and does not use xforms), but not when my xqueries usually produce xml to be send back to the xforms client. The below example does nothing (no errors that I can see in any log); I can't get the redirect to work using redirect-to() and I wonder if this could even work with XForms. Can anybody tell me how to make this work somehow? Thank you! This is my xform (I took out some display and formatting features): <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Login</title> <xf:model id="session"> <xf:instance id="session_instance"> <session xmlns=""> <user/> <pass/> <loginstatus/> </session> </xf:instance> <xf:submission id="login" ref="instance('session_instance')" action="http://localhost:8080/exist/rest/db/myapp/xquery/login.xq" method="post" replace="instance" instance="session_instance"> </xf:submission> </xf:model> </head> <body> <xf:group ref="instance('session_instance')"> <xf:input ref="user"> <xf:label>User Name:</xf:label> </xf:input> <br/> <xf:secret ref="pass"> <xf:label>Password: </xf:label> </xf:secret> <br/> <xf:submit submission="login"> <xf:label>Login</xf:label> </xf:submit> </xf:group> </body> </html> And this is my xquery: xquery version "1.0"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace session="http://exist-db.org/xquery/session"; let $collection := "/db/myapp" let $post-request := request:get-request-data() let $user := $post-request/user/text() let $pass := $post-request/pass/text() let $login := xmldb:login($collection, $user, $pass) return if ($login) then ( session:redirect-to(xs:anyURI("/exist/rest/db/myapp/xforms/project-ff.xhtml")) else <session xmlns=""> <user></user> <pass></pass> <loginstatus>failure</loginstatus> </session> |
| Free embeddable forum powered by Nabble | Forum Help |