cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Values from one node to another node??

Former Member
0 Kudos
130

Hi

I have table(say GetTable) with two columns: Month and MaterialInput. Month is of TextView Element & MaterialInput is of InputField type.

This GetTable is bound to GetTableNode which has two value attributes: Month(type --> String)& MaterialInput(BigDecimal).

I making the user to enter any value against any row under the column "MaterialInput". Thus he/she can enter any value in Input field against corresponding Month..

Now I have to display only those rows to which he has seleted.

I created another table(say DisplayTable) and binded with DisplayTableNode having Month and MaterialInput (string and BigDecimal types respectively).

And I have written the following code.


IPublicPreBuyPricesComp.IGetTableNodeElement getTableElement ;
	IPublicPreBuyPricesComp.IDisplayTableNodeElement displayTableElement ;
    int size = 0;
    int sizeMax = wdContext.nodeGetTableNode().size();
    
	
	BigDecimal Input = null;
	String Month = null;
	
	
    for(; size<sizeMax;size++)
    {
	displayTableElement = wdContext.createDisplayTableElement(); 
    	getTableElement = wdContext.nodegetTableNodeNode().getTableNodeElementAt(size);
    	  	 
    	Input = getTableElement.getMaterialInput();
    	Month = getTableElement.getMonth();
			
    	 if (Input.equals(null))
    	 { 
			continue;
	 }
	   	else 
	   	{
			displayTableElement.setMaterialInput(Input);
			displayTableElement.setMonth(Month);
			
wdContext.nodeDisplayTableNode().addElement(fixedTableElement);
	   	}
		
    }

I'm getting following errors:

1. The table gets displayed with values only if I fill the first row and then continue it like this for rest fo the rows below.

2. if i fill the first row and then third/fourth or any row then only first row gets dispalyed.

3. if i dont' enter the first row and with rest of the rows i fill any manner, nothing gets displayed.

I don't know where I'm going wrong

Can somebody help me with this???

Thanks in advance

Srikant

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This may not solve your problem. But all the above code can be replaced with

WDCopyService.copyElements(wdContext.nodeGetTableNode(),
                        wdContext.nodeDisplayTableNode());

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Srikant

I guess you have mapped the context nodes and the table in a wrong fashion because you cannot map BigDecimal( rather any java native type ) to a table column.

In the code provided by Maksim, the type for MaterialInput context attributes have been taken as "decimal" and not "BigDecimal" .

Just try and figure out the issue.

Hope this helps.

Kaushal.

former_member182372
Active Contributor
0 Kudos

Hello Srikant,

You are creating and dealing with variable <i>displayTableElement</i> BUT inserting to node another one - <i>fixedTableElement</i>. Is it mistake in your post or error in code? Seems like you are inserting same element multiple times.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim

Thanks for pointing this mistake..

It was mistake in my post. I'm inserting the elements to <i>displayTableElement</i> only.

Still I'm getting the error.

I need to pass only those values against which I have included data and rest should not go to the displayTableNode..

And, as suggested by Devisha i even tried putting

<b>(Input.equal(null))</b>, still it didn't make any difference..

Any other suggestions ???

Thanks in advance

Srikant

former_member182372
Active Contributor
0 Kudos

Hm...really strange.

I have :

1) DisplayTable node (cardinality 0..n, selection 0..1) with attributes MaterialInput(decimal) and Month (string)

2) GetTableNode node (cardinality 0..n, selection 0..1) with attributes MaterialInput(decimal) and Month (string)

3) 2 tables with appropriate mapping to mentioned nodes.

3) Button with action handler:


wdContext.nodeDisplayTable().invalidate();
int size = 0;    
int sizeMax = wdContext.nodeGetTableNode().size();

IPrivateNewComponentView.IDisplayTableElement displayTableElement;
IPrivateNewComponentView.IGetTableNodeElement getTableElement;

BigDecimal Input = null;	
String Month = null;

