Hello,
I creating an application (something like orbeon forms with users). And want that in table will be showed only forms which was created by user (myName). In a form data I can add user name... But how I can get forms from database that was created only by user (myName)? Maybe someone can show code example? |
Administrator
|
And is this using Form Builder / Form Runner, or with a form you wrote "by hand" in XForms? Alex |
This is modification of Orbeon Government Forms example.
|
In reply to this post by gunmanas
I think when you save the Data into that DB, you logged in into your application as a specific user.
So you need to store the user information, too, so that you can use it as a filter. Do method do you use for the users to login`? > -----Ursprüngliche Nachricht----- > Von: "gunmanas" <[hidden email]> > Gesendet: 05.05.09 09:02:09 > An: [hidden email] > Betreff: [ops-users] get records from database > > Hello, > > I creating an application (something like orbeon forms with users). > And want that in table will be showed only forms which was created by user > (myName). > > In a form data I can add user name... But how I can get forms from database > that was created only by user (myName)? Maybe someone can show code example? > -- > View this message in context: http://www.nabble.com/get-records-from-database-tp23382005p23382005.html > Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.com. > > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Exactly. In XPath within XForms, you can get the login for the current user with xxforms:get-remote-user(). When the form is created, you can store it in the instance (<xforms:setvalue> on xforms-model-construct-done) and then in your summary page you need to pass that the current user ID to the code that queries the database and change this code to only return data for that specified user. Over time, this will be build right into Form Runner. Alex |
Thanks for yours answers :)
So... How I can get all forms from database with value ./info/Name ='John'? At first I want try with static value and write the code: let $collection-name :=collection('/db/orbeon/forms/Forma1/')//form[./info/Name ='John'] let $search := normalize-space(request:get-parameter('search', '')) for $resource-name in xmldb:get-child-resources($collection-name) let $resource-date := xmldb:last-modified($collection-name, $resource-name) let $resource := doc(concat($collection-name, $resource-name)) where $search = '' or text:match-any($resource, $search) order by $resource-date descending return ...... But in forms table I dont get any forms, maybe this code is wrong? |
Administrator
|
Starting with a static value is the right way to go. A few hints that might help: * If your instance doesn't get updated, check the orbeon.log, as an error might have happened during the submission. * Also you can use the XForms inspector to see the instance update "live" in your browser. * You can also try your XQuery directly in the eXist client, if you are debugging XQuery. * Finally, for questions regarding XQuery in eXist, the folks on the exist-open list should be able to help you (http://www.nabble.com/exist-open-f4073.html). I hope this helps, Alex |
Free forum by Nabble | Edit this page |