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
Trusted Contributor
kirthiga
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer
Accepted Solution

listfield issue

[ Edited ]

hi all ,

 

 

  am parsing URL tag using dom parser.this tag contains several url ids.

and i need to split that id into halves.

i had done that splitting. this the code which i had done

 

NodeList list2 = doc.getElementsByTagName("URL");
				for (int i = 0; i < list2.getLength(); i++) {
					Node textNode = list2.item(i).getFirstChild();
					//int i1 =
					urllist.addElement(textNode.getNodeValue());
					String a = textNode.getNodeValue();
					int b = a.length();
					
					int j = a.indexOf('?');
					 splittedString= a.substring(j,b);
					 urllist.addElement(splittedString);
					
				}

 

and in my screen1 i have implemented a list which contains the title of each section.

when i select a particular item in this it should direct me to next screen carrying the url which i had coded above.

 

now everything works fine. but when i select a item in my list of screen1 containing titles using this code,

 valueurl = (String) urllist.elementAt(_list.getSelectedIndex());

 

i get the exact splitted url id , but it doesnt match my selected item.

if i select the 2nd item of my list of titles i get url id of some other title.

 

can anyone help me to sort out  my problem ?

Please use plain text.
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: parsing problem

How is this a parsing problem? It sounds like it has more to do with bookkeeping related to the ListField, your list of titles, and urllist (a Vector, evidently).




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Developer
nitinverma274
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: parsing problem

When u get the substring then U start with

 

int j = a.indexOf('?');
splittedString= a.substring(j,b);
then Spliting String conatin the spllited String with ? sign.

 

I think U should start with Like this.

 

int j = a.indexOf('?');
splittedString= a.substring(j+1,b);

 

B'coz Ur String is after that ? Sign.

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

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

Thanks.

Please use plain text.
Trusted Contributor
kirthiga
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: listfield issue

[ Edited ]

no nitin , i tried as yu said .. its not working .. i get other titles urlid .. doen match ..

but the problem occurs after splitting the string i suppose .

Please use plain text.
Trusted Contributor
kirthiga
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: listfield issue

@ ted ,

 

 

  fine .. i might be wrong in choosing the topic name.

anyways the content of it is explained in detail.

any idea regarding this issue ?

Please use plain text.
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: listfield issue

My point was that you have not shown the relevant part of your code. How is the ListField being rendered? What is this list of titles that doesn't match the urls and how is it constructed? Have you checked (using the debugger) that the titles are in the same order as the urls?




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Trusted Contributor
kirthiga
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: listfield issue

can this line be changed to vector , so that it will contain all the urlids in it ..

 

String a = textNode.getNodeValue();

is that since it is a string it holds only one value ?

Please use plain text.
Trusted Contributor
kirthiga
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: listfield issue

[ Edited ]

fine ,

 

 

my listfield of titles is working fine .

 

this is how i get the titles

NodeList list1 = doc.getElementsByTagName("Title");
				for (int i = 0; i < list1.getLength(); i++) {
					Node textNode = list1.item(i).getFirstChild();
					listElements1.addElement(textNode.getNodeValue());
				}

 

 

 

valueurl = (String) urllist.elementAt(_list.getSelectedIndex());

 

    
	                 if (_list.getSelectedIndex() == 0)
						
	                	 UiApplication.getUiApplication().pushScreen(new nextscreen());
																		
					else if (_list.getSelectedIndex() == 1)
						
							UiApplication.getUiApplication().pushScreen(new nextscreen());
						
					else if (_list.getSelectedIndex() == 2)   

 

Please use plain text.
Developer
nitinverma274
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: listfield issue

First do one thing

Print the spillted String first. and check that what it is.

And U r right the problem is in ur spillted String.

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

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

Thanks.

Please use plain text.
Trusted Contributor
kirthiga
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: listfield issue

k will do it ..

Please use plain text.