cancel
Showing results for 
Search instead for 
Did you mean: 

enable button when text is not empty

Former Member
0 Kudos

Hi,

I have created a view that has an input field and a "save" button.

The save button is disabled by default, and should become enabled only if some text was written to the input field. As for now, the best I could do is to enable the button after pressing "Enter" from the input field.

I would like to know, if there is a more elegant way, in which the button will be automatically enabled the moment the text is inserted, and disabled if one deletes the text.

Thanks,

Oren.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi ,

Make a boolean variable which will be set to the enabled prpoperty of ui elementt - button.

Your input field UI would also be binded to a context - say XXX,

Place a code in the OnEnter Event of the inputelementUI ,

in that code checkif the lenght of the string entered is greater than 0. in that case simply set the boolean varialble above to true , the button would be enabled

Message was edited by:

Vivek Mishra

Message was edited by:

Vivek Mishra

Former Member
0 Kudos

Hi,

OK, so instead, I intead to leave the "ok" button enabled, but if pressed, and the the input field is empty - I want to emphasize the input field with a red frame.

Is this possible?

Thanks,

Oren.

Former Member
0 Kudos

Hi Oren

You can achieve this by creating an item in Message Pool and then using that in your code like

if length()<0 then you can throw raisependingException. code will look like

IWDNodeElement task = node.getElement();
manager = wdComponentAPI.getMessageManager();
IWDAttributeInfo attibute = node.getNodeInfo().getAttribute(XX);

String message = wdComponentAPI.getTextAccessor().getText(IMessageXX.Messagepool_Name);
manager.raiseInvalidContextAttributeException(task, attibute, message, true);
manager.raisePendingException();

Best Regards

Chaitanya.A

Former Member
0 Kudos

Yes, this is possible.

Open the message editor and create a message with message key as Blank and text as Please enter some value and type can be standard,error or warning.

Now, OnAction of the button wirte this code.

IWDAttributeInfo attr = wdContext.getNodeInfo().getAttribute(<name of the attribute binded to the input field>);

wdComponentAPI.getMessageManager().reportContextAttributeMessage(wdContext.currentContextElement,attr,IMessage<component name>.BLANK,null,true);

Warm Regards,

Murtuza

Former Member
0 Kudos

Thank you all. Problem is solved.

I would like to reward you for the answers, but for some reason I cannot see the reward pannel... anyone knows why?

sridhar_k2
Active Contributor
0 Kudos

Oren,

Unfortunately web dynpro doesnt support Java Script and it doesnt have any methods for your functionality.

onEnter you have to write to enable. But i dont think it would make sense to use.

Regards,

Sridhar

Former Member
0 Kudos

Hi Oren,

Their is no Change event or key press event . Unless a round trip is triggered this will not work.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

The answer to your question would be No.

Regards,

Murtuza