on 06-10-2005 10:46 PM
Hi,
Need to validate whether value of an attribute is an instance of the datatype of the attribute.
Will the following code work ?
IWDNodeElement element = wdContext.nodePlants.getCurrentElement();
IWDAttributeInfo attrInfo = (IWDAttributeInfo)element;
if (element.getAtrributeText("test") instanceof attrInfo.getDataType()){
//code here
}
Do let me know.
Thanks !
Sri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sounds strange.
First, you cannot cast a node element to an attribute info.
Second, why do you need to check the type of an attribute value at all?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Armin,
I need to validate the data input in the field. One of the validation criteria is datatype....say "Is data input numeric". For this we need to look at the input data type and compare it with the datatype of the attribute. Do realise there may be a casting issue in my code. So, please advise the best approach. Thanks !
Though I set the value attribute to type integer, I have been able to enter string data. When and how is the WD validation triggered ? Is there a way to capture this and throw a useful message to the user ? My use case requires to validate all fields at the time the user submits the form. So, need to look into each UI input element and the associated value attribute, and inform the user of any data issue.
Do let me know.
Thanks !
Hi
See u need not write any piece of code suppose where u r trying to Validate will Take care of that but ur Action shuld be Validating Action instead of Non-Validating Action.
See the Order of Actions is
1. WebDynpro will Validate First its own rules
2. Next is ur customized Validations will Take Place.
Try having some Empty Action on Input Field i.e onEnter of InputField Like that
See while creating Action for the Button Submission u Dont Check the CheckBox.
if u check it webDynpro will not Validate if not it Validates.
Hi
U need to check whether it is null or not but need not Validate whether it is Numeric or Not.
Wishes
Krishna kanth
Message was edited by: krishna kanth
Message was edited by: krishna kanth
Try the following
try{
IWDNodeElement element = wdContext.node<<NodeName>>().getCurrentElement();
if (element.getAttributeValue("ATTBName").getClass().newInstance() instanceof String ){
}
}
catch(Exception e)
{
}
Make sure that in the init method you need to create a n element of the node type .Otherwise you will get null pointer exception !!
Ex: IPrivateTestView.I<<NOde>>Element ele=wdContext.create<<Node>>Element();
ele.set<<Attrib>>("Temp");
wdContext.node<<Node>>().addElement(ele);
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anil,
Thanks for the response. But, what if I need to iterate through a list of value attributes that could be string, numeric, date type etc ? Is there a generic way of validating the data types ? Rather that coding the if statement as "....instance of String", is there a way to code something like "<value of attribute> instance of <datatype of the attribute>".
Hope the question is clear enuf. Do let me know.
Thanks !
Hi,
Check the following code this might be useful for you.
IWDNodeElement element = wdContext.getCurrentElement();
IWDAttributeInfo attrInfo = (IWDAttributeInfo)element.node().getNodeInfo().getAttribute(<<AttrName>>);
Object obj = element.getAttributeValue(<<AttrName>>);
if (attrInfo.getDataType().getAssociatedClass().isInstance(obj)){
//your code here - just printing here
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Data : "+obj.toString());
}
This thing works fine, but for primitive types like "boolean" and "int", it won't work.
Regards,
Santhosh.C
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
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.