0

Listbox selectedItem not refreshing other databound components (inplace)

asked 2011-07-18 18:03:26 +0800

jsanchez gravatar image jsanchez
30 1

updated 2011-07-18 18:21:03 +0800

I have a listbox with inplace components, when i change the selected row in the listbox from one row to another and i go directly to inplace and edit the value of the component, the grid below does not refresh it's values. On the other hand if i select the row without going into inplace mode everything works fine.

If i do a binder.loadAll everything works fine, but i loose the inplace edition.

So to sum it up, when i go into inplace the gridForma isn't updated, but if i select the row without going into inplace everthing works fine.

Heres the code...(I've updated it so its pretty easy to reproduce)

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<window width="500px">
	<zscript><![CDATA[
	//prepare the example persons List
	import com.zk.selecteditem.*;
	int count = 30;
	List persons = new ArrayList();
	for (int j = 0; j < count; ++j) {
		Person personx = new Person();
		personx.setFirstName("Tom" + j);
		personx.setLastName("Hanks" + j);
		persons.add(personx);
	}
	Person selected = new Person();
]]>
</zscript>
	<listbox rows="4" model="@{persons}" selectedItem="@{selected}">
		<listhead>
			<listheader label="First Name" width="100px" />
			<listheader label="Last Name" width="100px" />
			<listheader label="Full Name" width="100px" />
		</listhead>
		<!-- define variable person here-->
		<listitem self="@{each='person'}">
			<listcell>
				<textbox inplace="true" value="@{person.firstName}" />
			</listcell>
			<listcell>
				<textbox inplace="true" value="@{person.lastName}" />
			</listcell>
			<listcell label="@{person.fullName}" />
		</listitem>
	</listbox>

	<grid width="400px">
		<rows>
			<row>
				First Name:
				<textbox value="@{selected.firstName}" />
			</row>
			<row>
				Last Name:
				<textbox value="@{selected.lastName}" />
			</row>
			<row>
				Full Name:
				<label value="@{selected.fullName}" />
			</row>
		</rows>
	</grid>
</window>

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-07-19 10:31:55 +0800

jsanchez gravatar image jsanchez
30 1

Bump, i've seen other posts with no solid solution, anyone have a tip?

link publish delete flag offensive edit

answered 2011-07-19 10:56:30 +0800

twiegand gravatar image twiegand
1807 3

jsanchez,

Which version of ZK are you running?  I can't seem to reproduce the problem...

Regards,

Todd

link publish delete flag offensive edit

answered 2011-07-19 14:53:23 +0800

robertpic71 gravatar image robertpic71
1275 1

Hi Jsanchez,

i see no "real" fault. Update seems to work for me (tried in the livedemo).

Of course, there one "ugly" condition:

>> a click for direct inplace editiing do NOT SELECT the Listitem >> the detail below (=selectedITem) is the previous selected Listitem
I would say: 50% bug, 50% feature request

If you first selecct the Item (click to an output field) and after that click to the inplaceedit --> everthing works

----------------
Note: there is no instant change (after each keystroke), update is done after each fieldexit
if you expect update character by character you have to catch all onChanging-Events....


For easier testing, here is the adopted code - running in the ZK Sandbox:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./mywin"?>
<window id="mywin" width="500px">
	<zscript><![CDATA[
	//prepare the example persons List
	import org.zkoss.zksandbox.Person;
	int count = 30;
	List persons = new ArrayList();
	for (int j = 0; j < count; ++j) {
		String _firstName = "Tom" + j;
                String _lastName = "Hanks" + j;
                Person personx = new Person(_firstName, _lastName);
		persons.add(personx);
	}
	Person selected = persons.get(0);
]]>
</zscript>
	<listbox rows="4" model="@{persons}" selectedItem="@{selected}">
		<listhead>
			<listheader label="First Name" width="100px" />
			<listheader label="Last Name" width="100px" />
			<listheader label="Full Name" width="100px" />
		</listhead>
		<!-- define variable person here-->
		<listitem self="@{each='person'}">
			<listcell>
				<textbox inplace="true" value="@{person.firstName}" />
			</listcell>
			<listcell>
				<textbox inplace="true" value="@{person.lastName}" />
			</listcell>
			<listcell label="@{person.fullName}" />
		</listitem>
	</listbox>

	<grid width="400px">
		<rows>
			<row>
				First Name:
				<textbox value="@{selected.firstName}" />
			</row>
			<row>
				Last Name:
				<textbox value="@{selected.lastName}" />
			</row>
			<row>
				Full Name:
				<label value="@{selected.fullName}" />
			</row>
		</rows>
	</grid>
</window>

link publish delete flag offensive edit

answered 2011-07-19 16:53:53 +0800

jsanchez gravatar image jsanchez
30 1

Thanks for the tips guys, I have been able to solve this, here's what i needed to do...

Add the following onClick event to each listcell

<listcell>
	<attribute name="onClick">
	Integer iIndex = ((Listitem)self.getParent()).getIndex();
	lbox.setSelectedIndex(iIndex);
	Events.sendEvent(lbox, new Event(Events.ON_SELECT, lbox));
</attribute>

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-07-18 18:03:26 +0800

Seen: 384 times

Last updated: Jul 19 '11

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