cancel
Showing results for 
Search instead for 
Did you mean: 

How to Diasble the button if node is null

Former Member
0 Kudos

Hi All,

I want to disable button if node is null... I have written the code in wdInit()...

But it is not triggered....

IPrivateaView.IApplicantsListNode node = wdContext.nodeAView();

node1 = node.size()

if(node1 !=null)

{

wdContext.currentContextElement().setEnableMergeButton(true);

}

}

else

{

wdContext.currentContextElement().setEnableMergeButton(false);

}

Please Tel me how to do...

Thanks & regards

Mathi

Message was edited by:

Mathi s

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create a calculated attribute and write the code to test the size of th node and return the value desired, bind the context attribute to the enabled property of the button.

Code is already their in the post.

Regards

Ayyapparaj

Answers (3)

Answers (3)

former_member751941
Active Contributor
0 Kudos

Hi Mathi,

wdDoInit will fire when first time you run the project. Don’t put the condition inside “wdDoInit” method. It will not triggered.

Take a context attribute say “isEnabled” of type “boolean"

Go to the View Layout and select button and bind context attribute “isEnabled” in the value of “enabled” properties of button.

Inside wdDoInit use this code.(First time)

wdContext.currentContextElement().setIsEnabled(false);

where you are populating your node use.

wdContext.currentContextElement().setIsEnabled(true);

Regards,

Mithu

former_member187990
Participant
0 Kudos

Hi Mathi...

In order to make a button enable or disable you have to define an attribute in the context.(Say ButtonStatus) and make it type Boolean

Bind the enabled property of the Button UI element to this attribute.

In the wdDoinit()

write the coding.

int nodesize=wdcontext.node<"NodeName">.size();
if(nodesize==0)
{
 wdcontext.currentContextElement.setButonStatus(false);
}
else
{
 wdcontext.currentContextElement.setButonStatus(true);
}

Former Member
0 Kudos

Hi,

Instead of

IPrivateaView.IApplicantsListNode node = wdContext.nodeAView();

if(node !=null)

try using

int size = wdContext.nodeAView().size(); //this will give the number of elements the node has

if(size != 0)

Message was edited by:

Leena Ramachandran

Message was edited by:

Leena Ramachandran

Message was edited by:

Leena Ramachandran

Former Member
0 Kudos

Hi

Thanks For ur reply....

I have tried both u and sathis suggestion...

but,Button is always Disabled....

Could u plz tel me the correct way...

Thanks & regards

Mathi

Former Member
0 Kudos

Hi Mathi,

Have you bound the 'enabled' property of the button to your context attribute 'EnableMergeButton'?

Regards,

Leena

former_member751941
Active Contributor
0 Kudos

Hi Mathi,

It will definitely work. After populating your node have you set context attribute value "true" ??

wdContext.currentContextElement().setIsEnabled(true);

Regards,

Mithu

Former Member
0 Kudos

Hi,

You can put this code inside the <i>wdDoModifyView()</i> method.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

Say you have button named "Submit" asssociated with a action "Submit".

As suggested by others we will check the node size.And if node size is 0 we will disable the action associated with the button.This will automatically disable the button.

nodesize= wdContext.node(your node).size();

if(nodesize==0)

{

wdThis.wdGetSubmitAction.setEnabled(false);

}

else

{

wdThis.wdGetSubmitAction.setEnabled(true);

}

Former Member
0 Kudos

Hi,

Thanks for ur reply.....

Where i put this code....

if i put wdDoInit()-->Always disable

Put wdDoModify()-->always enable

Thanks & regards

Mathi

Former Member
0 Kudos

Hi,

What is the cardinality of the node? If it is 1...n, then putting the code inside <i>wdDoModifyView()</i> is not going to work.

Regards,

Satyajit.

Former Member
0 Kudos

Hi Mathi,

Put this line of code in your wdDoInit of the view controller.

if(wdContext.node<your node>.size()==0)

{

wdThis.wdGetSubmitAction.setEnabled(false);

}

This will make the button disabled if the node is empty during view loading for the first time.

Once the view is loaded, and their is some action triggered, in that action you can again check if the node is empty.If it si not empty then you can enable the button.

Now this code can be in any action or naviagtion plug (like for =m this view you go to anothe view and come back,then if the Inound plug write this code) or if some action is trigered in the view which will load values in the node then write the code in the action method.

if(nodesize==0)

{

wdThis.wdGetSubmitAction.setEnabled(false);

}

else

{

wdThis.wdGetSubmitAction.setEnabled(true);

}

if you can explain your scenario when the node will have value and when it will not,may be i can help you more precisely.

Former Member
0 Kudos

Thanks For ur reply...

I have created calculated attribute and solved the problem...

Thanks For All...

Thanks....

mathi