0

<attribute name="onClick"> : - what is the equivalent for on load?

asked 2010-08-24 11:26:07 +0800

Jameszk gravatar image Jameszk
48 1

Hi I have some code that can be used to update the screen when I click on a grid.

<grid id="summaryGrid" model="@{winTwSignals$composer.trainwireClassEventsList, load-after='timeRangeCombo.onChange, dateTimeBox.onChange'}"
style="width:800px; height:235px; overflow:auto">
<attribute name="onClick">
do stuff to update the screen
</attribute>

What code do I need to update the screen once the grid has loaded. (I need to do this because it has to do with bing maps, I need to manipulate a bing maps javasript object, unfortunately)

I have tried
<attribute name="onMove">
and onFocus
onLoad -everything. Can anyone make any suggestions? I want to update the sceen once it has loaded using javascript but without clicking (onclick).

Thanks
James

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-08-24 11:27:38 +0800

Jameszk gravatar image Jameszk
48 1

updated 2010-08-24 11:57:26 +0800

P.S. the full code in the attribute block is:

<attribute name="onClick">
winTwSignals$composer.setMapParameters(true);
jsonMapPins = gen.getPointsArrayJson();
jsonMapDetails = gen.getMapDetailsJson();
Clients.evalJavaScript("removePins();");
Clients.evalJavaScript("setupMap(" + jsonMapPins + ");");
</attribute>

Can anyone help?
Just to repeat, I need a replacement for "onClick" that doesn't require clicking - but works automatically, rather like an onload type event.

link publish delete flag offensive edit

answered 2010-08-24 13:13:14 +0800

robertpic71 gravatar image robertpic71
1275 1

Some ideas:

1.) Manage the databinding inside the composer:
Instead of load-after='timeRangeCombo.onChange, dateTimeBox.onChange'
you have to catch
onChange$timeRangeCombo
onChange$dateTimeBox

binder.loadAll(); // fill the grid
Clients.eval...

2.) Create a dummy field (behind the grid)
<label id="updateMapDummy" visible="false" value="@{winTwSignals$composer.updateMap, load-after='timeRangeCombo.onChange, dateTimeBox.onChange'}"/>

public String updateMap() {
Clients.eval....
return null;
}

3.) Timer event (wait for 500 ms) and update onTimer

/Robert

link publish delete flag offensive edit

answered 2010-08-24 20:05:13 +0800

samchuang gravatar image samchuang
4084 4

Hi

another idea, use onInitRender

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
	<zscript><![CDATA[
	List ary = new ArrayList();
	ary.add("1");
	ListModelList model = new ListModelList(ary);
	ListitemRenderer re = new ListitemRenderer() {
		public void render(Listitem item, Object data) throws Exception {
			item.appendChild(new Listcell(obj.toString));
		}
	};
]]></zscript>
	<grid id="grid" model="${model}">
		<attribute name="onInitRender">
			List l = model.getInnerList();
			for (Object obj : l) {
				System.out.println(obj.toString());
			}
		</attribute>
	</grid>
	<button label="Add model" onClick='model.add("2")'></button>
</zk>

link publish delete flag offensive edit

answered 2010-08-25 02:21:52 +0800

Jameszk gravatar image Jameszk
48 1

updated 2010-08-25 02:22:56 +0800

Thanks guys, much appreciated! The "onInitRender" event did the trick.

I spent time reading though documentation, e.g. here:

http://www.zkoss.org/javadoc/2.2.0/zk/org/zkoss/zk/ui/event/Events.html

and I did not find this "onInitRender" event documented. I now realise that I needed to look at the components methods, e.g.
The XUL Components Components Listbox

Live and learn.

Anyway, this has fixed my problem, much appreciated and long live open source! (We'll be buying more support soon by the way).

Cheers,
James

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-08-24 11:26:07 +0800

Seen: 719 times

Last updated: Aug 25 '10

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