for(; size<sizeMax;size++) {
	displayTableElement = wdContext.createDisplayTableElement();
	getTableElement = wdContext.nodeGetTableNode().getGetTableNodeElementAt(size);
	
	Input = getTableElement.getMaterialInput();    	
	Month = getTableElement.getMonth();
	
	if ( Input==null ) {
		continue;	 
	} else {
		displayTableElement.setMaterialInput(Input);			
		displayTableElement.setMonth(Month);			
		
		wdContext.nodeDisplayTable().addElement(displayTableElement);
	}		    
}

Everything works fine!...

BTW, when do you perform transfer? Which action handler?

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

Thanks once again for the effort.

Now let me explain how the things working in my application

Month M.Input

July 10000

August

Septemeber

October

The 10000 value entered by the user in the input field.

Now, here the user enters the values and on click of button the in second view the following should get displayed

Month M.Input

July 10000

I have put this code in a method and calling it in wdDoInit() method of second view. as click of button is not helping my case.

Now I highlight wat are the different outputs for different kind of input.

Case 1:

1st View 2nd View

Month M.Input Month M.Input

JUL 10000 JUL 10000

AUG

SEP

OCT

Case 2:

JUL 10000 JUL 10000

AUG 2000 AUG 2000

SEP

OCT

Case 3:

JUL 10000 JUL 10000

AUG

SEP 3000

OCT 500

Case 4:

JUL nothing get displayed

AUG 2000

SEP 3000

OCT

So, my requirement is to suppress the ones which has no values and display only which has data. I have written the code in CustomController and have done the appropriate maaping

The cardinality is 1..n and selection 0..1 in both the cases.

Yet it is not working

Where I'm going wrong??

Thanks in advance

Srikant

P.S. The code for shifting the focus is not working, it is used in above context only, where the user after pressing enter the cursor points the next input which is not happening , in that also i had writtn code in method in View and called in onEnter handler. Is there any suggestions this regard also??

former_member182372
Active Contributor
0 Kudos

Hello Srikant,

I have 2 Views (View1, View2), 1 cusom controller (Custom). "View2" is embeded to "View1" via ViewContainerUIElement. There is a node "GetTableNode" with structure described above in "Custom", "View1", "View2", with mapping "View1"->"Custom", "View2", ->"Custom". In "Custom" there are method "reload" and event "reload". In method reload we just fire event "reload" (wdThis.wdFireEventReload();). In "View1"`s button action handler we call method "reload" from "Custom". In "View2" we subscribe to event from custom controller and prepare filtering described above. It works for me ;-).

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim

10x for all the effort you taking for me. For me its not working. Don't know why I'm unable to send data of only those rows which have data !!

Thanks for the effort

Still if you can suggest me something, I will be thankful

Thanks in advance

Srikant

former_member182372
Active Contributor
0 Kudos

Hello Srikant,

Could you send me your project to rastchinskym at mail.ru? Will try to figure out the problem.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Srikant,

The problem is you are creating the DisplayTableElement everytime inthe loop but not using it all the time.

Put all this source code together in the 'else' brace.

displayTableElement = wdContext.createDisplayTableElement();

displayTableElement.setMaterialInput(Input);

displayTableElement.setMonth(Month);

wdContext.node.....

Hope it helps

Regards

MK

Former Member
0 Kudos

Hi Srikant,

I guess you are getting null poiner exception at line:

if (Input.equals(null))

When you are not specifying any value then check using following code:

if(Input == null)

{

}

Other code looks fine.

Regards,

Bhavik

Former Member
0 Kudos

Hi Shrikant,

If you simply want to replicate all the records of the source node into another target node, then you can use the Copy Service as suggested above. This is just like the "move corresponding" as in ABAP, so the criteria for this is that the target nodes must have the attributes of the source node that you have to copy.

Hope this helps,

Nirav

Former Member
0 Kudos

Hi,

May you should check the cardinality or selection of the node context which binded to the table.

Regards

Yoel

Former Member
0 Kudos

Hi Yoel

Can you elaborate on this!!

I have cardinality of 1..n and selection 0..1 for both the nodes.

Any suggestions in this regard.

But i think that is not the problem.

Thanks

Srikant