on 04-04-2008 10:53 AM
hi,
I have converted an integer data type to string.Now at run time the input field which is mapped to this integer bata type is showing a 0 and becoze of this iam not able to run a validation which says "that if the input field is empty then approve button cannot be clicked"
my code:
String text=String.valueOf(wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived());
wdComponentAPI.getMessageManager().reportSuccess("text"+text);
if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))
{
wdContext.currentVn_inactivenableElement().setVa_approvebtn(false);
}
what change ai have to make it look empty at run time
What is the exact DDIC (data dictionary) type of your context attribute? Is it "integer" or "integerObject"? See also
http://help.sap.com/saphelp_nw70/helpdata/EN/42/c04c950ad21d65e10000000a1553f6/content.htm
http://help.sap.com/saphelp_nw70/helpdata/EN/4c/40ba420db1cc66e10000000a1550b0/frameset.htm
If it is has DDIC type "integer" then the runtime type is "int" and you just cannot check if no value is set, because it always has a value.
If it has DDIC type "integerObject", the runtime type is "Integer" and it can also have a NULL value. To check if the value is not set, compare the attribute value with NULL, no need to convert to string etc.
Just forget all these proposals with accessing the input field in wdDoModifyView() and using setText() etc..
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Nisha,
Try this code;
String text = wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived().toString();
wdComponentAPI.getMessageManager().reportSuccess("As String " + text );
if( doctype.equalsIgnoreCase( "DA") && ( text == null) && ( text.equals( "0")))
{
wdContext.currentVn_inactivenableElement().setVa_approvebtn( false);
}
Here the value of text will be pure string and now try this code.
One more thing; i don't find any logic in using && for testing text as null or 0.
I hope this is what you were trying for.
if( doctype.equalsIgnoreCase( "DA") && ( ( text == null) || ( text.equals( "0"))))
{
//Statements
}
Regards
- Vinod V Pillai
*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
As your input field is of datatype int why dont you try as follows
int x = wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived();
if(wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived() == 0 )
{
wdContext.currentVn_inactivenableElement().setVa_approvebtn(false);
}
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
dont' type cast it for comparison;
you can use following code for comparison.
if(doctype.equalsIgnoreCase("DA"))
{
if ( wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived()==0 )
{
// put your code here..
}
}
regards,
nikhil
Edited by: Nikhil Bos on Apr 4, 2008 6:17 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can be more clear....
1) u have a input field - datatype mapped to integer.
2) u have doctype -- string
3) now u have to check ..if the input field is 0 or null , and doctype if equals "DA" then u want to make the button disable ... Is that u want , If any other thing pls mention.
Also can say what is the output for this ...
String text=String.valueOf(wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived());
wdComponentAPI.getMessageManager().reportSuccess("text"+text);
/*
if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))
{
wdContext.currentVn_inactivenableElement().setVa_approvebtn(false);
}
*/
// what is the value it is printing for text.
Is it giving any runtime error ????
Thanks,
Srini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also change code:
if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))
to
if(doctype.equalsIgnoreCase("DA")&& ((text==null) || (text=="0")))
Regards,
Gopal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In wdModifyView Try following code:
if(firstTime){
IWDInputField text = (IWDInputField) view.getElement("InputFieldID");
text.setValue("");
}
Instead of InputFieldID, give id of input fied you want empty.
Regards,
Gopal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nisha,
Sorry I was busy with some other work. So could not respond early.
Following code is used to make InputField llok empty at run time. Anybody can fill data in it afterwards:
Code have to be in wdModifyView
if(firstTime){
IWDInputField text = (IWDInputField) view.getElement("InputFieldID");
text.setValue("");
}
Following code is for making your code correct. Nothing related to what your requirement is:
Instead of code
if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))
put
if(doctype.equalsIgnoreCase("DA")&& ((text==null)&&(text.equals("0"))))
[I have used equals as suggested by Srinivas]
Regards,
Gopal
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.