cancel
Showing results for 
Search instead for 
Did you mean: 

Validations not working in BlackBerry

Former Member
0 Kudos

Hi All,

I am implemeting an applcation which is expected to work both on Desktops as well as Blackberry. I am almost done with it, but stuck with some of most common and important functionallities.

1. Validations: Here I am trying to check whether on the input screen atleast some inputs fields are keyed in (the requirment is scuh that i cant make fields mandatory). I wrote code for this which works perfectly in IE but when it comes to blackberry, even though no inputs are specified the navigation happens to next screen. I cant find why is this behaviour with Blackberry. I have serached a lot on this but couldnt find anything specific on this.

if (wdContext.Current<NodeElement>.get<Context_attribute == null>)
 {
 wdComponentAPI.getMessageManager().reportException("Specify some inputs", true)
 }

2. Resetting Inputs Fields: Currently i have two views in application and the results are showed in the second view. I want to reset all the input fields when we navigate to the input view so that we can enter new values. I tried doing this using in wdDoModifyView method of input view.

 if (firstTime == false)
 {
  wdContext.Node<NodeElement>.invalidate()
 }

However this deletes the node itself and all the inputs fields are greyed out when I return to the first screen. I have gone through this thread regarding invalidate() method but still it leaves me confuesed

Please share your valuable thoguhts on this.

Thanks

Hussain

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hussain,

1. Validation : Try below code :


if (wdContext.Current<NodeElement>.get<Context_attribute> != null)
{
        if(wdContext.Current<NodeElement>.get<Context_attribute>.trim() != "")
        {
           --- your code---
        }
       else
       {
         wdComponentAPI.getMessageManager().reportException("Specify some inputs", true)
        }
} 
else
       {
         wdComponentAPI.getMessageManager().reportException("Specify some inputs", true)
        }

2. Resetting Inputs Fields:

When you invalidate the node it removes all its elements. While binding the value property of an input field you must have at least one element to the node. hence set the individual attribute to null.

Regards

Deepak

Former Member
0 Kudos

Hi Deepak,

Thanks for the hints. I however figured out the problem and looks very strange to me. Like i said before i am trying to validate whether any of the inputs fields are empty. using the code as mentioned in my previous post it works as expected in IE.

Additionally I used this piece of code for validation. Strange thing is the application dumps in IE with Null Pointer Exception but works great in Blackberry.

if (wdContext.Current<NodeElement>.get<Context_attribute> != null)

P.S: Sorry this got posted mistakenly and is incomplete. Below is the complete post.

Edited by: Hussain on Jan 31, 2011 12:48 PM

Former Member
0 Kudos

Hi Deepak,

Thanks for the hints. I however figured out the problem and looks very strange to me. Like i said before i am trying to validate whether any of the inputs fields are empty. using the code as mentioned in my previous post it works as expected in IE.

Additionally I used this piece of code for validation. Strange thing is the application dumps in IE with Null Pointer Exception but works great in Blackberry.

if (wdContext.Current<NodeElement>.get<Context_attribute> != null)
 {
    if (wdContext.Current<NodeElement>.get<Context_attribute>.length () != 0)
      {
          ----some code logic here------
      }
      else
      {
        wdComponentAPI.getMessageManager.reportException("Enter this value",true);
      }
  }

Aslo I am facing another issue. Suppose I have four input fileds a1 a2 a3 a4 and the application is developed using ARFC Model to return the sum of these four fields.

For the first run If i only enter a1 and a2, I would get the sum a1 and a2 correctly. In the next run if I leave a1 and a2 blank and enter a3 and a4, it is computing the sum of a1 a2 a3 and a4. The values of a1 and a2 are being picked up from the model node. Can any one suggest how to clear/flush the model nodes so that each time it takes new values.

Thanks

Hussain

Former Member
0 Kudos

Hi Hussain,

For the first issue, check the cardinality of your node. At lease one element should be present when validating.

For second issue, Set the values of a1 and a2 to null when passing the input parameters for second run.

Regards

Deepak

Former Member
0 Kudos

Hi Deepak,

I have checked the cardinallity and it is set appropriately. I guess the applcition doesnt recongnize null value comparision when executed in WML browser and it passes through the IF condition even though it should not. However when i additionally used attribute length for comparision it works fine in Blackberry but it goes for a Null Pointer Exception dump in IE because of the lenght() statement.

For the second issue i have tried this already and it dosent seem to work. Searching on the forum there are few suggestion for deleting the model instance by using diconncetifAlive(). Any more thoughts on this ?

Thanks

Hussain

Answers (0)