0

XEL and databinding

asked 2009-08-23 21:15:52 +0800

cbclark64 gravatar image cbclark64
50 1

I'm attempting to convert a JSF application to ZK. While converting a particular page, I coded:
<?xel-method prefix="myFuncs" name="inStatus" class="com.foo.bar.MyFunctions" signature="java.lang.Boolean inStatus( com.foo.bar.model.EmploymentApplication , java.lang.String )" ?>
...
...
...
<listbox id="applicationList" model="@{myController.employeeApplications}" fixedLayout="true" width="100%" height="100%" vflex="true" >
<listhead sizable="true">
<listheader width="30px" label="Application Date" sort="auto(applicationDate)" />
<listheader width="50px" label="Applicant Name" sort="auto(lastName, firstName)" />
<listheader width="70px" label="Status" sort="auto(status)" />
<listheader width="50px" label="Store #" sort="auto(storeNum)" />
</listhead>

<listitem id="applicationListItem" self="@{each='appl'}" value="@{appl}" forward="onDoubleClick=onEditApplication" >
<listcell ><datebox format="MM/dd/yyyy" value="@{appl.applicationDate}" readonly="true" buttonVisible="false"/> </listcell>
<listcell label="@{appl.lastName}" > , <label value="@{appl.firstName}" /></listcell>
<listcell label="${appl.status}" visible="${ myFuncs:inStatus(appl, 'DECLINED') }" />
<listcell label="@{appl.storeNum}" />
</listitem>
</listbox >

The problem I'm having is in the 3rd <listcell.../>. I want the contents to be visible only if myFuncs:inStatus(...) returns true. Setting a breakpoint in the inStatus method shows that it gets called exactly once. The appl parameter is null. Is there a way to make inStatus(...) get called for each <listitem.../> that is created? Thanks

Chris

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2009-08-24 01:02:54 +0800

joylo0122 gravatar image joylo0122
688 1
www.zkoss.org

@Chris

Try to see this smalltalk (Enrich Your JSF Applications with ZK Today!), I think the tags will not working well
in JSP, you had declared them in a correct way.

About the problem with null parameter, you may write a method in "com.foo.bar.MyFunctions" to print out the response.
If the repsonse is correct, then check the path about <?xel-method class="..." />.

/Joy

link publish delete flag offensive edit

answered 2009-08-24 13:32:01 +0800

cbclark64 gravatar image cbclark64
50 1

@Joy,
Perhaps I wasn't clear about what I am doing. I am working in ZK, not JSF. I had an error in the XEL definition early on and that kept the method from being called at all. Once I corrected the definition, the method does get called, but only once. The real question is, why does the ZK runtime call the method early in its lifecycle instead of when the <listitem /> is rendered.

Chris

link publish delete flag offensive edit

answered 2009-08-24 15:26:32 +0800

robertpic71 gravatar image robertpic71
1275 1

Your main problem.

All variable-evaluations are only executed at the creation. Only the databinder @{xxx} could be reloaded.
You could use a TypeConverter to extend the databinding with own javacodes.

Check this side for some examples.

/Robert

link publish delete flag offensive edit

answered 2009-08-25 00:56:59 +0800

joylo0122 gravatar image joylo0122
688 1
www.zkoss.org

@Chris

Hmmm...try to use annotation to solve this problem ( Reference:Data_Binding_Collection_Data_with_ZUML_Annotations ).
And there's a method maybe you will use in Composer, "applicationList.invalidate()" could help you refresh this listbox..

Wish these tips are helpful.

/Joy

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-08-23 21:15:52 +0800

Seen: 189 times

Last updated: Aug 25 '09

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