Hello all.
Im a bit lost and all out of ideas on how to solve my problem:
A lil background:
im filling a ShowPanel with different shows being given in a theatre (connected to DAO classes, that in their turn get values out of a database) , and then when you choose from this you get several dates. Then when you click a date, the seatings appear in the SeatPanel.
I got the first part with the shows and dates. But Im stuck at getting the seatings.
I have a controller class which calls the shows+dates (this happens in one method). But i always get a nullpointerexception for the seatings. (this happens in a different method).
I think i just don't know how to link the chosen show+date with the seatings.
For the moment i have :
public ArrayList<Seats> getSeating() throws SeatingException{ ArrayList<Place> seating = new ArrayList<Place>(); PlaceDAO pdao = PlaceDAO.getInstance(); try{ for (Show s : show ) { ArrayList<Showdate> showdate = s.getDates(); for (Showdate sd : showdate ){ seating.addAll(pdao.getSeating(sd)); } } } catch (SeatingException e) { JOptionPane.showMessageDialog(null, e.getMessage(),"No seatings found", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } return seating; }
The code to get the shows and dates is the following :
So this part works..public ArrayList<Show> getShows() throws ShowException { try{ ShowDAO sdao = ShowDAO.getInstance(); show= sdao.getShows(); } catch (ShowException e) { JOptionPane.showMessageDialog(null, e.getMessage(),"No shows found", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } return show; }
The given class PlaceDao has a static getInstance() method and an ArrayList<model.Place> getSeating(model.Showdate showdate) method.
In the next stage i have to try and fill the panel with the seatings, but first i need to be able to call them.
Please help me, i need it.
the NullPointerException points to :
seating.addAll(pdao.getSeating(sd));
but this can't be. The pdao. is definitely filled with values
so why isn't it responding ?