List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel
AbstractReadOnlyModel
From source file:au.org.theark.admin.web.component.rolePolicy.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkRoleModuleFunctionVO> buildDataView( ArkDataProvider<ArkRoleModuleFunctionVO, IAdminService> dataProvider) { DataView<ArkRoleModuleFunctionVO> dataView = new DataView<ArkRoleModuleFunctionVO>( "arkRoleModuleFunctionVoList", dataProvider) { private static final long serialVersionUID = -7977497161071264676L; @Override//from w w w. ja v a 2 s.c o m protected void populateItem(final Item<ArkRoleModuleFunctionVO> item) { final ArkRoleModuleFunctionVO arkRoleModuleFunctionVo = item.getModelObject(); item.setOutputMarkupId(true); item.setOutputMarkupPlaceholderTag(true); WebMarkupContainer rowEditWMC = new WebMarkupContainer("rowEditWMC", item.getModel()); AjaxButton listEditButton = new AjaxButton("listEditButton", new StringResourceModel(au.org.theark.core.Constants.EDIT, this, null)) { private static final long serialVersionUID = 197521505680635043L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { item.setEnabled(true); item.get("arkCreatePermissionImg").setVisible(false); item.get("arkReadPermissionImg").setVisible(false); item.get("arkUpdatePermissionImg").setVisible(false); item.get("arkDeletePermissionImg").setVisible(false); item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setEnabled(true)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")) .setEnabled(true)); item.get("rowSaveWMC").setVisible(true); target.add(item); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listEditButton pressed"); } }; listEditButton.setDefaultFormProcessing(false); rowEditWMC.add(listEditButton); item.add(rowEditWMC); if (arkRoleModuleFunctionVo.getArkRole() != null) { item.add(new Label("arkRole", arkRoleModuleFunctionVo.getArkRole().getName())); } else { item.add(new Label("arkRole", "")); } if (arkRoleModuleFunctionVo.getArkModule() != null) { item.add(new Label("arkModule", arkRoleModuleFunctionVo.getArkModule().getName())); } else { item.add(new Label("arkModule", "")); } if (arkRoleModuleFunctionVo.getArkFunction() != null) { item.add(new Label("arkFunction", arkRoleModuleFunctionVo.getArkFunction().getName())); } else { item.add(new Label("arkFunction", "")); } if (arkRoleModuleFunctionVo.getArkCreatePermission()) { item.addOrReplace( new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkReadPermission()) { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkUpdatePermission()) { item.addOrReplace( new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkDeletePermission()) { item.addOrReplace( new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/cross.png"))); } item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")).setVisible(false)); WebMarkupContainer rowSaveWMC = new WebMarkupContainer("rowSaveWMC", item.getModel()); AjaxButton listSaveButton = new AjaxButton("listSaveButton", new StringResourceModel(au.org.theark.core.Constants.SAVE, this, null)) { private static final long serialVersionUID = -7382768898426488999L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target, arkRoleModuleFunctionVo); target.add(SearchResultsPanel.this); target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listSaveButton pressed"); } }; rowSaveWMC.add(listSaveButton); rowSaveWMC.setVisible(false); item.add(rowSaveWMC); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.core.web.component.customfield.SearchResultListPanel.java
License:Open Source License
public DataView<CustomField> buildDataView(ArkDataProvider2<CustomField, CustomField> subjectProvider) { DataView<CustomField> customFieldDataView = new DataView<CustomField>("customFieldList", subjectProvider) { @Override// ww w .j a va2 s . c om protected void populateItem(final Item<CustomField> item) { CustomField field = item.getModelObject(); if (field.getId() != null) { // Add the id component here item.add(new Label(Constants.CUSTOMFIELD_ID, field.getId().toString())); } else { item.add(new Label(Constants.CUSTOMFIELD_ID, "")); } // Component Name Link item.add(buildLinkWMC(item)); // Field Type if (field.getFieldType() != null) { item.add(new Label(Constants.CUSTOMFIELD_FIELD_TYPE, field.getFieldType().getName())); } else { item.add(new Label(Constants.CUSTOMFIELD_FIELD_TYPE, "")); } // Field Label if (field.getFieldLabel() != null) { item.add(new Label(Constants.CUSTOMFIELD_FIELD_LABEL, field.getFieldLabel())); } else { item.add(new Label(Constants.CUSTOMFIELD_FIELD_LABEL, "")); } // custom field type if (field.getCustomFieldType() != null) { item.add(new Label(Constants.CUSTOMFIELD_CUSTOME_FIELD_TYPE, field.getCustomFieldType().getName())); } else { item.add(new Label(Constants.CUSTOMFIELD_CUSTOME_FIELD_TYPE, "")); } //custom file category if (field.getCustomFieldCategory() != null) { item.add(new Label(Constants.CUSTOMFIELD_CATEGORY, field.getCustomFieldCategory().getName())); } else { item.add(new Label(Constants.CUSTOMFIELD_CATEGORY, "")); } //custom file category order number if (field.getCustomFieldCategory() != null && field.getCustomFieldCategory().getOrderNumber() != null) { item.add(new Label(Constants.CUSTOMFIELD_CATEGORY_ORDERNUMBER, field.getCustomFieldCategory().getOrderNumber().toString())); } else { item.add(new Label(Constants.CUSTOMFIELD_CATEGORY_ORDERNUMBER, "")); } /* For the alternative stripes */ item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; addToolbars(customFieldDataView); return customFieldDataView; }
From source file:au.org.theark.core.web.component.customfieldcategory.SearchResultListPanel.java
License:Open Source License
public DataView<CustomFieldCategory> buildDataView( ArkDataProvider2<CustomFieldCategory, CustomFieldCategory> subjectProvider) { DataView<CustomFieldCategory> customFieldCategoryDataView = new DataView<CustomFieldCategory>( "customFieldCategoryList", subjectProvider) { @Override/* ww w .jav a 2s. c om*/ protected void populateItem(final Item<CustomFieldCategory> item) { CustomFieldCategory category = item.getModelObject(); //id if (category.getId() != null) { item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ID, category.getId().toString())); } else { item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ID, "")); } // Component Name Link item.add(buildLinkWMC(item)); //Custom Field Name if (category.getCustomFieldType() != null) { item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_CUSTOM_FIELD_TYPE_NAME, category.getCustomFieldType().getName())); } else { item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_CUSTOM_FIELD_TYPE_NAME, "")); } // Description if (category.getDescription() != null) { item.add(new Label(Constants.CUSTOMFIELDCATEGORY_DESCRIPTION, category.getDescription())); } else { item.add(new Label(Constants.CUSTOMFIELDCATEGORY_DESCRIPTION, "")); } //Parent Category if (category.getParentCategory() != null) { item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_PARENTCATEGORY_NAME, category.getParentCategory().getName())); } else { item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_PARENTCATEGORY_NAME, "")); } //Order Number if (category.getOrderNumber() != null) { item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ORDERNUMBER, category.getOrderNumber().toString())); } else { item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ORDERNUMBER, "")); } /* For the alternative stripes */ item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; addToolbars(customFieldCategoryDataView); return customFieldCategoryDataView; }
From source file:au.org.theark.core.web.component.customfieldupload.SearchResultListPanel.java
License:Open Source License
/** * //from w w w . j av a2s .com * @param iModel * @return the pageableListView of Upload */ public PageableListView<Upload> buildPageableListView(IModel iModel) { PageableListView<Upload> sitePageableListView = new PageableListView<Upload>(Constants.RESULT_LIST, iModel, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Upload> item) { Upload upload = item.getModelObject(); // The ID if (upload.getId() != null) { // Add the id component here item.add(new Label(Constants.UPLOADVO_UPLOAD_ID, upload.getId().toString())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_ID, "")); } // / The filename if (upload.getFilename() != null) { // Add the id component here item.add(new Label(Constants.UPLOADVO_UPLOAD_FILENAME, upload.getFilename())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_FILENAME, "")); } // File Format if (upload.getFileFormat() != null) { item.add(new Label(Constants.UPLOADVO_UPLOAD_FILE_FORMAT, upload.getFileFormat().getName())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_FILE_FORMAT, "")); } // UserId if (upload.getUserId() != null) { item.add(new Label(Constants.UPLOADVO_UPLOAD_USER_ID, upload.getUserId())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_USER_ID, "")); } // Start time if (upload.getStartTime() != null) { item.add(new Label(Constants.UPLOADVO_UPLOAD_START_TIME, upload.getStartTime().toString())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_START_TIME, "")); } // Finish time if (upload.getFinishTime() != null) { item.add(new Label(Constants.UPLOADVO_UPLOAD_FINISH_TIME, upload.getFinishTime().toString())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_FINISH_TIME, "")); } if (upload.getUploadStatus() != null && upload.getUploadStatus().getShortMessage() != null) { item.add(new Label(Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME, upload.getUploadStatus().getShortMessage())); } else { item.add(new Label(Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME, "")); } // Download file link button item.add(buildDownloadButton(upload)); // Download upload report button item.add(buildDownloadReportButton(upload)); // For the alternative stripes item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return sitePageableListView; }
From source file:au.org.theark.core.web.component.tabbedPanel.DynamicTabbedPanel.java
License:Open Source License
public DynamicTabbedPanel(final String id, final IModel<List<ITab>> tabModel) { super(id, new Model<Integer>(-1)); this.tabModel = tabModel; final IModel<Integer> tabCount = new AbstractReadOnlyModel<Integer>() { private static final long serialVersionUID = 1L; @Override/* ww w . j ava2 s . c o m*/ public Integer getObject() { return tabModel.getObject().size(); } }; WebMarkupContainer tabsContainer = newTabsContainer("tabs-container"); add(tabsContainer); // add the loop used to generate tab names tabsContainer.add(new Loop("tabs", tabCount) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final LoopItem item) { final int index = item.getIndex(); final ITab tab = tabModel.getObject().get(index); final WebMarkupContainer titleLink = newLink("link", index); titleLink.add(newTitle("title", tab.getTitle(), index)); item.add(titleLink); } @Override protected LoopItem newItem(final int iteration) { return newTabContainer(iteration); } public boolean isVisible() { return tabCount.getObject() > 0; } }); }
From source file:au.org.theark.core.web.form.AbstractWizardHeaderPanel.java
License:Open Source License
public AbstractWizardHeaderPanel(String id) { super(id);/*from ww w . j a va2 s. c o m*/ add(new Label("title", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return getTitle(); } }).setEscapeModelStrings(false)); add(new Label("summary", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return getSummary(); } }).setEscapeModelStrings(false)); }
From source file:au.org.theark.core.web.form.AbstractWizardHeaderPanel.java
License:Open Source License
public AbstractWizardHeaderPanel(String id, String summary, String title) { super(id);// ww w.j ava2s .co m this.title = title; this.summary = summary; add(new Label("title", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return getTitle(); } }).setEscapeModelStrings(false)); add(new Label("summary", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return getSummary(); } }).setEscapeModelStrings(false)); }
From source file:au.org.theark.disease.web.component.affection.form.DetailForm.java
License:Open Source License
@SuppressWarnings("unchecked") public void initialiseDetailForm() { initDiseaseDDC();// w w w . j a v a 2 s. c o m initAffectionStatusDDC(); detachableModel = new LoadableDetachableModel<List<Position>>() { @Override protected List<Position> load() { List<Position> positions = iArkDiseaseService .getPositions(containerForm.getModelObject().getAffection()); return positions; } }; positionListEditor = new ListView<Position>("positionListEditor", detachableModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Position> item) { final Position position = item.getModelObject(); if (position != null) { position_storage.put(item.getIndex(), position); } List<Gene> availableGenes = new ArrayList<Gene>(); if (containerForm.getModelObject().getAffection().getDisease() != null && containerForm.getModelObject().getAffection().getDisease().getGenes() != null) { availableGenes = new ArrayList<Gene>( containerForm.getModelObject().getAffection().getDisease().getGenes()); } final DropDownChoice<Gene> geneDDC = new DropDownChoice<Gene>("affection.disease.genes", new Model<Gene>(position.getGene()), availableGenes, new ChoiceRenderer<Gene>("name", "id")); geneDDC.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { Gene selectedGene = iArkDiseaseService.getGeneByID(Long.parseLong(geneDDC.getValue())); positionDDC.setChoices(new ArrayList<Position>(selectedGene.getPositions())); target.add(positionDDC); } }); geneDDC.setOutputMarkupId(true); item.add(geneDDC); List<Position> availablePositions = new ArrayList<Position>(); if (geneDDC.getModelObject() != null) { availablePositions = new ArrayList<Position>(geneDDC.getModelObject().getPositions()); } LoadableDetachableModel<Position> positionModel = new LoadableDetachableModel<Position>(position) { @Override protected Position load() { return position; } }; if (position != null) { positionModel.setObject(position); } positionDDC = new DropDownChoice<Position>("affection.positions", positionModel, availablePositions, new ChoiceRenderer<Position>("name", "id")) { @Override protected void onBeforeRender() { if (geneDDC.getModelObject() != null && geneDDC.getModelObject().getId() != null && !geneDDC.getModelObject().getPositions().isEmpty()) { this.setChoices(new ArrayList<Position>(geneDDC.getModelObject().getPositions())); } if (this.getModelObject().getName() != null) { position_storage.put(item.getIndex(), this.getModelObject()); } super.onBeforeRender(); } }; positionDDC.setOutputMarkupId(true); positionDDC.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { Position selectedPosition = positionDDC.getModelObject(); if (selectedPosition.getName() != null) { position_storage.put(item.getIndex(), selectedPosition); } } }); item.add(positionDDC); item.add(new AjaxDeleteButton(Constants.DELETE, new Model<String>("Are you sure?"), new Model<String>("Delete")) { private static final long serialVersionUID = 1L; protected void onDeleteConfirmed(AjaxRequestTarget target, Form<?> form) { try { //need to remove save containerform post position removal position_storage.remove(item.getIndex()); positionListEditor.getModelObject().remove(position); containerForm.getModelObject().setAffection(iArkDiseaseService .getAffectionByID(containerForm.getModelObject().getAffection().getId())); save(containerForm, target); target.add(dataViewPanel); deleteCompleted("Row '" + position.getName() + "' deleted successfully.", true); } catch (Exception e) { e.printStackTrace(); target.add(form); deleteCompleted("Error deleting row '" + position.getName() + "'. Row has data associated with it.", false); } } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onDeleteConfirmed(target, form); target.add(form); target.add(feedBackPanel); } }); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; positionListEditor.setOutputMarkupId(true); newPositionBtn = new AjaxEditorButton(Constants.NEW) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { positionListEditor.getModelObject().add(new Position()); target.add(form); } }.setDefaultFormProcessing(false); arkCrudContainerVO.getDetailPanelFormContainer().add(newPositionBtn); PropertyModel<Date> recordDateModel = new PropertyModel<Date>(containerForm.getModel(), "affection.recordDate"); recordDateTxtFld = new DateTextField("recordDate", recordDateModel) { @Override protected void onBeforeRender() { this.setModel(new PropertyModel<Date>(containerForm.getModel(), "affection.recordDate")); super.onBeforeRender(); } }; ArkDatePicker recordDatePicker = new ArkDatePicker(); recordDatePicker.bind(recordDateTxtFld); recordDateTxtFld.add(recordDatePicker); AffectionCustomDataVO affectionCustomDataVO = new AffectionCustomDataVO(); affectionCustomDataVO.setCustomFieldDataList(new ArrayList<AffectionCustomFieldData>( cpModel.getObject().getAffection().getAffectionCustomFieldDataSets())); final CompoundPropertyModel<AffectionCustomDataVO> affectionCustomDataModel = new CompoundPropertyModel<AffectionCustomDataVO>( affectionCustomDataVO); dataViewPanel = new AffectionCustomDataDataViewPanel("dataViewPanel", affectionCustomDataModel) .initialisePanel( iArkCommonService.getUserConfig(Constants.CONFIG_CUSTOM_FIELDS_PER_PAGE).getIntValue()); customFieldForm = new AbstractCustomDataEditorForm<AffectionCustomDataVO>("customFieldForm", affectionCustomDataModel, feedBackPanel) { private static final long serialVersionUID = 1L; @Override public void onEditSave(AjaxRequestTarget target, Form<?> form) { for (AffectionCustomFieldData acfd : this.cpModel.getObject().getCustomFieldDataList()) { iArkDiseaseService.save(acfd); } } @Override public void onBeforeRender() { if (!isNew()) { this.setModelObject(new AffectionCustomDataVO(iArkDiseaseService .getAffectionCustomFieldData(containerForm.getModelObject().getAffection()))); } this.buttonsPanelWMC.setVisible(false); super.onBeforeRender(); } }.initialiseForm(); pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) { @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(customFieldForm.getDataViewWMC()); target.add(this); } }; pageNavigator.setOutputMarkupId(true); customFieldForm.getDataViewWMC().add(dataViewPanel); arkCrudContainerVO.getDetailPanelFormContainer().add(pageNavigator); attachValidators(); addDetailFormComponents(); deleteButton.setVisible(false); }
From source file:au.org.theark.disease.web.component.affection.SearchResultListPanel.java
License:Open Source License
public DataView<AffectionVO> buildDataView( final ArkDataProvider<AffectionVO, IArkDiseaseService> diseaseProvider) { DataView<AffectionVO> studyCompDataView = new DataView<AffectionVO>("affectionList", diseaseProvider, iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { @Override/*from www. ja v a 2s. c om*/ protected void populateItem(final Item<AffectionVO> item) { Affection affection = item.getModelObject().getAffection(); item.add(new Label("affection.id", affection.getId().toString())); item.add(buildLink(item.getModelObject())); item.add(new Label("affection.recordDate", affection.getRecordDate().toString())); item.add(new Label("affection.status", affection.getAffectionStatus().getName())); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return studyCompDataView; }
From source file:au.org.theark.disease.web.component.affection.SearchResultListPanel.java
License:Open Source License
public PageableListView<AffectionVO> buildListView(IModel iModel) { PageableListView<AffectionVO> listView = new PageableListView<AffectionVO>("affectionList", iModel, iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { @Override/*from www .ja v a 2s .c om*/ protected void populateItem(final ListItem<AffectionVO> item) { Affection affection = item.getModelObject().getAffection(); item.add(new Label("affection.id", affection.getId().toString())); item.add(buildLink(item.getModelObject())); item.add(new Label("affection.recordDate", affection.getRecordDate().toString())); item.add(new Label("affection.status", affection.getAffectionStatus().getName())); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return listView; }