How often will calculate works in Orbeon Xforms - orbeon

I have a bind definition as follows:
<xforms:bind nodeset="instance('demo')/pointer"
type="xforms:integer"
calculate="
if($current-page < '2') then '0'
else (
if($current-page > '2')
then ($max-pages - 1)
else .
)"/>
For every user click on the form, the current-page value changes. I wanted to understand how often does the calculate in the above the bind defnition execute?
The problem is that the pointer variable and current-page are dependent on each other, so if I click on something first, the value of pointer should be evaluated immediately and in the next instruction I have to set the current-page value based on the pointer value that is changed. On the click, the code will be as below:
<xforms:setvalue ref="$pointer"
value="($pointer + 1)"/>
<!-- i am assuming if the current-page is 2,
it will increment, else the value is set as per calculate -->
<xforms:setvalue ref="$current-page"
value="($current-page + 1)"
xxforms:if="($pointer = $max-pages)" />

When users click on the button (assuming it is a button) that trigger the two xforms:setvalue, those xforms:setvalue run first and the xforms:bind calculate runs later.
Pretty much all users' interaction with the form will cause the xforms:bind calculate to be be reevaluated.

Related

value changed in nested child flow not reflected in main parent flow (MULE 4)

I have declared a variable var2 outside foreach loop.
Usecase:
before 1st iteration value of var2="abc"
after first iteration var2="bcd"
I want second iteration to use value as "bcd" but second iteration is using the value "abc".
Please suggest a solution for my usecase.
UPDATE
The issue is not due to foreach.
I have 3 flows
flow1--> flow2(childofflow1)--> flow3(childofflow2)
I defined variable vars.var2 in flow1 --> updated it in flow3 --> updated value reflected in flow2 --> updated value doesn't reflect in flow1
value in flow1 = a
value in flow2 = a
value updated in flow3 to b
value reflected in flow2 = b
value reflected in flow1 = a
The foreach scope actually preserves the values of variables from the previous iteration and that is documented behavior: https://docs.mulesoft.com/mule-runtime/4.3/for-each-scope-concept#variable-propagation
Perhaps your flow is overwriting the value.
Example:
<set-variable value='abc' doc:name="Set Variable" variableName="var2"/>
<set-payload value="#[[1,2,3]]"/>
<foreach doc:name="For Each" >
<set-variable value='#[vars.var2 ++ "def"]' doc:name="Set Variable" variableName="var2"/>
<logger level="INFO" doc:name="Logger" message="Iteration #[vars.counter] value vars2: #[vars.var2]"/>
</foreach>
<logger level="INFO" doc:name="Logger" message="final value #[ vars.var2]"/>
Output log:
Iteration 1 value vars2: abcdef
Iteration 2 value vars2: abcdefdef
Iteration 3 value vars2: abcdefdefdef
final value abcdefdefdef
I had set target variable for flow 2 that's why any change to payload/variables was not reflected in flow1.
Setting the target variable in a Flow Reference component causes the original message to remain unchanged. This means that any modification to the payload or to the variables that occur in the referenced flow revert after the referenced flow finishes executing its processors, returning the payload and variables to their original values.
Alternatively, if you do not define a target variable, any modification that occurs to the payload or to the variables in the referenced flow persist after the referenced flow finishes its execution, changing the original value of the payload or variables.
Documentation for reference:
https://docs.mulesoft.com/mule-runtime/4.3/flowref-about

Call the name of a Texbox with number changing in Visual Basic 6

I'm use Visual Basic 6 to create a table with many Textbox which named txtNo1, txtNo2, txtNo3,...
I want to use the "For...Next..." loop to assign a content to these Textbox.
How can I call all these Textbox in the simplest way?
For i = 1 to 100
txtNo (......) .txt = "ABC"
Next i
Instead of using unique textboxes, each with a unique name, you should use a (textbox) control array:
Place the 1st textbox on the form, name it 'txtNo'
Copy it and paste it onto the form
VB will ask you "There's already a control named 'txtNo'. Would you like to create a control array?". Answer "Yes"
Paste as the textbox as many times as you need it
Then your code looks like
' Control arrays typically start at index 0
For i = 0 to 100
txtNo(i) .txt = "ABC"
Next i
Jim Mack's solution works as well, code for it:
' Assuming your form is named 'Form1'
For each ctrl in Form1.Controls
If TypeOf ctrl Is Textbox
For i = 1 To 100
If ctrl.Name = "txtNo" & CStr(i) Then
ctrl.Text = "ABC"
End If
End If
End If
It's a bit more complex, but therefore more flexible as works with multiple control types (in one loop).
If you need an easiest way to create your textboxes as a table, you can Load the controls at runtime. You have to add only the first TextBox control to your form, set the name to "txtNo", and Index to 0 in the Properties window.
In your code, call Load() to create additional controls, and you can set the Top/Left and other properties
For i = 1 To 100
Load txtNo(i)
txtNo(i).Top = txtNo(i - 1).Top + txtNo(i - 1).Height + 150
txtNo(i).Left = txtNo(i - 1).Left
txtNo(i).Text = "Textbox " & i
txtNo(i).Visible = True
Next i
If you need again to change any control property, from your list of controls, you can iterate only over your control list, instead of all controls of your Form
For i = txtNo.LBound() To txtNo.UBound()
Form1.Controls("txtNo")(i).Text = "New text " & i
Next i

