0

I cannot get databinding to work with listbox.

asked 2010-12-28 10:28:22 +0800

orthello gravatar image orthello
18 2

<hbox id="hboxx" spacing="0" apply="us.fed.nmcourt.jaa.u.UserAdminGFC">
<groupbox>
<listbox id="usersLB" multiple="true" rows="14" model="@{hboxx$composer.users}">
<listhead>
<listheader label="Users"/>
</listhead>
<listitem self="@{each='user'}" value="@{user}">
<listcell label="@{user.fullname}"/>
</listitem>
</listbox>
</groupbox>
...

public class UserAdminGFC
extends DbSessionGFC
{
private List<User> cAllUsersL;
...

public List<User> getUsers ()
throws SQLException,
SqlExecutorException
{
Connection _C = getDbConnection ();
try
{
SelectUserListSql _SULS = new SelectUserListSql ( _C );

cAllUsersL = _SULS.getSelectResult ();
}
finally
{
_C.close ();
}

return cAllUsersL;
}
...
}

public class User
{

...
private String cFullName;

public User ()
{
}

...
public void setFullName ( String fullName )
{
cFullName = fullName;
}

public String getFullName ()
{
return cFullName;
}
...
}


The method getUsers is never called.
Shouldn't the following line make getUsers get called?
<listbox id="usersLB" multiple="true" rows="14" model="@{hboxx$composer.users}">

One wierd thing is that all my onClick@xxx methods within UserAdminGFC are called
correctly. What am I missing?

James Wilson
jwilson@nmcourt.fed.us
(505) 228-5233

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2010-12-28 13:26:57 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

1) You see the # button above the forum text editor alongside the B, I, & U? It's for code. It sure makes reading your code much easier.
2) You didn't show all of your ZUL file. Did you put the AnnotateDataBinderInit in it?

link publish delete flag offensive edit

answered 2010-12-28 14:45:25 +0800

orthello gravatar image orthello
18 2

Cary, thanks for your response.

I did put AnnotateDataBinderInit in it.

I think the problem has to do with the fact that I create
tabbedpanels dynamically and then make a include call to include
the zul for each tabbedpanel. When I put AnnotateDataBinderInit
in my include call I get an error because AnnotateDataBinderInit
has already been used.

<zk>
    <?init class="us.fed.nmcourt.jaa.db.CreateDatabasePoolInitiator"?>
    <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
    <window
        id="mainWindow"
        title="Judge Assignment Application"
        border="normal"
        position="center"
        mode="modal"
        closable="true"
        apply="us.fed.nmcourt.jaa.win.MainWindowGFC">
        <tabbox id="mainTabBox">
            <tabs id="mainTabs">
                <tab id="loginTab" label="Login"/>
            </tabs>
            <tabpanels id="mainTabPanels">
                <tabpanel id="loginTabPanel">
                    <include src="login.zul"/>
                </tabpanel>
            </tabpanels>
        </tabbox>
    </window>
</zk>

link publish delete flag offensive edit

answered 2010-12-29 09:59:44 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

I haven't added tabs dynamically, but others on the forum have. I think you're going to need to have a reference to the binder in your GFC subclass and add the tabpanel as a component so that the binder knows about it. When the binder initiates, your tab panel isn't there, so it doesn't do any binding.

add

private AnnotateDataBinder binder = null ;

to your controller and see if any of the AnnotateDataBinder::addBinding(...) methods can be used.

link publish delete flag offensive edit

answered 2010-12-29 10:34:09 +0800

orthello gravatar image orthello
18 2

Ok, if I wait to include AnnotateDataBinderInit until after all my dynamic tabpanels are loaded then databinding works.
What is the best way to invoke AnnotateDataBinderInit programatically?

link publish delete flag offensive edit

answered 2010-12-29 10:37:16 +0800

orthello gravatar image orthello
18 2

Cary, just saw your response. Thanks for your response.
I'll look into you suggestion right away.

James

link publish delete flag offensive edit

answered 2010-12-29 12:16:32 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

...and if all else fails you can create your own binder...

binder = new AnnotateDataBinder(comp, b);

You might peek @ the source for AnnotateDataBinderInit::doAfterCompose(Page page, Component[] comps) to see if you can get any clues from it.

link publish delete flag offensive edit

answered 2010-12-29 14:23:15 +0800

orthello gravatar image orthello
18 2

It's working!

I put the AnnotateDataBinderInit zul call in one of the dynamic tabpanels that all the users will get.

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-12-28 10:28:22 +0800

Seen: 558 times

Last updated: Dec 29 '10

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