on 12-03-2010 2:55 PM
Hi all,
I am writing small webdynpro java application, in this i am doing validations for inputfields (like should contain value otherwise through an error message). i done this one but if i enter space in this field it is not throughing any error, so would any one help me. and also i want do like througing error if i click enter button or tab button with out filling values in those inputfields.
thanks
anu
Hi,
To validate the input field for space use the following code assuming Va_Input is the context bound to the InputField UI,
String value = wdContext.currentContextElement.getVa_Input();
if(value!=null && value.trim().equals("")){
//Display error message.
}
Here trim() method is used to remove the blank spaces and after doing this if the string is an "empty string" then it indicates that it holds only blank sapces, hence display the error message.
To do the validation on click of enter key, create an eventhandler and bind it to onEnter action of the InputField and write all the validations in that event handler. Validation on click of tab is not possible.
Hope this will be helpful.
Regards,
Vishweshwara P.K.M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks Nizamudeen,
I tried but still i am getting null pointer exception.
the code i used in my app is
public void onActionCheck(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionCheck(ServerEvent)
if(this.wdContext.currentNamesElement().getFname() == null)
{
this.errorDisplay();
}
else
{
wdThis.wdFirePlugToComp1View();
}
//@@end
}
public boolean errorDisplay( )
{
//@@begin errorDisplay()
IWDMessageManager messageMgr =
wdThis.wdGetAPI().getComponent().getMessageManager();
if (wdContext.currentNamesElement().getFname() instanceof String) {
return true;
}
else {
messageMgr.reportContextAttributeMessage(
this.wdContext.currentNamesElement(),
this.wdContext.nodeNames().getNodeInfo().getAttribute("Fname"),
IMessageErrorComp.DESIRE__FNAME,
null,
true);
return false;
}
//@@end
}
and one more doubt i am using "reportContextAttributeMessage" to display the message .but i think this is depricated one, would u plese suggest me which method i can use instead of this.
thanks
anu
thanks its solved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.