0

grid is null in doAfterCompose

asked 2014-09-21 14:01:48 +0800

MohanSharma2909 gravatar image MohanSharma2909
1 1

updated 2014-09-21 14:12:58 +0800

This is my templateWestCollapsible.zul

 <borderlayout id="templateBorderlayout"  
              apply="org.test.view.ManageScheduleComposer">  
  <center id="center" autoscroll="false">
    </center>

    <east collapsible="true" title="Help" size="15%" open="false"
                         sclass="z-borderlayout-icon z-east-exp">

    </east>
    <west size="15%">
        <include id="westMenu" src="westMenu.zul"/>
    </west>
</borderlayout>

This is my westMenu.zul

<window border="normal"  apply= org.test.view.ManageScheduleComposer">
    <caption label="Quick Links"></caption>
    <groupbox mold="3d" width="100%" closable="false"
                                              hflex="1">
        <vbox hflex="1">
            <toolbarbutton id="schedule" label="schedules"/>
        </vbox>
    </groupbox>
</window>

I have a class which takes the id and generates the view on the center layout

This is my schedule.zul

<window id="win" vflex="1" hflex="1" border =""
                apply="org.test.view.ManageScheduleComposer">
    <div>
        <grid  mold="paging" pageSize="10" id="dataGrid" hflex="1"
                         emptyMessage="Nothing to display">
            <columns>
                <column label="Description"></column>
                <column label="From Date"></column>
                <column label="To Date"></column>
                <column label="Status"></column>
                <column  width ="5%"></column>
                <column label="Action"></column>
            </columns>
            <rows id="scheduleRows">
                <row self="@{each='manageSchedule'}"
                                           value="@{manageSchedule}">
                    <label value="@{manageSchedule.description}"></label>
                    <label value="@{manageSchedule.fromDate}"></label>
                    <label value="@{manageSchedule.toDate}"></label>
                    <label  value="@{manageSchedule.status}"></label>
                    <label  value="@{manageSchedule.id}"
                                               visible="false"></label>
                    <button label="Release">
                    </button>
                </row>
            </rows>
        </grid>
    </div>  
   </window>

My problem is inside the Composer class the grid is coming as null if the load the templateWestCollapsible.zul but if I load the schedule.zul directly the grid is not null then this is my composer

public class ManageScheduleComposer extends SelectorComposer<Component> {

@Wire
private Rows scheduleRows;

@Wire
private Grid dataGrid;

private ListModelList<ScheduleDto> allSchedulesList;
List<ScheduleDto> list = new ArrayList<>();

public ManageScheduleComposer(){
    list.add(new ScheduleDto("1",new LocalDate(2014,9,01), new LocalDate(2014,9,30),"Sept",""));
    list.add(new ScheduleDto("2",new LocalDate(2014,10,01), new LocalDate(2014,10,30),"Oct",""));
    list.add(new ScheduleDto("3",new LocalDate(2014,11,01), new LocalDate(2014,11,30),"Nov",""));
}

public ListModelList<ScheduleDto> getAllSchedulesList() {
    return allSchedulesList;
}

public void setAllSchedulesList(ListModelList<ScheduleDto> allSchedulesList) {
    this.allSchedulesList = allSchedulesList;
}

@Override
public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
    setAllSchedulesList(new ListModelList<ScheduleDto>(list));
    dataGrid.setModel(getAllSchedulesList());// dataGrid is null why?
  }
}
delete flag offensive retag edit

Comments

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-09-21 17:32:11 +0800

Darksu gravatar image Darksu
1991 1 4

Hello MohanSharma2909,

From your description, and the provided code, it is logic that the grid is null because it's supposed to get the reference from the zul page (In this case the grid has not been defined).

Perhaps you could create separate composers?

Best Regards,

Darksu

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
1 follower

RSS

Stats

Asked: 2014-09-21 14:01:48 +0800

Seen: 22 times

Last updated: Sep 22 '14

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