-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hope your problem is resolved.. but my problem is still there and I thought that you can help me to get out of this problem.
actually I had multiple events to publish one by one as per user selection for eg: user select Season, Service, DateFrom and DateTo and then clicks on the refresh button.
When the refresh button is clicked I had used the above logic to get all the datas using the below mentioned code
public void onClick$ref(Event event){ if(lbox_service.getSelectedIndex() != 0 || lbox_season.getSelectedIndex() != 0) { if(lbox_service.getSelectedIndex() == 0) { setService_id("0"); } else { setService_id(lbox_service.getSelectedItem().getValue().toString()); } if(lbox_season.getSelectedIndex() == 0) { setSeason_id("0"); } else { setSeason_id(lbox_season.getSelectedItem().getValue().toString()); } System.out.println("Service Index 11 : "+ lbox_service.getSelectedIndex()); System.out.println("Season Index 11 : "+ lbox_season.getSelectedIndex()); EventQueue evtQ = EventQueues.lookup("myEventQueue", EventQueues.APPLICATION, true); //evtQ.publish(new Event("service_id", self, lbox_service.getSelectedItem().getValue().toString())); //evtQ.publish(new Event("season_id", self, lbox_season.getSelectedItem().getValue().toString())); evtQ.publish(new Event("service_id", self, getService_id())); evtQ.publish(new Event("season_id", self, getSeason_id())); //evtQ.publish(new Event("onClickRef", null, lbox_service.getSelectedItem().getValue().toString())); //evtQ.publish(new Event("onClickRef", null, lbox_season.getSelectedItem().getValue().toString())); /*.publish(new Event("onClickRef", null, lbox_service.getSelectedItem().getValue().toString())); EventQueues.lookup("myEventQu", EventQueues.DESKTOP, true) .publish(new Event("onClickRef", null, lbox_season.getSelectedItem().getValue().toString()));*/ } else { setService_id("0"); setSeason_id("0"); EventQueue evtQ = EventQueues.lookup("myEventQueue", EventQueues.APPLICATION, true); evtQ.publish(new Event("service_id", self, getService_id())); evtQ.publish(new Event("season_id", self, getSeason_id())); System.out.println("Service Index : "+ lbox_service.getSelectedIndex()); System.out.println("Season Index : "+ lbox_season.getSelectedIndex()); } }
now i had publish all my value and after that my new Controller run that will subscribe those published values. using the below code
public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); <b > EventQueues.lookup("myEventQueue", EventQueues.APPLICATION, true)</b> .subscribe(new EventListener() { public void onEvent(Event event) throws Exception { /*String service = (String) event.getData(); logger.info("Servive $$$$$$$$$ " + service); //String season = (String) event.getData(); //logger.info("Season $$$$$$$$$ " + season); */ if("service_id".equals(event.getName())) { setService_id((String) event.getData()); baseController.setFilter_bar(true); System.out.println("Service Id :" +event.getData()); } else if("season_id".equals(event.getName())) { setSeason_id((String) event.getData()); baseController.setFilter_bar(true); System.out.println("Season Id :" +event.getData()); } /*setService_id((String) event.getData()); setSeason_id((String) event.getData());*/ /*if("season_id".equals(event.getName())){ setSeason_id((String) event.getData()); }else { setSeason_id("0"); }*/ System.out.println("Filter bar :" +baseController.isFilter_bar()); if(baseController.isFilter_bar() == true) { String dateFrom = ""; String dateTo = ""; String order = "2"; List TDRetailers = verificationStoreHibernateDao.getTraditionalRetailers(getService_id(), getSeason_id(), dateFrom, dateTo, order); //VerificationStoreHibernateDao storeHibernateDao = new VerificationStoreHibernateDao(); //List TDRetailers = this.verificationStoreHibernateDao.getTraditionalRetailers(service_id); //ListModel listModel = this.retailers.getModel(); ListModelList listModelList = (ListModelList) retailer.getModel(); listModelList.clear(); listModelList.addAll(TDRetailers); baseController.setFilter_bar(true); } } }); }
but actully my problem is with running the query and with getting those published values. Based on them I will be able to run my Traditional getTraditionalRetailers queries.
My problem is
1. how to publish multiple events values. Is it the right way that I had done.
2.as I had done separate publish, everytime I publish new value The query runs, the result is that i had mutiple time query execution. for example If i will publish two values the queries run's for the two times and if I publish three values the query executes for three time.
I don't know what is their problem. .
help me to solve my error..
Hard to understand what you mean. And it's not better to post this under several threads :-(
OK. As i understand you right. You will send multiple event values. The problem in your case seems to me that you take ONE visual component that show the result. So it's all times overriden from different events and shows only the last subscribed message. It's not possible to show the values in different components that reflects the sense of each value?
best
Stephan
PS: Think all time that this is a web application. Means http protocol. One request One answer. So the last will win.
Asked: 2011-02-21 02:13:47 +0800
Seen: 382 times
Last updated: Feb 21 '11