0

How to do data binding using MVC Style with ZK 7

asked 2014-02-27 00:16:00 +0800

TRATOR gravatar image TRATOR flag of Brazil
96 1
http://www.codelimit.com....

updated 2014-02-27 00:16:34 +0800

Hello ZK warriors.

I´d like to ask if you guys know how to implement data binding using MVC style with ZK 7.

In earlier versions I used to implement like this:

zul´s file:

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./wndIndex"?>
<window id="wndIndex" apply="IndexComposer">
   <textbox id="txtName" value="@{$composer.user.name}" />
</window>

composer´s file:

org.zkoss.zkplus.databind.AnnotateBinder binder

def onCreate_wndIndex(Event event) {
    binder = (AnnotateBinder) event.target.getAttribute("binder", true);
}

but in ZK 7 the classes from org.zkoss.zkplus.databind.* are now deprecated.

Which classes should I use now? Does someone have a working example?

Best regards,

Felipe Ribeiro

delete flag offensive retag edit

4 Answers

Sort by » oldest newest most voted
0

answered 2014-02-28 11:28:19 +0800

MVarun gravatar image MVarun flag of India
268 1 6

Hi Felipe Ribeiro,

Here I'll rewrite the above code in MVC Style...

In Zul page:

<window id="wndIndex" apply="packageName.JavaClassname">
       <textbox id="txtName" />
</window>

In Java Class:

public class JavaClassName extends GenericForwardComposer // ! IMPORTANT
{
    Window wndIndex;
    Textbox txtName;

   public void doAfterCompose(Component comp) throws Exception 
   {
       super.doAfterCompose(comp);

       win_parentportal.setAttribute("win_parentportal", this);

    someMethodName();
    }
    public void someMethodName()
      {
             txtName.setValue("Hello"); OR
             txtName.setText("Hello"); 
      }
}

Here extending GenericForwardComposer is importsnt to bind.

Greetings..

M Varun.

link publish delete flag offensive edit
0

answered 2014-02-28 22:13:37 +0800

TRATOR gravatar image TRATOR flag of Brazil
96 1
http://www.codelimit.com....

updated 2014-03-01 00:57:03 +0800

Thanks for replying Varun.

But actually my problem is not wiring my zul with my controller.

My base of implementation rely on this example http://emrpms.blogspot.in/2013/01/zk-mvc-crud-with-spring-3-jpa-hibernate_20.html

where Senthil Muthiah implemented a binder with org.zkoss.zkplus.databind.*

but as a said before in ZK 7 all classes from the package org.zkoss.zkplus.databind.* are deprecated

so I want to use another set of classes to archive this same result

Best regards,

Felipe Ribeiro

link publish delete flag offensive edit
0

answered 2014-03-01 18:48:07 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

Mine guess is it this :

org.zkoss.bind.AnnotateBinder
Pitty that they didn't add the new class in comment when they set the @Deprecate

Greetz chill.

link publish delete flag offensive edit
0

answered 2014-03-05 16:00:07 +0800

TRATOR gravatar image TRATOR flag of Brazil
96 1
http://www.codelimit.com....

Thanks for your help Chill.

I´ll try to use this set of classes in org.zkoss.bind package

Unfortunatelly all examples for org.zkoss.bind package, including zk´s demos only shows implementation using MVVM style.

If I come out with something I´ll post here later and if someone archives this goal please feel free to help too =)

Best regards,

Felipe Ribeiro

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
3 followers

RSS

Stats

Asked: 2014-02-27 00:16:00 +0800

Seen: 59 times

Last updated: Mar 05 '14

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