Flex: RemoteObject, passing named parameters - apache-flex

I'm calling ColdFusion cfc method using RemoteObject method of the Flex.
<fx:Declarations>
<s:RemoteObject destination="ColdFusion" source="cfc.categoryGateway" id="categoryGateway">
<s:method name="getCategoryList" result="returnHandler(event)"
fault="mx.controls.Alert.show(event.fault.faultString)">
<s:arguments>
<orderby>categoryId</orderby>
<parentCategory>1</parentCategory>
</s:arguments>
</s:method>
</s:RemoteObject>
</fx:Declarations>
Where as my cfc accepts the parameter in following manner:
<cffunction name="getCategoryList" access="remote" output="false" returntype="query">
<cfargument name="parentCategory" type="string" required="false" />
<cfargument name="orderby" type="string" required="false" />
<!--- code... --->
<cfreturn qCategoryList />
</cffunction>
So you can see that I changed the sequence of the parameter, when I call the cfc method. But it does not worked.
It means that <s:arguments> does not pass the named parameter.
Is there any solution for that? As you can see that I may have some of the arguments not mandatory so, it must be passed by name.

The arguments parameter is an array, so regardless of what you name each element, I think it will still use it in order.
You can try doing something like this instead:
<s:RemoteObject destination="ColdFusion" source="cfc.categoryGateway" id="categoryGateway">
<s:method name="getCategoryList" result="returnHandler(event)"
fault="mx.controls.Alert.show(event.fault.faultString)" />
</s:RemoteObject>
then call:
categoryGateway.getCategoryList({orderby:'categoryId', parentCategory:'1'});

Related

How to use the input/output elements in webflow?

I'm trying to understand how the input and output elements are used in webflow. The documentation suggests that flow input/output mapping is similar to calling a method with a signature, but I don't understand what passes the flow the input value or what the flow returns output to. How do I use these elements?
I've been reading the documentation found here, but there are no examples of the elements in action that I can find. This is an example from the documentation.
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow.xsd">
<input name="hotelId" />
<on-start>
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)"
result="flowScope.booking" />
</on-start>
<view-state id="enterBookingDetails">
<transition on="submit" to="reviewBooking" />
</view-state>
<view-state id="reviewBooking">
<transition on="confirm" to="bookingConfirmed" />
<transition on="revise" to="enterBookingDetails" />
<transition on="cancel" to="bookingCancelled" />
</view-state>
<end-state id="bookingConfirmed" />
<end-state id="bookingCancelled" />
In this code, where does the value assigned to "hotelId" come from? Does the input come from the URL? If so, does <input/> behavior change in subflows?
In this code, hotelId will be automatically mapped from the URL if you call /myFlow?hotelId=3 (assuming your flow is called "myFlow")
but you can also set the input directly when calling the flow from another flow, i.e. using:
<subflow-state id="mySubflow" subflow="myFlow">
<input name="hotelId" value="3"/>
</subflow-state>

Colon is not replaced by underscore in name of the property when passed to end-event script

