on 03-12-2008 1:21 AM
Hi everyone,
I have some code to check if the mandatory inputfield is filled by the user:
public void CheckMandatory( java.lang.String fieldname )
{
//@@begin CheckMandatory()
IWDMessageManager messageMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager();
Object attributeValue = this.wdContext.currentContextElement().getAttributeValue(fieldname);
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(fieldname);
if (((String) attributeValue).length() == 0){
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,IMessageBasics_Error.MISSING_INPUT,new Object[] { fieldname },true);
}
//@@end
}
but when we excute the code to "if (((String) attributeValue).length() == 0)",dump window appears.I debugged into the code and found the "attibuteValue" is not an empty string but an null value,maybe that's the reason for the dump.
How to deal with the problem? Thanks in advance.
Hi,
Take the value as string
Instaed of this
Object attributeValue = this.wdContext.currentContextElement().getAttributeValue(fieldname);
put this
String value ="";
value = this.wdContext.currentContextElement().getAttributeAsText(fieldname);
Then check for this condition
if (value.length() == 0) {
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,IMessageBasics_Error.MISSING_INPUT,new Object[] { fieldname },true);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Begue,
Implement Chandran's method for validation.
Using the Required property will not help, if the fieldValue, is a String type Context.
Coz, NULL is a valid value for String Object.
Regards,
Alka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Instead of writing code,
you can select the state property of Inputfield as required.
I think this will do..
Thanks,
Gunja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this
if ( null == attrributeValue || attributeValue.trim().length() == 0)){
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,IMessageBasics_Error.MISSING_INPUT,new Object[] { fieldname },true);
}
//@@end
}
--
Shyam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Try this way
IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();
Object attributeValue =
wdContext.currentContextElement().getAttributeValue(fieldName);
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute(fieldName);
if (attributeValue instanceof String) {
if (((String) attributeValue).length() == 0) {
messageMgr.reportContextAttributeMessage(
wdContext.currentContextElement(),
attributeInfo,
IMessageRequisitionForm.MISSING_INPUT,
new Object[] { fieldLabel },
true);
}
} else if (attributeValue instanceof Integer) {
}
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Make use of this code
Object attrValue = wdContext.currentContextElement().getName();
if(attrValue==null)
{
wdComponentAPI.getMessageManager().reportSuccess("The Value is Null");
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("Entered Value"+wdContext.currentContextElement().getName());
}
Regards
Chandran S
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 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.