Strange behaviour with xxf:format attribute in my Xforms form (using Orbeon Form Runner)

I have a numeric input field in my form. I just add some format on it with xxf:format :
<xf:input
id="input-control"
bind="input-bind"
class="question nombre"
xxf:format="if (. castable as xs:integer)
then replace(format-number(xs:integer(.),'###,###,###,###,###,###,###,###,###,##0'),',',' ')
else ''">
This may look a bit wild but it's just a format where number 123456 will be presented as 123 456. This works great for me, but not for users...
So now, I added a script to cancel formatting when input is focused (aka : go back to 123456 when editing the field) with a simple js :
<xf:action ev:event="DOMFocusIn">
<xxf:script>
var input = this.getElementsByTagName('input')[0];
var valeur = input.value.replace(' ','');
input.value = valeur;
</xxf:script>
</xf:action>
Behaviour looks ok at first sight, I mean, I entered 123456, focus out and got 123 456 (format ok), focus in and got 123456 (script behaviour ok). But if I don't make any changes on the field and focus out, I don't have the format back (still 123456 instead of 123 456).
I understand that the format is only applied when "needed" and "needed" means here, when the value of the input changes. But if I force an xforms-value-change event I still don't have the format back.
Anyone has an idea on how to achieve this ?
(anyone has understood anything ? :-s)
This can be tricky to get right. I would recommend using instead the fr:number control, which does all of this for you.

Setting returned text to open an app in applescript

I have a apple script program that I am programming and I want the text the user sends to open an application, But I keep getting error messages saying "Can't get application {"name_of_app"} of <>. The code I very simple and I cant figure out the problem
set deReturnedItems to (display dialog "How many spam messages?" with icon stop default answer "" buttons {"Quit", "OK"} default button 2)
set xpp to text returned of deReturnedItems
set theReturnedItems to (display dialog "How many spam messages?" with icon stop default answer "" buttons {"Quit", "OK"} default button 2)
set amt to the text returned of theReturnedItems
set daReturnedItems to (display dialog "Last thing, what should the spam message say?" default answer "" buttons {"Quit", "OK"} default button 2)
set msg to the text returned of daReturnedItems
repeat [amt] times
tell application [xpp]
activate
tell application "System Events"
keystroke [msg]
keystroke return
end tell
end tell
end repeat
Get rid of those square brackets. Don't use them for variables. Use underscores before and after if you must, like:
repeat _amt_ times
…
end
Also, you need to check to make sure your variable is an integer before you use it in the repeat block.
Incidentally, when you set a variable and then include it in brackets, that's applescript syntax for set the string to a list. For example:
set [x, y, z] to "123"
return x
-- returns "1", and y is set to "2", and z is set to "3"

How to keep TYPO3's RTE from adding an empty line before <ul>s

In TYPO3 4.5 as well as 6.1, whenever I add an unordered list element, RTEhtmlarera (or some of its many processing routines) will add an extra
<p> </p>
before the ul tag on saving the content element.
This happens only once, when the ul is inserted first. When the p tag is removed and the content element is saved again, it won't happen again.
How can this erroneous behaviour be removed?
Hi try set encapsLines to zero..
Setup typoscript:
tt_content.stdWrap.dataWrap >
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines >
Not a real solution but maybe a hint in the right direction.
If you write down your list, do not press enter before the first list entry but shift+enter.
Example:
Here comes the list: <<-- AT THIS POINT PRESS SHIFT+ENTER
- a <<-- Here it does not matter if you press enter or shift+enter
- b
- c
- ...
This works for me as a workaround. I've done a lot of research in sysext:rtehtmlarea but nothing worked. So this looks for me like some kind of mysterious bug/feature connected with the "BR to P" (or vice versa) configuration you can define in pageTS or Setup. BTW: I never fully understood this conversion-thing :)
For me with 6.1 this worked:
lib.parseFunc_RTE {
externalBlocks = table, blockquote, ol, ul, div, dl, address, hr
externalBlocks {
ol.stripNL=1
ol.stdWrap.parseFunc = < lib.parseFunc
ul.stripNL=1
ul.stdWrap.parseFunc = < lib.parseFunc
# i have also seen this setting, but didn´t test it:
# blockquote.stripNLprev = 1
# blockquote.stripNLnext = 1
}
}
I removed many lines for this example, be aware that you overwrite previous settings by using {} ..

Resources