Hi ,
i got a field in a form where i got a numeric value which represent a counter of the form data ( counter= counter +1, each time that a user try to open a new form data and try to save it )!. any idea of how to implement this ? and thanks |
Administrator
|
With Form Runner, or with your own load/save mechanism?
-Erik On Sun, Apr 8, 2012 at 4:58 PM, globe <[hidden email]> wrote: > Hi , > > > i got a field in a form where i got a numeric value which represent a > counter of the form data ( counter= counter +1, each time that a user try > to open a new form data and try to save it )!. any idea of how to implement > this ? > > and thanks > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/how-to-implement-a-counter-tp4541813p4541813.html > Sent from the Orbeon Forms (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 > -- 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 |
Hi Eric,
with form runner; in fact i want to do it threw a webservice ( that return a 'sequence' from the db depending on the form/app ), the only problem is how to retrieve the sequence from the webservice and load in the a field at the intialization of the form runner! , is there any example that show this manipulation ?. and thanks |
Administrator
|
Mmh, I don't think we have an example. But you can create an action
that runs upon form load, calls the service, and then as action result set the value of a hidden control (as just mentioned in a reply to another question). -Erik On Tue, Apr 10, 2012 at 2:52 AM, globe <[hidden email]> wrote: > Hi Eric, > > > with form runner; in fact i want to do it threw a webservice ( that return > a 'sequence' from the db depending on the form/app ), the only problem is > how to retrieve the sequence from the webservice and load in the a field at > the intialization of the form runner! , is there any example that show this > manipulation ?. > > > and thanks > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/how-to-implement-a-counter-tp4541813p4545086.html > Sent from the Orbeon Forms (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 > -- 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 |
This post was updated on .
Hi Globe
I don’t know if you got this working for you, but I thought I would share what I did for a similar situation: I wanted to add a counter to forms created for ~application-name/form-name Using Form Builder I created a new form definition ~application-name/counters. This had one section – Counter (name:counter) and two output controls: Form Name (form-name, include in summary) Last Number (last-number) In the form definition for the original form ~application-name/form-name: 2 Web Services: Service Name: get-counter Resource: /fr/service/persistence/crud/application-name/counters/data/form-name/data.xml Method: GET Serialization: XML Request Body: <request/> Service Name: update-counter Resource: /fr/service/persistence/crud/application-name/counters/data/form-name/data.xml Method: PUT Serialization: XML Request Body: <form> <counter> <form-name>form-name</form-name> <last-number/> </counter> </form> 1 Output Control: counter (or however you want to use the data) 2 Actions: Action Name: populate-counter Condition: Run on creation only React to: Form Load Service to call: get-counter Response Control: Destination: Counter, Source XPath: (/form/counter/last-number+1) Action Name: update-counter Condition: Run always React to: Value Change, Control: Counter Service to call: update-counter Service Request: Source: Counter, Destination XPath: /form/counter/last-number The only customisation required is to add the scenario for the first form data (last-number doesn’t exist). For this you need to edit the source of the form definition: Find the action definition <xf:action id="populate-counter-binding"> and add another action element as the last action: … <xf:action ev:event="xforms-submit-error" ev:observer="get-counter-submission" context="instance('fr-service-response-instance')"> <xf:action class="fr-set-control-value-action"> <xf:var name="control-name" value="'counter'" as="xs:string"/> <xf:var name="control-value" value="1" as="xs:string"/> <xf:setvalue ref="instance('fr-form-instance')/*/*[name() = $control-name]" value="$control-value"/> </xf:action> </xf:action> … replace the control-name value of counter with the Output control defined above. You don't really need to use Form Builder for the creation of the counter form definition, but doing it this way also means that you can view your counters at /fr/application-name/counters/summary and if you change the last-number to an input control you can restart your count easily using FR. This solution allocates a counter on form load, to allocate on form save change the listener on the populate-counter-binding action to: <xf:action ev:event="fr-data-save-prepare" ev:observer="fr-form-model" if="$fr-mode='new'"> <xf:send submission="get-counter-submission"/> Regards Jeremy |
First please excuse my ignorance but I'm totally new to this. This is my second day with orbeon (still learning). I created what I thought was a great looking form, only to be told I needed a counter on the form to issue upon printing out as a pdf. I'm working with the free version.
Anyway, I found what I believe is what I need below. The counter, but how do I insert this? Do I create a new formatted text control? or Do I edit source then put the code somewhere in there? or Do I put it in controls validation properties under Calculated Value? Again be gentle I'm very new at this, and basically have no idea what I'm doing except for the easy drag drop and clicking of this program. Thanks you for the help. Randy |
Administrator
|
Randy,
You don't need a formatted text control: that is to do things like bold, italics, etc. To clarify: what is the requirement of your counter? Where is the source of truth for that counter going to be? In a database? -Erik |
Although I would want it to go into the database as a unique ID. It is mostly to issue with the form (a permit with a unique number).
|
Administrator
|
I don't know if that would work for you, but each form already has an automatically generated UUID.
You could use the following as an initial value for an output field: xxf:instance('fr-parameters')/document That field will then hold the UUID generated by Form Runner. -Erik |
This post was updated on .
So, xxf:instance('fr-parameters')/document would give me a or the
UUID on the form? I tried pasting that into the initial value of a text output control and got nothing when I brought the new page of the form up? On Mon, Mar 24, 2014 at 1:14 PM, Erik Bruchez [via Orbeon Forms community mailing list] <ml-node+s24843n4658138h24@n4.nabble.com> wrote: > I don't know if that would work for you, but each form already has an > automatically generated UUID. > > You could use the following as an initial value for an output field: > > xxf:instance('fr-parameters')/document > > That field will then hold the UUID generated by Form Runner. > > -Erik > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > http://discuss.orbeon.com/how-to-implement-a-counter-tp4541813p4658138.html > To unsubscribe from how to implement a counter, click here<http://discuss.orbeon.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4541813&code=Y29tcGdlZUBnbWFpbC5jb218NDU0MTgxM3wxODc1MTY2NzM5> > . > NAML<http://discuss.orbeon.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > |
Administrator
|
There was a typo in Erik's answer. Instead, try (note the '-instance'):
xxf:instance('fr-parameters-instance')/document Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |