Avoiding multiple executions in xforms-enabled - orbeon

I am trying to launch a javascript for adding extra functionality to a form run. The script must be launch when the form is loaded.
The idea is:
<xxf:script ev:event="xforms-enabled">
alert('hello world');
</xxf:script>
The problem is, as described at the Orbeon Forum, the "xforms-enabled" event is launched several times (for each control and variable). In the forum is described some workarounds and solutions, but cannot be applied when using javascript (or I do not know how to do it).
The question is: how can I execute the javascript code only one time when starting the form? Must I use another event?

The best would be to run your script on xforms-ready, which is dispatched to the model. So you would put, inside your <xf:model>:
<xxf:script ev:event="xforms-ready">...</xxf:script>

Related

Passing variables to Camunda subprocess

I'm trying to model a document workflow using Camunda 7.12. One of the requirements is that the user can define a due date for the whole process, and the system must send a remainder a couple of days before that deadline.
I was suggested to define a subprocess with a timer event that triggers when the date selected by the user in the start form is reached.
So, I defined the following subprocess in the model:
The timer event has the following properties:
The due_date variable is entered by the user in a form when the he starts the process, but I don't know how I can pass it (or if it's even possible) to the remainder subprocess.
Any ideas? Or alternatives on how it could be done?
Thanks in advance,
I found a solution that doesn't involve big changes in the model. Simply, I set the process start event as Asynchronous Before. Now, the timer start event can get the due date value and launch the remainder task as expected.
Cheers,
A related issue was fixed in
https://jira.camunda.com/browse/CAM-9303
and the related unit test
(https://github.com/camunda/camunda-bpm-platform/blob/33601f3026341882afae321611dfe4e8dfd31d2c/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/event/timer/StartTimerEventTest.java#L1351-L1446)
passes on camunda 7.12 and also on the #SpringBootTest I created.
However, I saw the same issue when testing manually via tasklist using this process:
https://cawemo.com/share/6bf324bb-4002-490c-8739-7ca94803acc0
Tasklist uses an API which differs from the call used in the tests.
Possible workarounds I see:
a) Wrap API used in test runtimeService().createProcessInstanceByKey(...) with own REST service and start via this endpoint.
b) Change process model and move process into embedded sub process, then attach intermediated timer event to it. This creates the variable before the event is registered. Example here:
https://cawemo.com/share/870694cf-b704-42c2-b0d7-a2637406d356
A new JIRA ticket for this issue in the context of form variables has beenc reated here: https://jira.camunda.com/browse/CAM-11357

How to efficiently render a dynamic list of subelements in Vaadin

Given a Vaadin application where a user can add and remove elements of a list that is also rendered in the browser, I am wondering what the most efficient way of handling such manipulations would be. Currently, I am simply using the add and remove methods.
I am only experienced with Apache Wicket where one should avoid to manipulate the component tree for performance reasons. In the documentation, I only found a section on how to handle repeated elements in Polymer but nothing on how this can be done using the "simple" API.
Am I choosing the right approach?
The Vaadin UI code runs on the server, so the add/remove operations don't affect the DOM directly. When a response is sent back to the browser, Vaadin will look at the difference between the previous UI state and the current and send appropriate instructions to the browser client to update the DOM. In this case, the instruction would be something like "remove the following components:...". The actual DOM manipulation is handled by Vaadin, and is not something you can affect yourself.
If you run into performance issues, help us out by filing an issue ticket on GitHub, so we can take a look at it https://github.com/vaadin/flow/issues

Gatling/JMeter record scenario incompletely

I've been using JMeter and Gatling to record a scenario on a JSF2 PrimeFaces 4 web app, in order to load test it. The recording goes well with both tools, but the replay of the scenario fails because a click action on a commandButton opening a popup dialog doesn't fire the associated event. Said commandButton gets enabled by the previous action in the scenario (a dropDown selection in the same table row).
That issue happens only when running the scenario on the performance testing tools, not when navigating in the browser UI.
I've compared the arguments of the POST requests picked up by Firebug and Gatling/JMeter, and they seem completely identical (management of the JSF ViewState is correctly set up btw). I've also increased the pauses between actions during the scenario, but to no avail.
Any ideas on what the recorders and/or I could be missing?
Thanks in advance.
Neither Gatling nor JMeter executes javascript, so if you have some javascript logic, you'll have to re-implement it.
#Cleverback I've got some examples with Primefaces and Gatling here: https://github.com/rmpestano/gatling-jsf-demo and also there is an example of JSF event.
Can you create or describe your case as a test case on that project?

How to run a command when clicking submit button (lua)?

i want to use lua to generate cgi-webpages with uhttpd. What's the correct way to execute a shell command when a button (submit form), or a link is clicked?
Thanks
If you are asking for the specifics of what form the HTML would take and the server side scripts in order to do what you want, then your question is way too broad. If you're just wondering about the Lua side of running shell command:
The HTTP GET (link click) or POST (form) would cause one of your Lua functions to get called, wherein you would call os.execute('your-command'). However, due to the obvious security risk associated with calling os.execute, some environments that embed Lua disable certain calls. I don't know anything about the Lua modules allowed by uhttpd. With some luck, it supports the call, and it's up to you to make the proper checks if you want to use it.

Showing status of current request by AJAX

I'm trying to develop an application which modifies a couple of tasks of the famous Online-TODO List RememberTheMilk (rememberthemilk.com) using the REST API.
Unfortunately the modifying takes a lot of time, so I want to give a feedback to the users.
My idea was just to display a couple of text lines (e.g. modifying task 1 of n...).
Therefore I used the periodically_call_remote on my page and called a which reads a Singleton.
In the request I store the text that should be displayed in the same singleton. But I found out, that once I set up a request, the periodically_call_remote does not update the specified div.
My question to this:
1. is this a good way to implement this behaviour?
2. if it is, how do get the periodically_call_remote to work during a submit?
Using a Singleton is most definitely a bad idea. In an advanced production setup it isn't guaranteed that subsequent requests will go to the same process or to the same machine (and subsequently will have a different Singleton). Plus, if you have many users, I don't even want to think about what'll happen to those poor Singletons.
Does any of this stuff actually need to go through your Rails app? It seems like you can call the RTM API via Javascript from the page the user is on and then update the page when the XHR request is complete.

Resources