0

Problem reloading a dropbox value

asked 2013-01-14 16:26:13 +0800

jbiscella gravatar image jbiscella
9

updated 2013-01-14 16:26:44 +0800

Hi all, I'm very sorry for the question, but even if I looked a lot in the forum and online I can't find a solution to this simple questio:

I'm using org.zkoss.bind.BindComposer for binding and I want to update a doublebox value when an element from a listbox is selected.

I binded correctly the listbox and tried to alterate the values binded to the doublebox by acting on the getters and setters of the selecteditem, but even if the values changes on the debugger they are not updated on the view;
the zul code is the following:

<listbox model="@id('opts') @bind(domanda.sectorOptions)"
		selectedItem="@bind(domanda.selectedItem)" onSelect="@command('countValues')"
		emptyMessage="Daabase connection error, please contact the MIPEL Secretariat">
		<listhead>
			<listheader width="560px" label="Opzione" ></listheader>
			<listheader width="200px" label="Costo al metro quadro" ></listheader>
			<listheader width="200px"
				label="metratura minima consentita" ></listheader>
		</listhead>
		<template name="model" var="opt">
			<listitem>
				<listcell label="@load(opt.labelIt)" ></listcell>
				<listcell label="@load(opt.cost)" ></listcell>
				<listcell label="@load(opt.minArea)" ></listcell>
			</listitem>
		</template>
	</listbox>
	<hbox>
		<label width="135px" value="Metri quadrati" ></label>
		<doublebox id="sm" value="@bind(domanda.squareMeters)"  ></doublebox>
	</hbox>

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2013-01-15 05:28:39 +0800

roliroli gravatar image roliroli
164 4

updated 2013-01-15 05:28:54 +0800

Yes, you're right.

But in ZUL
maybe value="@bind(vm.example.value)" in doublebox tag is redundant.

If you want to use @bind approch
use a variable in your ViewModel and @Notifychange("variable") on the @command method

There're many ways to implement same thing, so choose the way you like.

http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/Syntax/ViewModel/@NotifyChange

link publish delete flag offensive edit
0

answered 2013-01-14 20:06:51 +0800

jbiscella gravatar image jbiscella
9

updated 2013-01-14 20:16:41 +0800

so... to be sure cause it's not working the way I'm doing it:

Java

...
@Wire
private Doublebox example;
          ...
          @AfterCompose
	  public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
		    Selectors.wireComponents(view, this, false);
	  }
...
public void letsTest(){
          ...
          example.setValue("Hello world");
          ...
}
...

Zul

...
<doublebox id="example" value="@bind(vm.example.value)">

is it right?

link publish delete flag offensive edit
0

answered 2013-01-14 17:26:56 +0800

roliroli gravatar image roliroli
164 4

Hello, jbiscella

1. use @Wire annotation on "Doublebox" in your ViewModel.
2. use Selectors.wireComponents(view, this, false); in your @aftercompose phase. (If you're using version before 6.5, use @Init instead.)

@bind in ZUL will auto update the value, just like you saw in debugger. Just wire your component with ViewModel, UI will update automatically.

link publish delete flag offensive edit
0

answered 2013-01-14 17:11:52 +0800

jbiscella gravatar image jbiscella
9

No, thank you for the suggestion, but how it works? does I only need to annotate the variable or also to use setValue?

link publish delete flag offensive edit
0

answered 2013-01-14 16:59:23 +0800

roliroli gravatar image roliroli
164 4

updated 2013-01-14 17:07:00 +0800

Hi,

Did you remember wire component in viewmodel?

http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/Advance/Wire%20Components

link publish delete flag offensive edit
Your answer
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: 2013-01-14 16:26:13 +0800

Seen: 67 times

Last updated: Jan 15 '13

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