List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel
AbstractReadOnlyModel
From source file:au.org.theark.study.web.component.contact.PhoneListPanel.java
License:Open Source License
/** * Create a dataview for only export purposes. * // w w w. j a v a 2 s . c o m * @param phoneProvider * @return */ private DataView<PhoneSubjectVO> buildDataViewWithStudySubjectID( ArkDataProvider<PhoneSubjectVO, IStudyService> phoneProvider) { DataView<PhoneSubjectVO> phoneListDataView = new DataView<PhoneSubjectVO>("phoneListWithSubjectID", subjectPhoneProvider, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<PhoneSubjectVO> item) { PhoneSubjectVO phoneSubjectVO = item.getModelObject(); if (phoneSubjectVO.getSubjectUID() != null) { item.add(new Label("subjectUId", phoneSubjectVO.getSubjectUID())); } else { item.add(new Label("subjectUId", "")); } if (phoneSubjectVO.getId() != null) { item.add(new Label("id", phoneSubjectVO.getId().toString())); } else { item.add(new Label("id", "")); } if (phoneSubjectVO.getAreaCode() != null) { item.add(new Label("areaCode", phoneSubjectVO.getAreaCode())); } else { item.add(new Label("areaCode", "")); } if (phoneSubjectVO.getPhoneType() != null && phoneSubjectVO.getPhoneType().getName() != null) { item.add(new Label("phoneType.name", phoneSubjectVO.getPhoneType().getName())); } else { item.add(new Label("phoneType.name", "")); } 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 phoneListDataView; }
From source file:au.org.theark.study.web.component.correspondence.SearchResultListPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<Correspondences> buildPageableListView(IModel iModel) { PageableListView<Correspondences> pageableListView = new PageableListView<Correspondences>( "correspondenceList", iModel, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 9076367524574951367L; @Override// www . j a va 2 s.c om protected void populateItem(final ListItem<Correspondences> item) { Correspondences correspondence = item.getModelObject(); // set the date to be the link to details item.add(buildLink(correspondence)); if (correspondence.getTime() != null) { item.add(new Label("time", correspondence.getTime())); } else { item.add(new Label("time", "")); } if (correspondence.getOperator() != null) { item.add(new Label("operator.ldapUserName", correspondence.getOperator().getLdapUserName())); } else { item.add(new Label("operator.ldapUserName", "")); } if (correspondence.getCorrespondenceModeType() != null) { item.add(new Label("correspondenceModeType.name", correspondence.getCorrespondenceModeType().getName())); } else { item.add(new Label("correspondenceModeType.name", "")); } if (correspondence.getCorrespondenceDirectionType() != null) { item.add(new Label("correspondenceDirectionType.name", correspondence.getCorrespondenceDirectionType().getName())); } else { item.add(new Label("correspondenceDirectionType.name", "")); } if (correspondence.getCorrespondenceOutcomeType() != null) { item.add(new Label("correspondenceOutcomeType.name", correspondence.getCorrespondenceOutcomeType().getName())); } else { item.add(new Label("correspondenceOutcomeType.name", "")); } if (correspondence.getReason() != null) { item.add(new Label("reason", correspondence.getReason())); } else { item.add(new Label("reason", "")); } // Download file button item.add(buildDownloadButton(correspondence)); // Delete file button item.add(buildDeleteButton(correspondence)); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = -1588380616547616236L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return pageableListView; }
From source file:au.org.theark.study.web.component.global.subject.SearchResultListPanel.java
License:Open Source License
public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider) { DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) { @Override/* www. jav a 2 s . co m*/ protected void populateItem(final Item<SubjectVO> item) { LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy(); item.add(buildLink(item.getModelObject())); item.add(new Label("study", item.getModelObject().getLinkSubjectStudy().getStudy().getName())); item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName())); /* if (subject != null && subject.getPerson() != null && subject.getPerson().getPreferredName() != null) { item.add(new Label("linkSubjectStudy.person.preferredName", subject.getPerson().getPreferredName())); } else { item.add(new Label("linkSubjectStudy.person.preferredName", "")); } */ List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService .getPersonLastNameHistory(subject.getPerson()); String lastNameString = ""; if (!lastnameHistory.isEmpty()) { lastNameString = lastnameHistory.get(0).getLastName(); for (int i = 1; i < lastnameHistory.size(); i++) { lastNameString += ", " + lastnameHistory.get(i).getLastName(); } } if (subject != null && subject.getPerson() != null && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) { item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString)); } else { item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", "")); } item.add(new Label("linkSubjectStudy.person.genderType.name", subject.getPerson().getGenderType().getName())); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); String dateOfBirth = ""; if (subject != null && subject.getPerson() != null && subject.getPerson().getDateOfBirth() != null) { dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth()); item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth)); } else { item.add(new Label("linkSubjectStudy.person.dateOfBirth", "")); } item.add(new Label("linkSubjectStudy.person.vitalStatus.name", subject.getPerson().getVitalStatus().getName())); item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName())); if (subject.getConsentStatus() != null) { item.add( new Label("linkSubjectStudy.consentStatus.name", subject.getConsentStatus().getName())); } else { item.add(new Label("linkSubjectStudy.consentStatus.name", "")); } List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson()); String otherIDstring = ""; for (OtherID o : otherIDs) { otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n"; } if (!otherIDs.isEmpty()) { item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring)); } else { item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", "")); } 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.study.web.component.global.subject.SearchResultListPanel.java
License:Open Source License
public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider, final AbstractDetailModalWindow modalWindow, final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel) { DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) { @Override//from ww w .j a va2 s . c om protected void populateItem(final Item<SubjectVO> item) { LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy(); item.add(buildLink(item, modalWindow, relatives, feedbackPanel)); item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName())); /* if (subject != null && subject.getPerson() != null && subject.getPerson().getPreferredName() != null) { item.add(new Label("linkSubjectStudy.person.preferredName", subject.getPerson().getPreferredName())); } else { item.add(new Label("linkSubjectStudy.person.preferredName", "")); } */ List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService .getPersonLastNameHistory(subject.getPerson()); String lastNameString = ""; if (!lastnameHistory.isEmpty()) { lastNameString = lastnameHistory.get(0).getLastName(); for (int i = 1; i < lastnameHistory.size(); i++) { lastNameString += ", " + lastnameHistory.get(i).getLastName(); } } if (subject != null && subject.getPerson() != null && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) { item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString)); } else { item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", "")); } item.add(new Label("linkSubjectStudy.person.genderType.name", subject.getPerson().getGenderType().getName())); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); String dateOfBirth = ""; if (subject != null && subject.getPerson() != null && subject.getPerson().getDateOfBirth() != null) { dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth()); item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth)); } else { item.add(new Label("linkSubjectStudy.person.dateOfBirth", "")); } item.add(new Label("linkSubjectStudy.person.vitalStatus.name", subject.getPerson().getVitalStatus().getName())); item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName())); if (subject.getConsentStatus() != null) { item.add( new Label("linkSubjectStudy.consentStatus.name", subject.getConsentStatus().getName())); } else { item.add(new Label("linkSubjectStudy.consentStatus.name", "")); } item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson()); String otherIDstring = ""; for (OtherID o : otherIDs) { otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n"; } if (!otherIDs.isEmpty()) { item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring)); } else { item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", "")); } } }; return studyCompDataView; }
From source file:au.org.theark.study.web.component.global.subject.SearchResultListPanel.java
License:Open Source License
public PageableListView<SubjectVO> buildListView(IModel iModel) { PageableListView<SubjectVO> listView = new PageableListView<SubjectVO>(Constants.SUBJECT_LIST, iModel, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { @Override//w w w. j a v a 2 s . c om protected void populateItem(final ListItem<SubjectVO> item) { LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy(); item.add(buildLink(item.getModelObject())); item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName())); /* if (subject != null && subject.getPerson() != null && subject.getPerson().getPreferredName() != null) { item.add(new Label("linkSubjectStudy.person.preferredName", subject.getPerson().getPreferredName())); } else { item.add(new Label("linkSubjectStudy.person.preferredName", "")); } */ List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService .getPersonLastNameHistory(subject.getPerson()); String lastNameString = ""; if (!lastnameHistory.isEmpty()) { lastNameString = lastnameHistory.get(0).getLastName(); for (int i = 1; i < lastnameHistory.size(); i++) { lastNameString += ", " + lastnameHistory.get(i).getLastName(); } } if (subject != null && subject.getPerson() != null && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) { item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString)); } else { item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", "")); } item.add(new Label("linkSubjectStudy.person.genderType.name", subject.getPerson().getGenderType().getName())); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); String dateOfBirth = ""; if (subject != null && subject.getPerson() != null && subject.getPerson().getDateOfBirth() != null) { dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth()); item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth)); } else { item.add(new Label("linkSubjectStudy.person.dateOfBirth", "")); } item.add(new Label("linkSubjectStudy.person.vitalStatus.statusName", subject.getPerson().getVitalStatus().getName())); item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName())); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson()); String otherIDstring = ""; for (OtherID o : otherIDs) { otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n"; } if (!otherIDs.isEmpty()) { item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring)); } else { item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", "")); } } }; return listView; }
From source file:au.org.theark.study.web.component.managestudy.SearchResultListPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<Study> buildPageableListView(IModel iModel, final WebMarkupContainer searchResultsContainer) { PageableListView<Study> studyPageableListView = new PageableListView<Study>("studyList", iModel, iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override/* w ww . j ava 2s . c o m*/ protected void populateItem(final ListItem<Study> item) { Study study = item.getModelObject(); if (study.getId() != null) { item.add(new Label("id", study.getId().toString())); } else { item.add(new Label("id", "")); } childStudiesExist = (study.getParentStudy() != null); // Add "+" indicator if study has a parent (but handle for actual parent) Label childStudyLabel = new Label("childStudyIndicator", "+"); childStudyLabel.setVisible(childStudiesExist && (study != study.getParentStudy())); childStudyNote.setVisible(childStudiesExist); item.add(childStudyLabel); item.add(buildLink(study, searchResultsContainer)); if (study.getContactPerson() != null) { item.add(new Label("contact", study.getContactPerson()));// the ID here must match the ones in mark-up } else { item.add(new Label("contact", ""));// the ID here must match the ones in mark-up } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DD_MM_YYYY); String dateOfApplication = ""; if (study.getDateOfApplication() != null) { dateOfApplication = simpleDateFormat.format(study.getDateOfApplication()); item.add(new Label("dateOfApplication", dateOfApplication)); } else { item.add(new Label("dateOfApplication", dateOfApplication)); } 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 studyPageableListView; }
From source file:au.org.theark.study.web.component.manageuser.SearchResultListPanel.java
License:Open Source License
public PageableListView<ArkUserVO> buildPageableListView(IModel iModel, final WebMarkupContainer searchResultsContainer) { // This has to be populated earlier PageableListView<ArkUserVO> pageableListView = new PageableListView<ArkUserVO>("userList", iModel, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override//from w ww. ja v a 2s . com protected void populateItem(final ListItem<ArkUserVO> item) { ArkUserVO arkUserVO = item.getModelObject(); item.add(buildLink(arkUserVO, searchResultsContainer)); item.add(new Label("lastName", arkUserVO.getLastName()));// the ID here must match the ones in mark-up item.add(new Label("firstName", arkUserVO.getFirstName())); item.add(new Label("email", arkUserVO.getEmail())); 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 pageableListView; }
From source file:au.org.theark.study.web.component.mydetails.form.MyDetailsForm.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) public void initialiseForm() { //ArkUserVO arkUserVOFromBackend = new ArkUserVO(); try {/*from w w w. jav a 2 s. c o m*/ ArkUserVO arkUserVOFromBackend = iUserService.lookupArkUser(getModelObject().getUserName(), getModelObject().getStudy()); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { arkUserVOFromBackend.setStudy(iArkCommonService.getStudy(sessionStudyId)); } else { arkUserVOFromBackend.setStudy(getModelObject().getStudy()); } //Study will selected with model object and that will be the page list view accordingly. listViewPanel.setOutputMarkupId(true); iModel = new LoadableDetachableModel() { private static final long serialVersionUID = 1L; @Override protected Object load() { return getModelObject().getArkRolePolicyTemplatesList(); } }; initStudyDdc(arkUserVOFromBackend); List<UserConfig> arkUserConfigs = iArkCommonService .getUserConfigs(arkUserVOFromBackend.getArkUserEntity()); arkUserVOFromBackend.setArkUserConfigs(arkUserConfigs); getModelObject().setArkUserConfigs(arkUserConfigs); } catch (ArkSystemException e) { log.error(e.getMessage()); } emailTxtField.setOutputMarkupId(true); saveButton = new AjaxButton(Constants.SAVE) { private static final long serialVersionUID = -8737230044711628981L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target); } public void onError(AjaxRequestTarget target, Form<?> form) { processFeedback(target, feedbackPanel); } }; closeButton = new AjaxButton(Constants.CLOSE) { private static final long serialVersionUID = 5457464178392550628L; public void onSubmit(AjaxRequestTarget target, Form<?> form) { modalWindow.close(target); } public void onError(AjaxRequestTarget target, Form<?> form) { processFeedback(target, feedbackPanel); } }; closeButton.setDefaultFormProcessing(false); emailTxtField.add(EmailAddressValidator.getInstance()); boolean loggedInViaAAF = ((String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SHIB_SESSION_ID) != null); groupPasswordContainer.setVisible(!loggedInViaAAF); shibbolethSessionDetails .add(new AttributeModifier("src", ArkShibbolethServiceProviderContextSource.handlerUrl + ArkShibbolethServiceProviderContextSource.session)); shibbolethSession.add(new AttributeModifier("class", "paddedDetailPanel")); shibbolethSession.setVisible(loggedInViaAAF); shibbolethSession.add(shibbolethSessionDetails); userConfigListEditor = new AbstractListEditor<UserConfig>("arkUserConfigs") { @Override protected void onPopulateItem(au.org.theark.core.web.component.listeditor.ListItem<UserConfig> item) { item.add(new Label("configField.description", item.getModelObject().getConfigField().getDescription())); PropertyModel<String> propModel = new PropertyModel<String>(item.getModel(), "value"); TextField<String> valueTxtFld = new TextField<String>("value", propModel); item.add(valueTxtFld); item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { private static final long serialVersionUID = -8887455455175404701L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; attachValidators(); addComponents(); }
From source file:au.org.theark.study.web.component.mydetails.form.MyDetailsForm.java
License:Open Source License
private void createPageListView(IModel<List<ArkRolePolicyTemplate>> iModel) { // TODO: Amend hard-coded 50 row limit, pageableListView didn't work within a ModalWindow pageableListView = new PageableListView<ArkRolePolicyTemplate>("arkRolePolicyTemplatesList", iModel, 50) { private static final long serialVersionUID = 3557668722549243826L; @Override/* w w w . j a va 2s .c o m*/ protected void populateItem(final ListItem<ArkRolePolicyTemplate> item) { ArkRolePolicyTemplate arkRolePolicyTemplate = (ArkRolePolicyTemplate) item.getModelObject(); /*if (((ArkUserVO)getModelObject()).getStudy() != null) { item.addOrReplace(new Label("studyName", ((ArkUserVO)getModelObject()).getStudy().getName())); } else { item.addOrReplace(new Label("studyName", "[All Study Access]")); }*/ if (arkRolePolicyTemplate.getArkModule() != null) { item.addOrReplace(new Label("moduleName", arkRolePolicyTemplate.getArkModule().getName())); } else { item.addOrReplace(new Label("moduleName", "Not specified Module")); } if (arkRolePolicyTemplate.getArkRole() != null) { item.addOrReplace(new Label("roleName", arkRolePolicyTemplate.getArkRole().getName())); } else { item.addOrReplace(new Label("roleName", "Not specified Role")); } if (arkRolePolicyTemplate.getArkFunction() != null) { item.addOrReplace(new Label("functionName", arkRolePolicyTemplate.getArkFunction().getName())); } else { item.addOrReplace(new Label("functionName", "Not specified function")); } List<ArkPermission> arkPermissionsList = iArkCommonService .getArkPremissionListForRoleAndModule(arkRolePolicyTemplate); if (isPermissionLstContain(arkPermissionsList, "CREATE")) { item.addOrReplace( new ContextImage("arkCreatePermission", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkCreatePermission", new Model<String>("images/icons/cross.png"))); } // the ID here must match the ones in mark-up if (isPermissionLstContain(arkPermissionsList, "READ")) { item.addOrReplace( new ContextImage("arkReadPermission", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkReadPermission", new Model<String>("images/icons/cross.png"))); } // the ID here must match the ones in mark-up if (isPermissionLstContain(arkPermissionsList, "UPDATE")) { item.addOrReplace( new ContextImage("arkUpdatePermission", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkUpdatePermission", new Model<String>("images/icons/cross.png"))); } // the ID here must match the ones in mark-up if (isPermissionLstContain(arkPermissionsList, "DELETE")) { item.addOrReplace( new ContextImage("arkDeletePermission", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkDeletePermission", new Model<String>("images/icons/cross.png"))); } item.setEnabled(false); item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { private static final long serialVersionUID = -8887455455175404701L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; pageableListView.setReuseItems(false); pageableListView.setOutputMarkupId(true); listViewPanel.add(pageableListView); pageNavigator = new AjaxPagingNavigator("navigator", pageableListView); listViewPanel.add(pageNavigator); }
From source file:au.org.theark.study.web.component.phone.SearchResultListPanel.java
License:Open Source License
/** * /* ww w . ja va 2 s . c o m*/ * @param iModel * @return */ @SuppressWarnings("unchecked") public PageableListView<Phone> buildPageableListView(IModel iModel) { PageableListView<Phone> pageableListView = new PageableListView<Phone>(Constants.PHONE_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<Phone> item) { Phone phone = item.getModelObject(); item.add(buildLink(phone)); if (phone.getId() != null) { item.add(new Label("id", phone.getId().toString())); } else { item.add(new Label("id", "")); } if (phone.getAreaCode() != null) { item.add(new Label("areaCode", phone.getAreaCode())); } else { item.add(new Label("areaCode", "")); } if (phone.getPhoneType() != null && phone.getPhoneType().getName() != null) { item.add(new Label("phoneType.name", phone.getPhoneType().getName())); } else { item.add(new Label("phoneType.name", "")); } if (phone.getPhoneStatus() != null && phone.getPhoneStatus().getName() != null) { item.add(new Label("phoneStatus.name", phone.getPhoneStatus().getName())); } else { item.add(new Label("phoneStatus.name", "")); } if (phone.getValidFrom() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( au.org.theark.core.Constants.DD_MM_YYYY); String dateValidFrom = ""; dateValidFrom = simpleDateFormat.format(phone.getValidFrom()); item.add(new Label("validFrom", dateValidFrom)); } else { item.add(new Label("validFrom", "")); } if (phone.getValidFrom() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( au.org.theark.core.Constants.DD_MM_YYYY); String dateValidTo = ""; dateValidTo = simpleDateFormat.format(phone.getValidTo()); item.add(new Label("validTo", dateValidTo)); } else { item.add(new Label("validTo", "")); } if (phone.getPreferredPhoneNumber() != null && phone.getPreferredPhoneNumber() == true) { item.add(new ContextImage("phone.preferredPhoneNumber", new Model<String>("images/icons/tick.png"))); } else { item.add(new Label("phone.preferredPhoneNumber", "")); } 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 pageableListView; }