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

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.

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

Xquery to map the value of a specific name attribute

I am trying to create an xquery in jdeveloper . I am stuck at a small portion of it. It would be great if I get some suggestions.
Below is the part I am stuck at
The request is:
`<variables>
<variable name="StartTime" value="01:00:00"/>
<variable name= "EndTime" value="05:00:00"/>
The response I want to map is a single element with two values looks like below:
<ns2:time ns2:startTime="01:00:00" ns2:endTime="05:00:00"/>
Below is the xquery I tried. But I get only the start time at both places. I want some way by which I can correctly assign the values looking at the name value in the request.
if (fn:data($Prefereces/ns1:variables/ns1:variable/#name="StartTime")or fn:data($Prefereces/ns1:variables/ns1:variable/#name="EndTime")) then
( <ns2:time ns2:startTime="{fn:data($Prefereces/ns1:variables/ns1:variable/#value)}" ns2:endTime="{fn:data($Prefereces/ns1:variables/ns1:variable/#value)}">
</ns2:time>)
else
()
Thanks in advance.
You can use this :
<ns2:time ns2:startTime="{fn:data($Prefereces/variables/variable[#name = 'StartTime']/#value)}" ns2:endTime="{fn:data($Prefereces/variables/variable[#name = 'EndTime']/#value)}"/>
Note that the ns2 prefix has to be defined beforehand.
XQuery's predicates are specified using brackets ([condition]), which were missing from your tries.

Set value of output inside control in repeatable section

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" ...>

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)

jasper grails parameters

I have a Jasper report which accepts an Integer parameter.
I am using the <g:jasperReport> tag to call the report. The body of this tag has an HTML <input> whose value gets passed to the report.
The report is not working. It is giving an InvalidFormatException.
Please help.
Thanks in advance.
Abe
I found that defining the passed-in parameter as a String works even in the SQL; i.e., in the .jrxml:
<parameter name="headerid" class="java.lang.String">
<parameterDescription><![CDATA[ID this report is for]]></parameterDescription>
<defaultValueExpression><![CDATA['1']]></defaultValueExpression>
</parameter>
Use it in the SQL as you would an Integer; i.e.:
where header.id = $P{headerid}

Resources