on 02-02-2007 3:55 PM
Hi guys,
I want to perform a mandatory field value check in a web dynpro input field. I have cretaed an application and want to ensure that user entered values into it, before it can processed further. I do not think there is/are any property avialable for this.
Any help on how to code.
Thanks a lot in advance.
regards
Sam
Message was edited by:
sameer chilama
Hi Sameer,
Try this out,
try
{
String name = wdContext.current<ContextNodeName>Element.getName();
...
}
catch(NullPointerException e)
{
wdcomponentAPI.getMessageManager().reportException("Cannot enter a null value", true);
}
You can do it for all types of contexts..
Hope it helps you..
Regards,
Alka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i got it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Guys,
What if my value is a standard code and is assigned to a model node and subsequently model attribute. How fo i get the value of this?
regards
Sam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sameer,
When you want to validate input filed there shoule be some action to be performed.
For example if you have a value attribute named "Name" and you have bounded that to an Input Filed then you can perform the following logic to validate that input field for example onAction of button.
onAction:
String name= null;
name = wdContext.currentContextElement().getname();
if (name == null || name= .trim().length() == 0) {
wdComponentAPI.getMessageManager().reportException(
"Name cannot be left blank",true);
} else{
<Perform the required logic>
}
Regards,
Jhansi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
this is common code for test the Whether the input field is empty then we have to display the error.
Add the attribute in the context.
public void checkMandatory( java.lang.String displayName, java.lang.String fieldContextID )
{
//@@begin checkMandatory()
IWDMessageManager messageMgr =wdThis.wdGetAPI().getComponent().getMessageManager();
String attributeValue = wdContext.currentContextElement().getAttributeAsText(fieldContextID);
IWDAttributeInfo attributeInfo =wdContext.getNodeInfo().getAttribute(fieldContextID);
if (attributeValue != null)
attributeValue = attributeValue.trim();
if (attributeValue.length() == 0) {
//String fieldLabel = this.wdContext.getNodeInfo().getAttribute(displayName).getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,
IMessageOrderStatusApplication.EMPTY_INPUT,
new Object[] { displayName },
true);
}
//@@end
}
in on action write the code like
this.checkMandatory("Please enter the inputvalue","contextattributename");
wdComponentAPI.getMessageManager().raisePendingException();
it you want to add for more input fields
add second contexzt attribute
this.checkMandatory("Please enter the secondinputvalue","contextattributename1");
wdComponentAPI.getMessageManager().raisePendingException();
thanks,
Lohi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
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.