I am trying to define workflow in Alfresco 4.2. I have a type defined as follows:
<type name="abc:start">
<parent>bpm:startTask</parent>
<associations>
<association name="abc:client">
<source>
<mandatory>true</mandatory>
<many>true</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</type>
This type is used start event of an workflow:
<config evaluator="string-compare" condition="activiti$sa05">
<forms>
<form>
<field-visibility>
<show id="packageItems" />
<show id="abc:client"/>
</field-visibility>
<appearance>
<set id="items" appearance="title" />
<set id="info" appearance="title" />
<field id="packageItems" set="items" />
<field id="abc:client" set="info" />
</appearance>
</form>
</forms>
In the event I have a very simple script (started at end of event), which uses this association:
logger.log("Starting workflow for: " + abc_client);
execution.setVariable("abc:client", abc_client);
When I start workflow for the first time, everything is ok. When I start it for the second time, I get the following error:
Failed to execute supplied script: 01240010 ReferenceError: "abc_client" is not defined. (AlfrescoJS#2)
I set a breakpoint in RhinoScriptProcessor and I was able to see that "abc:client" gets passed to script, rather then "abc_client". Why is it so? Why this isn't deterministic?
It turns out that the following line was problematic:
execution.setVariable("abc:client", abc_client);
Alfresco keeps an internal cache of two-way-mapping: qualified name <-> variable name. On first execution of workflow {abc namespace}client is mapped to abc_client. But then the above line gets executed and now {abc namespace}client is mapped to abc:client. As the result, on the next execution of the workflow abc:client is passed, rather then abc_client.

traversing a BPEL array

I need to traverse an array (input to BPEL) in java embed activity and need to generate a response (output variable) of BPEL process.
I am using Jdeveloper and SOA 11g
following is my xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/BPELInpuandOutPutArray_jws/Project1/BPEL_input_output_array" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="process">
<complexType>
<sequence>
<element name="simpleinput" type="string"/>
<element name="arrayofObjects" maxOccurs="unbounded" nillable="true">
<complexType>
<sequence>
<element name="input1" type="string"/>
<element name="input2" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="arrayofObjectsoutput" maxOccurs="unbounded" nillable="true">
<complexType>
<sequence>
<element name="output1" type="string"/>
<element name="output2" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
so far I am able to manage for traversing in input array
oracle.xml.parser.v2.XMLElement e1=
(oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:process/client:arrayofObjects[1]/client:input1");
System.out.println(e1.getFirstChild().getNodeValue());
But my business requirement is to based on some logic set the values in output array.
for this I used following sample code.
for(int i=1; i < 4 ;i++)
{
setVariableData("outputVariable","payload","/client:processResponse/client:arrayofObjectsoutput['i']/client:output1",i);
setVariableData("outputVariable","payload","/client:processResponse/client:arrayofObjectsoutput['i']/client:output2",i);
}
My feeling is array would be created of length 3 and value will be settes(1,1) (2,2) (3,3) but at the output value is only (3,3) .
please tell me how can i achieve the same.
sample code will be appreciated.
The way I did it for a similar situation was to use a transformation to create the first element and then use the bpelx:insertAfter to insert additional array elements and then set them.
<assign name="Assign_2">
<bpelx:insertAfter>
<bpelx:from variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput"/>
<bpelx:to variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput"/>
</bpelx:insertAfter>
<copy>
<from expression="'MyOutput1-Index2'"/>
<to variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput[2]/client:output1"/>
</copy>
<copy>
<from expression="'MyOutput2-Index2'"/>
<to variable="outputVariable" part="payload"
query="/client:ArrayManipulationProcessResponse/client:arrayofObjectsoutput[2]/client:output2"/>
</copy>
</assign>
If proprietary extensions do not work, you can try the standard BPEL approach and use an XSLT script to iteratively construct a result document.
An example is given in the BPEL 2.0 specification, pp 65, look for Iterative document construction.
Basically, the list and the element to add is passed (via the doXSLTransform XPath function) to an XSLT script, which copies the element to add to the list and returns the new document. This is then assigned to a variable.
I feel there is no need to write custom Java code for such a simple task. The following code (BPEL2.0) does the job of copying the values.<assign name="Copy values">
<extensionAssignOperation>
<bpelx:copyList>
<bpelx:from>$inputVariable.payload/ns1:arrayofObjects</bpelx:from>
<bpelx:to>$outputVariable.payload/ns1:arrayofObjectsoutput</bpelx:to>
</bpelx:copyList>
</extensionAssignOperation>
</assign>

Can CFHEADER values be read by other code?

The code
<cfheader name="Test" value="1">
<cfheader name="Test" value="2">
results in the header "Test: 2" being sent to the browser (as seen using HttpFox).
Is there a way for the second line of code to determine if a header with the same name has already been written using CFHEADER?
Thanks!
What version of ColdFusion are you using? When I run your code on ColdFusion 9, I get the header value (As seen using FireBug):
test: 1, 2
As for whether or not you can tell what, if any, existing values there might be for the response header, I haven't yet found a way. I'll keep looking, though.
Update: Found it.
getPageContext().getResponse().containsHeader("test")
For example:
<cfif getPageContext().getResponse().containsHeader("test") eq "NO">
<cfheader name="test" value="2" />
</cfif>
Can't help with exact task of checking the headers, but I'd tried to implement the header facade to handle the headers sending and tracking the history of alredy processed items.
It can be as simple as UDF wrapper, like this one:
<!--- this should be somewhere on request start --->
<cfset request.headers = {} />
<!--- wrapper for cfheader --->
<cffunction name="SendHeader" returntype="void" output="false">
<cfargument name="name" type="string" required="true" hint="Header name">
<cfargument name="value" type="string" required="true" hint="Header value">
<cfif NOT StructKeyExists(request.headers, arguments.name)>
<cfset request.headers[arguments.name] = arguments.value />
<cfheader name="#arguments.name#" value="#arguments.value#" />
</cfif>
</cffunction>

How to do this XML declaration in Flex4

I have a dataProvider that's defined with mx:XML like this.
<mx:dataProvider>
<mx:XML format="e4x">
<root label="All Items">
<morning label="Evening" type="check" />
<evening label="Evening" type="check" />
<night label="Night" type="check" />
</root>
</mx:XML>
</mx:dataProvider>
This doesn't seem to be a valid option anymore with the new spark architecture. Can someone suggest how this can be done? I thought if I put in Declarations, it would work, but doesn't seem to be the case.
Try:
<fx:XML>
...
</fx:XML>

Resources