0

composer - getData beforeCompose

asked 2011-06-15 15:43:48 +0800

ftmichael gravatar image ftmichael
129 1

updated 2011-06-15 15:45:50 +0800

hey,
and yet another problem.

i'm using javascript in my zul file:

<script type="text/JavaScript">
 				 <![CDATA[
 				function init() {
 				var data = '${mapView$composer.data}'.evalJSON();
 				for (var key in data) {
						if (data.hasOwnProperty(key)) {
							alert(key);
						  }
					}
 				}
  				]]>
			</script>

the problem is as follows:
in my composer i have a method getData:

//this work fine if i hardcode the objects
public JSONArray getData(){
		JSONArray a = new JSONArray();
		a.push("m3");
                a.push("m4");
		return a;
	}

now i want to do the following:

MyWindow container = (MyWindow) comp.getParent();

public JSONArray getData(){
//this won't work because javascript calls the method before the page is composed, therefore container = null;
		JSONArray a = new JSONArray();
		List<String> list = new ArrayList<String>();
		list = container.getList();
		
		for(String str : list){
			a.push(str);
		}
		return a;
	}

how can i solve this, i have to access the getList() methode from my window.

thanks.

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2011-06-15 18:08:25 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

Why are you doing all this AJAX by hand? If you're going to use ZK, let it do it for you. Hook the doBeforeCompose(...) method of your composer and set an attribute that has your list as the value.

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: 2011-06-15 15:43:48 +0800

Seen: 361 times

Last updated: Jun 15 '11

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