• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to search items in arraylist using ejb?

 
drojokef durden
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello , i try to create a jsf project within ejb which is add new car with entering attributes listing attributes and search by make.

Add and list methods working well , but have problem of list method. I tryed many combinations (using enhanced loop , itarative loop) but i cant provide workink well. Alwayw outputText returns nothing ,when i enter attributes.

Here is ejb code for adding ,getting and listing car items :



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

Here is managedBean class code :



----------------------------------------------------------------------------------------------------------------------------
and finally search.xhtml code :

 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I added code tags to your post so it would be easier to read.)

You seem to have gone deep into the dark forest with that code. You have two nested loops where only one is necessary, and you're mixing indexes from the two loops which makes it even more confusing. But the main problem is that you never use the "make" variable which you're supposed to be comparing against the Car objects.

Here's some code which should work:



 
drojokef durden
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for reply Paul.I 've try it before. That time page returns only first element that found it.

}

and bean class :

}
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ceyhun erturk wrote:That time page returns only first element that found it.


Well, yes, that's the logical thing to do if you return a String and not a List<Car>. I wondered why that design was chosen, but I assumed this was a training exercise (and so doesn't have to make sense).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!