0

Templating rows in a Grid under Spring MVC [closed]

asked 2013-01-26 07:00:59 +0800

etaylor gravatar image etaylor
2 2

updated 2013-01-26 07:04:10 +0800

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.

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by sjoshi
close date 2013-02-08 06:38:51

Comments

@gquintana: I'll try ListModel and report back.

etaylor ( 2013-01-27 22:05:33 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-01-28 03:04:15 +0800

samchuang gravatar image samchuang
4084 4

updated 2013-01-28 03:05:37 +0800

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}"
link publish delete flag offensive edit
0

answered 2013-01-27 20:29:34 +0800

gquintana gravatar image gquintana
33 3

I am doing like this and it works. Does your OpportunityController have a "public ListModel getOpportunities()" method? What result are you experimenting: stacktrace? only table header?

link publish delete flag offensive edit

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-01-26 07:00:59 +0800

Seen: 38 times

Last updated: Jan 28 '13

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