on 06-05-2007 2:36 PM
All,
I want check whether the field is filled or not. In this case its not String ..its Integer.
1. How can I check whether integer value populated or not (Not with zeros, because, by default its filled with zeros,)
2. Also I want to check the values are integer or not.
Thanks ..
BM
Hi,
1)First u have to create error message in Message Pool as Type error and enter text like"input field is empty"
2)Then u have to create method check mandatory with parameter "fieldname"
3)create button and also create action for that
4)In onActionButton write code
this.checkmandatory("attributename");
5)write below code in check mandatory as
IWDMessageManager msg3=wdComponentAPI.getMessageManager();
Object avalue1=wdContext.currentContextElement().getAttributeValue(fieldname);
IWDAttributeInfo ainfo2=wdContext.getNodeInfo().getAttribute(fieldname);
if(avalue1 instanceof String)
{
if(((String) avalue1).length() == 0)
{
String fieldLabel=wdContext.getNodeInfo().getAttribute(fieldname).getSimpleType().getFieldLabel();
msg3.reportContextAttributeMessage(wdContext.currentContextElement(),ainfo2,IMessageErrormsg.CHECKINPUT,new Object[]{fieldLabel},true);
}
}
Message was edited by:
Suresh T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bharathi,
I think it's better to use String instead if integer type so that u can prompt messages by checking whether it is null or empty string. In this case, u can control the length by creating a dictionary type with maximum length 8 and bind it to this string variable. It is working perfectly for me. The invalid number can be checked as Shriram suggested.
Regards
Fahad Hamsa
Hi Bharathi,
Try this.
Integer custNum = new Integer(wdContext.currentContextElement().getCustomerNumber());
String cnum_st = custNum.toString();
if (cnum_st.length()== 😎
{
<Put the code that you want to perform>
// wdThis.wdGetTPMCustCompController().getCustomerDetailByNumber(cnum_st);
}
else
{
wdComponentAPI.getMessageManager().reportException("Input Field Should be of 8 characters",false);
}
Regards,
Mithu
Hi Bharati,
This can be solved by avoiding direct mapping with RFC variable. Map ordinary context variable of type String with inputfield. While submit,
convert this value to integer by using
int a=Integer.parseInt("12345678");
Then set this value to the RFC variable by
wdContext.current<nodefromRFC>().set<numVariable>(a);
Regards
Fahad Hamsa
Hi Bharati,
From your explaination what i can understand is the inputfield is alwyas filled with 8 zeros.
You want to check if the input value not empty and it is integer
Now since you dont know what the input is Integer/String
Webdynpro has inbuilt functinality to check if the input value for a field of type integer is integer or not.
And this functionality is called as soon as you trigger the action.
But even then if you want to check it then see the following code.
First check if the input value is integer as explained. If the input value is integer then exception is not thrown.
int i = 0;
boolean isInt = true;
try{
i = Integer.parseInt(wdContext.currentContextElement.getInputValue()));
}catch(NumberFormatException NFE)
{
// if it catches this exception that means the user entered value is not integer. Here you write what you want to do when the user does not enter a integer value
isInt = fasle;
}
// the above is done by webdynpro by default
if(isInt)
{
// check if the integer is zero
if(i=0)
{
// raise exception for value being zero
}
else
{
// cehck if the length is < 8
String str = String.valueOf(i);
if(str.length < 😎
{
// raise excpetion for value not being eight digit
}
}
}
Hi,
For checking wheter a UI element value is filled or not, map it to a context attribute of type Stirng.
Since it is mapped to String type attribute, you can easily check whether it is empty or not as in your former thread.
Then if you want you can check whether it is integer or not as below
try{
int i = Integer.parseInt(wdContext.currentContextElement.getInputValue()));
}catch(NumberFormatException NFE)
{
// if it catches this exception that means the user entered value is not integer. Here you write what you want to do when the user does not enter a integer value
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
6 | |
6 | |
6 | |
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.