Set value of output inside control in repeatable section - orbeon

I have my own control, which has model with action which is executing when form is loaded:
<xf:model>
<xf:action ... >
<xf:setvalue ref="???" value="some_value"/>
</xf:action>
</xh:model>
I put this control to my xforms file to the repeatable section:
<section-3>
<section-3-iteration>
<my-control/>
<output-control/>
</section-3-iteration>
<section-3-iteration>
<my-control/>
<output-control/>
</section-3-iteration>
</section-3>
Now I want to reference to the output control from my control, I mean I want to set output-control value inside control. What should I write to ref attribute in setvalue in my control?
I tried to put there: ref="../output-control", but it doesn't work. When I write: ref="xxf:instance('fr-form-instance')//*[name() = 'output-control']" it set value od output-control only in first iteration.
regards

It's a bit dangerous because it violates encapsulation. But if you really need to, try:
ref="xxf:binding('my-binding')/../output-control"
where my-binding refers to your custom control's id attribute on xbl:binding:
<xbl:binding id="my-binding" xxbl:mode="binding" ...>

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

sysproperty set to value "${value}" when no property is passed to target

I am executing a target with paramters as Dcolor=red.I am using this property value to set system property as
<sysproperty key="COLOR" value="${color}" />
If not passing any parameter named -Dcolor, when fetching key COLOR as System.getProperty("COLOR") is returning ${color}.
Is this correct behavior. How to handle such scenario ie. setting COLOR as null if no parameter names color is passed.
Please let me know if I am missing basics here. Resource link will be helpfull
That's crazy, the evaluation of the properties is done by the PropertyHelper class of the ant. But based on the source code, the returned value should be null, but it's not.
The documentation says the ant tries to evaluate it, but it doesn't state what happens if the evalutation is unsuccessful.
You can set a default value by predefining the property.
<property name="COLOR" value="defaultColor" />
But this will never set value null.
And finally after a long search, I found out that using syspropertyset instead of sysproperty, will return nulls.
This is a working example:
<propertyset id="java.props">
<propertyref name="test.property"/>
</propertyset>
<java>
<syspropertyset refid="java.props"/>
</java>
If you get the test.property, it will return null.

Use read-only xf:input as xf:output in Orbeon?

Can i use a read-only xf:input act like xf:output in Orbeon?
How to set the value of a readonly input field?
simpler code sample:
<xf:input ref="//Some/Elements/TotalCredit"
value="round(($quantity) * ($creditPerUnit))">
</xf:input >
<xf:output ref="//Some/Elements/TotalCredit"
value="round(($quantity) * ($creditPerUnit))"/>
In the above code the xf:input shows only the initial value from the model!
It doesn't update!
But xf:output value is updated as expected!
So, how can set xf:input's value like xf:output?
I don't want to use calculation in bind.
In your example, you have an xf:input with both a ref and a value; I am not sure what you expect this to do, or if that makes sense, but for sure it currently won't work:
With the xf:output, you can have both a ref and a value, where the node pointed by ref can influence whether the xf:output is shown and the value gives it its value.
If you want to do the same with an xf:input, it can put the result of your calculation in the ref (in your case round(($quantity) * ($creditPerUnit))). If that expression returns an atomic value, then the input field will be readonly, which I think should take care of your situation.
This is how i made it, considering this and this posts.
//First Input
<xf:input ref="//Some/Elements/PreviousInputCreditPerUnit">
<xf:action ev:event="xforms-enabled xxforms-iteration-moved xforms-value-changed">
<xf:setvalue
ref="//Some/Elements/ReadOnlyInputIK"
value="round(($quantity) * ($creditPerUnit))"/>
</xf:action>
</xf:input>
//Second input
<xf:input ref="//Some/Elements/PreviousInputQuantity">
<xf:action ev:event="xforms-value-changed">
<xf:setvalue
ref="//Some/Elements/ReadOnlyInputIK"
value="round(($quantity) * ($creditPerUnit))"/>
</xf:action>
</xf:input>
//Third ReadOnly Input (acts like xf:output)
<xf:input ref="//Some/Elements/ReadOnlyInput">
</xf:input>
Note the action event in the first column of my repeated row:
ev:event="xforms-enabled xxforms-iteration-moved xforms-value-changed"
See this example from Orbeon.

multiple expressions for single condition result

I have to change the header string of primefaces dialog, acording to a variable state in my backing bean. The condition would be the following (pseudo code):
#{backingBean.editing ? resourceBundle.edit_string resourceBundle.item.id : msg.add_string}
and the short snippet example:
<p:dialog id="dokDialog" header="#{backingBean.editing ? resourceBundle.edit_string resourceBundle.item.id : msg.add_string}" ...>
<!-- content -->
</p:dialog>
In this example I want to display either value #{msg.edit_string} #{resourceBundle.item.id} or #{msg.add_string} according to boolean value of #{backingBean.editing}.
What I want to do is to show either Editing Item 01 or New Item in the title.
Also I get the following exeption because I have two expressions (resourceBundle.edit_string resourceBundle.item.id) for one result:
Caused by: org.apache.el.parser.ParseException: Encountered " <IDENTIFIER>
Thanks!
resourceBundle.edit_string resourceBundle.item.id - it's a wrong expression. You need to concatenate
String.concat may help if you are using an appropriate version of EL: resourceBundle.edit_string.concat(' ').concat(resourceBundle.item.id)

Orbeon : how to set the href of a <xhtml:a> tag, based on the current node in a <xforms:repeat>?

I'm trying to set a href attribute of a tag, based on the value of a leaf of the current node in a xforms:repeat. I've tried different syntax, but can't make it work. This is my last try (with a xforms:var). NOTE : the iteration and the list are ok, just the href is not (null pointer exception).
<xforms:repeat id="sous_menu_branches" nodeset="./Branches/Branche">
<xhtml:li>
<xforms:var name="brancheId" value="./BrancheId"/>
<xhtml:a href="/notes-saisie/?brancheId={$brancheId}">
<xforms:output ref="Nom" mediatype="text/html"/>
</xhtml:a>
</xhtml:li>
</xforms:repeat>
Actually, when I try to use xforms:var in my view (view.xsl), I always got a java null pointer error. As example, in the code snippet bellow, the first xforms:output throw an exception, but not the second one (which is supposed to access the same value) :
<xforms:repeat id="sous_menu_branches" nodeset="./Branches/Branche">
<xhtml:li>
<xforms:var name="current-item" value="."/>
<xforms:output id="my-count" ref="$current-item/Nom"/>
<xhtml:a href="/notes-saisie/?brancheId=888">
<xforms:output ref="./Nom" mediatype="text/html"/>
</xhtml:a>
</xhtml:li>
</xforms:repeat>
Can anybody tell me what am I doing wrong ? Thanks in advance !
You don't say which version of Orbeon Forms you are using, but I suspect you are using one which doesn't yet support xforms:var. Try using xxforms:variable instead.

Resources