cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with context attributes

Former Member
0 Kudos

Hello All,

I am currently experiencing some strange behaviour in my WD application so I hope any experts here can give me a hand or spot my mistake.

<u><b>Scenario</b></u>

1) View A is being initialised and by default, will display the name of the manager.

2) This name is being stored as a string attribute "tempName" in a context node of cardinality 1..1.

3) Someone then decides to change the name of the manager in View A but half way, he changes his mind and clicks on a 'cancel button'.

4) This cancel button has an action tagged to it and will then transfer the contents of the attribute "tempName" back to the UI element.

<u><b>Problem</b></u>

The problem that I am experiencing now is that for some strange reason, the name that I stored in "tempName" becomes a NULL whenever it attempts to transfer the contents back to the UI element.

To ensure that tempName is assigned the correct data, I issued a "wdComponentAPI.getMessageManager().reportSuccess("From SearchButton :" + wdContext.currentApproverInfoElement().getPrevious1Name());" so that I know for sure that the correct data is being writtena nd displayed back to me.

Hence, it is very puzzling as I have no idea whatelse may have gone wrong. Any suggestions or feedback will be greatly appreciated. Thank you.

from

Kwok Wei

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kwok Wei,

Your are trying to transfer the value from

wdContext.currentApproverInfoElement().getPrevious1Name() to

"tempName" .Is that correct ?

Please check the databindings of the UIElement.

Regards, Anilkumar

Former Member
0 Kudos

Hi Anilkumar,

That is correct.

During initialisation, I actually made a copy of the contents :

1) String name1 = wdContext.currentApproverInfoElement().getApprover1Name();

2) wdContext.currentApproverInfoElement().setPrevious1Name(name1);

However, it seems that this information is lost when I try to recover back the data when someone hits the cancel button. The code below is assgined to the cancel action of the button.

3) String previous1Name = wdContext.currentApproverInfoElement().getPrevious1Name();

4) wdContext.currentApproverInfoElement().setApprover1Name(previous1Name);

After lines 3) and 4) are executed, the UI Element is showing NULL instead.

The UI element is binded to the context attribute ApproverInfo.Approver1Name.

from

Kwok Wei

Former Member
0 Kudos

Hi Kwok,

1) Is the cardinality of the node 'ApproverInfo' 1..1 ?

2) Are you initializing the node or attribute inside your wdDoModify() ?

3) Inside your action handler try printing the current lead selection of the node only and see what it returns.

wdContext.nodeApproverInfo().getLeadSelection();

If these didn't help you, please paste the code that references this particular node in wdDoInit(), wdDoModify() and in your action handler here. This might help us to identify what the problem is.

Best Regards,

Nibu.

Former Member
0 Kudos

Hello Nibu,

1) Yes, the cardinality is 1..1,

2) Yes, I have initialised it inside wdDoModify(),

3) I have already try printing out the values during initialisation, prior to clicking cancel and after clicking cancel. The first 2 results are correct but for some reason (most prob my fault) the 3rd is showing null.

from

Kowk Wei

Former Member
0 Kudos

Hi Kwok,

Do all the initializations in your wdDoInit() method as wdDoModify() will be called each time time screen rendering happens. Even if you are writing this code in wdDoModify(), make sure you write it inside if(firstTime){ } block. Can you please post your relevant code here?

Best Regards,

Nibu.

Message was edited by: Nibu Wilson

Former Member
0 Kudos

That did the trick !!!!

I forgot the if(firstTime){}.

It works now. Thanks Nibu !

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try the following

in the init() method write

wdContext.currentApproverInfoElement().setApprover1Name("Anil");

wdContext.currentApproverInfoElement().setPrevious1Name(wdContext.currentApproverInfoElement().getApprover1Name());

In the button click write the following

wdContext.currentApproverInfoElement().setApprover1Name(wdContext.currentNameElement().getPrevious1Name());

Regards, Anilkumar

Former Member
0 Kudos

Hi Anilkuamr,

Whats the difference between your suggstion and mine ? Seems to be the same though. Anyway, I have trie it out as suggested but it does not seems to be working.

from

Kwok Wei