Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Multiple output rows on custom component

Hello
I'm creating a custom component.
this component have 2 outputs rows and I want data to flow through one row at a time (not both the 2 rows).
Can you tell me how I can achieve it ?
Thanks,
Regards
tChangeTest.rar.rar 
Labels (3)
11 Replies
Anonymous
Not applicable
Author

Hi,
We are working on your another topic: https://community.talend.com/t5/Design-and-Development/Multiple-outputs-flow-management/td-p/97530 then come back to you asap!
Best regards
Sabrina
Anonymous
Not applicable
Author

If you are working on a component with two outputs, I am assuming that you have got to the stage where your component is outputting the same thing via the 2 outputs. If that is the case, then why do you not just implement some sort of procedure to switch the output you are sending data to for every row? I am assuming that you want to achieve the following....
Input Data
1
2
3
4
Output1
1
3
Output2
2
4
Anonymous
Not applicable
Author

If you are working on a component with two outputs, I am assuming that you have got to the stage where your component is outputting the same thing via the 2 outputs. If that is the case, then why do you not just implement some sort of procedure to switch the output you are sending data to for every row? I am assuming that you want to achieve the following....
Input Data
1
2
3
4
Output1
1
3
Output2
2
4

Thanks for you answer but I already know how to do this.

My real problem is that I don't want to get : http://www.noelshack.com/2015-29-1437142034-capture.png
Output1
1rows
Output2
1rows
I want control the rows data flow like this:
Output1
1rows
Output2
0rows
OR
Output1
0rows
Output2
1rows
Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

How do you want to decide which output is getting the data? Is there some sort of logic you are basing this on, is this a setting based on a datarow or is this decided at design time?
Also, your screenshot is misleading I think. Are you assuming that because you are seeing "1 rows" on both outputs that they are being output together? Is the data from output1 and output2 the same or is it different but appears to be happening at the same time?
You say that you know how to shift the datarow from one output to the other. If that is the case, what is the problem you are struggling with? If you know how to do this, then it is very easy to implement any logic you want to decide when the output will switch, which output it will switch to, etc.
Anonymous
Not applicable
Author

Thanks for your reply.
See below the logic to switch on which output to write :
<% 
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();
NodeConnectionsHelper connsHelper=new NodeConnectionsHelper(node, true);
String cid = node.getUniqueName();
IConnection inputConn = connsHelper.getInputConn();
if(inputConn == null)
{
return "";//not generate any code if no input connection.
}
IConnection connResponse = connsHelper.getOutputConnResponse();
IConnection connFault = connsHelper.getOutputConnFault();
%>
if (<%=inputConn.getName()%>.InputColumn == "toto")
{
<%=connResponse.getName()%>.Result = <%=inputConn.getName()%>.InputColumn;
java.util.List<String> responseList_<%=cid%> = null;
responseList_<%=cid%> = new java.util.ArrayList<String>();
responseList_<%=cid%>.add(<%=inputConn.getName()%>.InputColumn);
responseList_<%=cid%>.add(<%=inputConn.getName()%>.InputColumn);
responseList_<%=cid%>.add(<%=inputConn.getName()%>.InputColumn);
<%=connResponse.getName()%>.OutputColumn = responseList_<%=cid%>;
}
else if (<%=inputConn.getName()%>.InputColumn != "toto") {
<%=connFault.getName()%>.error_id = <%=inputConn.getName()%>.InputColumn;
<%=connFault.getName()%>.error_message = <%=inputConn.getName()%>.InputColumn;
}

As you can see above, the 2 outputs are connResponse and connFault. You can also see that we write on one output at the time.
On my screenshot, data are written only on connResponse. But n evertheless, empty data flows through connFault.
This is our issue : we don't want any row flow through connFault when switch to connResponse (even if it's an empty row).
Also we don't want any row flow through connResponse when switch to connFault.
Hope it's clear.
Thanks in advance
Anonymous
Not applicable
Author

Sorry, I have looked again and think I see your problem. You are getting a row from both outputs every time, but only one of those outputs is actually holding data. So like this....
Output1  Output2
1           null
null        2
3           null
null        4
But what you want is this....
Output1  
1
3
Output2
2
4
I'm not sure this is easy at all. Take a look at components like tMap which handle this sort of functionality. They have the concept of tMapIn and tMapOut sub components. If you do find out, I would be interested to see how you do it. Unfortunately the Talend Component Designer is the least documented piece of functionality and a lot of what I have learnt is through trial and error.
Anonymous
Not applicable
Author

I believe this is caused because the output objects (IConnections) that are instantiated in the Java Main file are always triggered to return a response even if it is null (ie you have not assigned it a value). Therefore I believe it requires the sub component design model where you can make use of the sub component output you require for each row. As I said before, this is guess work from playing around with the code.
Anonymous
Not applicable
Author

This is exactly the issue rhall_2.0. Can you give me more details about your proposed solution please ? Thanks