0

setVariable is deprecated ? why ?

asked 2009-12-06 12:30:07 +0800

vdrockywang gravatar image vdrockywang
120 2 4

I found IDE tell me it's deprecated about "comp.setVariable(comp.getId() + "Ctrl", this, true);"
Is any newer way to write MVC ?

Is there any article will introduce it ?

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2009-12-06 20:21:51 +0800

iantsai gravatar image iantsai
2755 1

you can use setAttribute instead.

link publish delete flag offensive edit

answered 2009-12-06 20:26:18 +0800

vdrockywang gravatar image vdrockywang
120 2 4

Is there any different ?
If i still use setVariable, is any shortcoming for me ?

link publish delete flag offensive edit

answered 2009-12-07 00:46:11 +0800

iantsai gravatar image iantsai
2755 1

if your code need to migrate to future version of ZK, you will have compiling error after compiling.

link publish delete flag offensive edit

answered 2009-12-14 19:16:02 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

updated 2009-12-14 19:18:07 +0800

Like "deprecate" means in ALL Java libraries, it means the API is kept there for "backward compatibility and might be removed in the future". So new created application will not "misuse" the API again.

The replaced method shall be written in Java doc of the "deprecated" one and take a detail look on the "Upgrade Note" of the ZK release-note.

link publish delete flag offensive edit

answered 2009-12-14 23:49:09 +0800

edusaj gravatar image edusaj
3

you can use setAttribute instead.

link publish delete flag offensive edit

answered 2009-12-15 10:12:47 +0800

robertpic71 gravatar image robertpic71
1275 1

The attribute seems no datasource for EL. I use this sometimes to get the same name for EL's and @databinding ("controller", "model").

This smalltalk (Fusioncomposer) uses setVariable for EL.
How is the new way for register a EL-Datainterface?
(like this smalltalk)

Note: I use actually cmp.setVariable("controller", this, true); to set the composer as datasource controller for EL.

/Robert

link publish delete flag offensive edit

answered 2009-12-20 20:12:39 +0800

iantsai gravatar image iantsai
2755 1

You can do this by implements you own Variable Resolver interface: org.zkoss.xel.VariableResolver, and use it like this:
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>

link publish delete flag offensive edit

answered 2009-12-21 21:01:53 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

updated 2009-12-21 21:02:39 +0800

@Robert,

Use cmp.setAttribute("controller", this, Components.SPACE_SCOPE) instead. It is almost identical to cmp.setVariable("controller", this, true)

cmp.setVariable keeps value (the "this") in component "cmp"'s ID space owner. And EL can refer it via its given key "controller".

link publish delete flag offensive edit

answered 2009-12-22 06:41:30 +0800

robertpic71 gravatar image robertpic71
1275 1

Henri, Iantsai

thanks for the answers. There are 2 threads. We found the answer in the other thread.

Other Thread

in short:
cmp.setAttribute("controller", this, Components.SPACE_SCOPE) works for EL, but not in the old ZK-Versions (i've changed my 3.6 example).

/Robert

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: 2009-12-06 12:30:07 +0800

Seen: 1,571 times

Last updated: Dec 22 '09

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