-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello All:
I've been wrestling all evening with trying to migrate the following ZUL snippet to a templated version (note that the following works perfectly):
<grid width="99.8%" height="100%" mold="paging" autopaging="true" apply="com.mycompany.gridlab3.web.OpportunityController">
<columns menupopup="auto">
<column label="Project Name" width="25%" sort="auto"/>
<column label="Project Location"/>
<column label="Bid Due"/>
<column label="Disposition" width="10%" sort="auto"/>
</columns>
<rows>
<row forEach="${opportunities}">
<label value="${each.projectName}"/>
<label value="${each.projectLocation}"/>
<label value="${each.bidDueDateTime}"/>
<label value="${each.disposition.title}"/>
</row>
</rows>
</grid>
At the top of the ZUL file, I have, of course, the following:
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
Also, I have added a model attribute called "opportunities", which is associated with the result of service.getOpportunities() elsewhere in my controller.
Now, converting this to a templated version has proved illusive. I've tried the following, among other variations:
<grid model="${$composer.opportunities}" width="99.8%" height="100%" mold="paging" autopaging="true" apply="com.mycompany.gridlab3.web.OpportunityController">
<columns menupopup="auto">
<column label="Project Name" width="25%" sort="auto"/>
<column label="Project Location"/>
<column label="Bid Due"/>
<column label="Disposition" width="10%" sort="auto"/>
</columns>
<template name="model">
<row>
<label value="${each.projectName}"/>
<label value="${each.projectLocation}"/>
<label value="${each.bidDueDateTime}"/>
<label value="${each.disposition.title}"/>
</row>
</template>
</grid>
I'm obviously missing something conceptually. I should think that moving to a templated version would require no modification to my controller.
The template example above is a test case. I will take fuller advantage of the templated approach once I can get this basic example working.
Any ideas on what I'm missing?
Thank you.
Hi etaylor,
refer to Default Names of Composer The sample code define a composer in a parent (in the window), and it's children can get the composer by ${$composer.xxx}
In your sample code, you apply the controller to grid, and wanna refer ${$composer.xxx} in grid, in this use case, it won't work due to Life Cycle issue.
ZK need to wire controller in doBeforeComposeChildren() first, so it's children can get controller by ${$composer.xxx}; ZK will apply properties when create component (when create grid), in this moment, ZK will try to resolve ${$composer.xxx}, but it will be null, since controller will apply later.
So you can add a parent to grid, and apply the Controller to it
<div apply="test.OpportunityController">
<grid model="${$composer.opportunities}"
@gquintana: I'll try ListModel and report back.
etaylor ( 2013-01-27 22:05:33 +0800 )edit