cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if a dropdown element is selected or not

Former Member
0 Kudos

Hi all

I have a dropdownbykey UI element .it's getting value from EJB's.I want to perform a check to find if user has selected any element from it or not when I press a Submit button.Note that it is showing blank innthe dropdown initially.

Thanks

Ananda

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Check the value of the context attribute to which the "selectedKey" property of the drop-down list is bound.

Armin

Former Member
0 Kudos

Hi

I have used this code to check context value attribute of type string

wdContext.currentContextElement().get<context_element>().equals(null)

and also

wdContext.currentContextElement().get<context_element>().length()==0

but none of them is working.

Help !!

Thanks

Ananda

Former Member
0 Kudos

hi ananda,

display the value of wdContext.currentContextElement().get<context_element>()

using

wdComponentAPI.getMessageManager.reportSuccess(wdContext.currentContextElement().get<context_element>())

before the check and see what is coming]

Regards

Rohit

Former Member
0 Kudos

Hi

I have used your suggestion and found that it is returning null.So I checked with following code

wdContext.currentContextElement().get<context_element>().equals("null")

but still it is giving NullpointerException

Please help

Ananda

Former Member
0 Kudos

Use

wdContext.currentContextElement().get<context_element>() == null

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Anandha,

Define a new context attribute of type say boolean and set its value to true in the onAction event of the dropdown.When the Save button is clicked check if the attribute is true/false to get the actual state, i.e, if the user has selected a value or not.

Hope this helps.

Bala

Former Member
0 Kudos

Hi Ananda,

In the event handler of the button check the value of attribute bound to the selectedkey property UI element.Since it is null initially you can check its value

Regards

Rohit