Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700
Accepted Solution

objectchoicefield and objectlistfield

i have successfully implemented objectlistfield by parsing xml...i have  also successfully implemented objectchoicefield by parsing xml and storing value into string array ...

 

nw when i select an option from objectchoicefield i want only details of tht particular option to b displayed into my objectlistfield...hw to do dis???

Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700

Re: objectchoicefield and objectlistfield

its lyk d drop down box on top right corner...v select a topic n den after clickin on search v r diverted to tht particular topic ...same thing i wana implement wid objectchoicefield n objectlistfield...

 

for eg : selecte a company name from objectchoicefield n in my objectlistfield i want to display details of tht particular selected company lyk its loc,contact no etc etc...

Developer
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone

Re: objectchoicefield and objectlistfield

Hi,

 

you can set the FieldChangeLIstner and you can get the change event in change method write your code and you can get the selectedindex of objectchoicefield so please try this.

 

Regards

Tita

 

---------------------------------------------------------------------------------------------------------------------------------------

please mark it as kudos if it helps you or mark it as solved if you get the prooper solution you want.

Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700

Re: objectchoicefield and objectlistfield

FieldChangeListener lst_1 = new FieldChangeListener(){
public void fieldChanged(Field field,int context){
     
  
  if(field instanceof Field){
    ObjectChoiceField test=(ObjectChoiceField)field;
    String str =(String)test.getChoice(test.getSelectedIndex());
    UiApplication.getUiApplication().pushScreen(new prac(str));
    
  
    }

 

this is wat i did but when i chose an option from objectchoicefield control jumps to nextscreen but complete list is displayed...d 1 which i chose from objectchoicefield i want only details of  tht particular item 2 b selected from d objectlistfield  n displayed

Developer
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone

Re: objectchoicefield and objectlistfield

Hi

 

Did you check the str object what you get in str?if you pass the single string then you have to short the data and then show the data or post our code here

 

Regards

Tita

Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700

Re: objectchoicefield and objectlistfield

1st xml file..for ObjectChoiceField

 

NodeList list = doc.getElementsByTagName("companyname");

 

String[] labels = new String[list.getLength()];
 


   for (int i = 0; i < labels.length; ++i) {
      labels[i] = list.item(i).getFirstChild().getNodeValue();
 }
  
   ObjectChoiceField obc=new ObjectChoiceField("Item : ",labels,0,ObjectChoiceField.FIELD_LEFT);

   add(obc); 

 

this is how i got companynames in2 my objectchoicefield...

 

 

2nd xml file...for ObjectListField

 

 

 

NodeList list = document.getElementsByTagName("CompanyName");

     
             for (int i=0;i<list_1.getLength();i++){
                
           
        Node value=list.item(i).getChildNodes().item(0);

 

                     listfield.insert(i);
                
                    v1.addElement(value.getNodeValue());

 

dis is how i got CompanyName from 2nd xml file in2 my objectlistfield..i hv 2 different xml files..

 

nw i want companyname frm 1st xml i.e objectchoicefield to search CompanyName frm 2nd xml i.e objectlistfield and if dey match den display d detail of tht particular company...m new to bb java development so i hv no idea hw 2 do it..

 

 

dis is d fieldchangelistener of objectchoicefield ..

 

FieldChangeListener lst_1 = new FieldChangeListener(){
public void fieldChanged(Field field,int context){
     try{
 
  if(field instanceof Field){
    ObjectChoiceField test=(ObjectChoiceField)field;
    String str =(String)test.getChoice(test.getSelectedIndex());
    UiApplication.getUiApplication().pushScreen(new prac(str));
    
  
    } }
catch(ClassCastException e){
    e.printStackTrace();
    }
}
};

 

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: objectchoicefield and objectlistfield

When the Company is selected then the company Detail is also kept in the Xml file.

Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700

Re: objectchoicefield and objectlistfield

my first xml file which m using for objectchoicefield has only companynames in it...my 2nd xml file which m using for objectlisfield has d companynames wid detail..

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: objectchoicefield and objectlistfield

Ok.

Now U have to do that, on the select event of ObjectchoiceField,

U have the Company names in a String Arrray.

Now Parse the Xml file which have the Company names with Details.

And Put a Check to Comapre the Company names if match then parse All tags and get Values if not then increment the Loop.

 

------------------------------------------------------------------------------------

Press Kudoes and Accept as solution Button, If u got Answer.

Thanks.

 

Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700

Re: objectchoicefield and objectlistfield

can u show me a code snippet???