0

StatusBarController with EventQueues mechanism

asked 2010-07-08 08:36:01 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-07-08 08:37:03 +0800

Hi all,

I'm worry about my old statusBar and how i access it to actualize the values. So i spend a little time for do it now with the new EventQueues mechanism that 's shipped with the zk 5.x versions.

You can read and copy the codes from http://www.forsthaus.de/blog/?p=515.

Have fun with it.

best
Stephan

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-02-21 02:11:57 +0800

yaryan997 gravatar image yaryan997
210 2

Hi...

@terrytornado

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..

link publish delete flag offensive edit

answered 2011-02-21 06:24:25 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2011-02-21 06:28:16 +0800

Look here.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-07-08 08:36:01 +0800

Seen: 1,890 times

Last updated: Feb 21 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More