List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel
AbstractReadOnlyModel
From source file:au.org.theark.study.web.component.studycomponent.SearchResultListPanel.java
License:Open Source License
/** * // w ww .j a v a 2 s . c o m * @param iModel * @param searchContainer * @return */ public PageableListView<StudyComp> buildPageableListView(IModel iModel) { PageableListView<StudyComp> sitePageableListView = new PageableListView<StudyComp>("studyCompList", 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<StudyComp> item) { StudyComp studyComponent = item.getModelObject(); /* The Component ID */ if (studyComponent.getId() != null) { // Add the study Component Key here item.add(new Label("studyComponent.id", studyComponent.getId().toString())); } else { item.add(new Label("studyComponent.id", "")); } /* Component Name Link */ item.add(buildLink(studyComponent)); // TODO when displaying text escape any special characters /* Description */ if (studyComponent.getDescription() != null) { item.add(new Label("studyComponent.description", studyComponent.getDescription()));// the ID here must match the ones in mark-up } else { item.add(new Label("studyComponent.description", ""));// the ID here must match the ones in mark-up } /* Add the Keyword */ // TODO when displaying text escape any special characters if (studyComponent.getKeyword() != null) { item.add(new Label("studyComponent.keyword", studyComponent.getKeyword()));// the ID here must match the ones in mark-up } else { item.add(new Label("studyComponent.keyword", ""));// the ID here must match the ones in mark-up } /* 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.study.web.component.subject.form.DetailForm.java
License:Open Source License
@SuppressWarnings("unchecked") public void initialiseDetailForm() { subjectUIDTxtFld = new TextField<String>(Constants.SUBJECT_UID) { private static final long serialVersionUID = 1L; @Override//from ww w .j a v a2 s . co m protected void onBeforeRender() { boolean isNew = isNew(); boolean autoGenerate = containerForm.getModelObject().getLinkSubjectStudy().getStudy() .getAutoGenerateSubjectUid(); if (isNew && !autoGenerate) { setEnabled(true); } else { setEnabled(false); } super.onBeforeRender(); } }; subjectUIDTxtFld.setOutputMarkupId(true); firstNameTxtFld = new TextField<String>(Constants.PERSON_FIRST_NAME); middleNameTxtFld = new TextField<String>(Constants.PERSON_MIDDLE_NAME); lastNameTxtFld = new TextField<String>(Constants.PERSON_LAST_NAME); previousLastNameTxtFld = new TextField<String>(Constants.SUBJECT_PREVIOUS_LAST_NAME) { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { if (!isNew()) { String subjectPreviousLastname = iArkCommonService .getPreviousLastname(containerForm.getModelObject().getLinkSubjectStudy().getPerson()); containerForm.getModelObject().setSubjectPreviousLastname(subjectPreviousLastname); } setEnabled(isNew()); super.onBeforeRender(); } }; preferredNameTxtFld = new TextField<String>(Constants.PERSON_PREFERRED_NAME); otherIdWebMarkupContainer = new WebMarkupContainer("otherIDWMC"); otherIdListView = new AbstractListEditor<OtherID>("linkSubjectStudy.person.otherIDs") { private static final long serialVersionUID = 1L; @Override protected void onPopulateItem(ListItem<OtherID> item) { PropertyModel<String> otherIDpropModel = new PropertyModel<String>(item.getModelObject(), "otherID"); PropertyModel<String> otherIDSourcepropModel = new PropertyModel<String>(item.getModelObject(), "otherID_Source"); TextField<String> otherIdTxtFld = new TextField<String>("otherid", otherIDpropModel); otherIdTxtFld.setRequired(true); TextField<String> otherIdSourceTxtFld = new TextField<String>("otherid_source", otherIDSourcepropModel); otherIdSourceTxtFld.setRequired(true); item.add(otherIdTxtFld); item.add(otherIdSourceTxtFld); item.add(new AjaxButton("delete") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { studyService.delete(item.getModelObject()); otherIdListView.getModelObject().remove(item.getIndex()); target.add(otherIdWebMarkupContainer); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { onSubmit(target, form); } }); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; otherIdWebMarkupContainer.setOutputMarkupId(true); addNewOtherIdBtn = new AjaxButton("newOtherID") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { OtherID newOtherID = new OtherID(); newOtherID.setPerson(containerForm.getModelObject().getLinkSubjectStudy().getPerson()); otherIdListView.getModelObject().add(newOtherID); target.add(otherIdWebMarkupContainer); super.onSubmit(target, form); } }; addNewOtherIdBtn.setDefaultFormProcessing(false); otherIdWebMarkupContainer.add(otherIdListView); otherIdWebMarkupContainer.add(addNewOtherIdBtn); preferredEmailTxtFld = new TextField<String>(Constants.PERSON_PREFERRED_EMAIL); otherEmailTxtFld = new TextField<String>(Constants.PERSON_OTHER_EMAIL); heardAboutStudyTxtFld = new TextField<String>(Constants.SUBJECT_HEARD_ABOUT_STUDY_FROM); dateOfBirthTxtFld = new DateTextField(Constants.PERSON_DOB, au.org.theark.core.Constants.DD_MM_YYYY); ArkDatePicker dobDatePicker = new ArkDatePicker(); dobDatePicker.bind(dateOfBirthTxtFld); dateOfBirthTxtFld.add(dobDatePicker); currentOrDeathageLable = new Label(Constants.PERSON_CURRENT_OR_DEATH_AGE); currentOrDeathageLable.setOutputMarkupId(true); dateOfBirthTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { //update label at date of birth change. setCurrentOrDeathAgeLabel(); setDeathDetailsContainer(); target.add(wmcDeathDetailsContainer); target.add(currentOrDeathageLable); } }); dateLastKnownAliveTxtFld = new DateTextField("linkSubjectStudy.person.dateLastKnownAlive", au.org.theark.core.Constants.DD_MM_YYYY); ArkDatePicker dateLastKnownAlivePicker = new ArkDatePicker(); dateLastKnownAlivePicker.bind(dateLastKnownAliveTxtFld); dateLastKnownAliveTxtFld.add(dateLastKnownAlivePicker); dateOfDeathTxtFld = new DateTextField(Constants.PERSON_DOD, au.org.theark.core.Constants.DD_MM_YYYY); causeOfDeathTxtFld = new TextField<String>(Constants.PERSON_CAUSE_OF_DEATH); ArkDatePicker dodDatePicker = new ArkDatePicker(); dodDatePicker.bind(dateOfDeathTxtFld); dateOfDeathTxtFld.add(dodDatePicker); dateOfDeathTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { //update label at date of text change. setCurrentOrDeathAgeLabel(); setDeathDetailsContainer(); target.add(wmcDeathDetailsContainer); target.add(currentOrDeathageLable); } }); commentTxtAreaFld = new TextArea<String>(Constants.PERSON_COMMENT); wmcDeathDetailsContainer = new WebMarkupContainer("deathDetailsContainer"); wmcDeathDetailsContainer.setOutputMarkupId(true); // Default death details to disabled (enable onChange of vitalStatus) setDeathDetailsContainer(); // Initialise Drop Down Choices // We can also have the reference data populated on Application start // and refer to a static list instead of hitting the database // Title Collection<TitleType> titleTypeList = iArkCommonService.getTitleType(); ChoiceRenderer<TitleType> defaultChoiceRenderer = new ChoiceRenderer<TitleType>(Constants.NAME, Constants.ID); titleTypeDdc = new DropDownChoice<TitleType>(Constants.PERSON_TYTPE_TYPE, (List) titleTypeList, defaultChoiceRenderer); titleTypeDdc.add(new ArkDefaultFormFocusBehavior()); // Preferred Status Collection<EmailStatus> allEmailStatusList = iArkCommonService.getAllEmailStatuses(); ChoiceRenderer<EmailStatus> preferredEmailStatusRenderer = new ChoiceRenderer<EmailStatus>(Constants.NAME, Constants.ID); preferredEmailStatusDdc = new DropDownChoice<EmailStatus>(Constants.PERSON_PREFERRED_EMAIL_STATUS, (List<EmailStatus>) allEmailStatusList, preferredEmailStatusRenderer); // Email Status // Collection<EmailStatus> emailStatusList = iArkCommonService.getEmailStatus(); ChoiceRenderer<EmailStatus> otherEmailStatusRenderer = new ChoiceRenderer<EmailStatus>(Constants.NAME, Constants.ID); otherEmailStatusDdc = new DropDownChoice<EmailStatus>(Constants.PERSON_OTHER_EMAIL_STATUS, (List<EmailStatus>) allEmailStatusList, otherEmailStatusRenderer); // Vital Status Collection<VitalStatus> vitalStatusList = iArkCommonService.getVitalStatus(); ChoiceRenderer<VitalStatus> vitalStatusRenderer = new ChoiceRenderer<VitalStatus>(Constants.NAME, Constants.ID); vitalStatusDdc = new DropDownChoice<VitalStatus>(Constants.PERSON_VITAL_STATUS, (List<VitalStatus>) vitalStatusList, vitalStatusRenderer); vitalStatusDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { //update label at vital status change. setCurrentOrDeathAgeLabel(); setDeathDetailsContainer(); target.add(wmcDeathDetailsContainer); target.add(currentOrDeathageLable); } }); //initialise the current or death label. setCurrentOrDeathAgeLabel(); // Gender Type Collection<GenderType> genderTypeList = iArkCommonService.getGenderTypes(); ChoiceRenderer<GenderType> genderTypeRenderer = new ChoiceRenderer<GenderType>(Constants.NAME, Constants.ID); genderTypeDdc = new DropDownChoice<GenderType>(Constants.PERSON_GENDER_TYPE, (List<GenderType>) genderTypeList, genderTypeRenderer); // Subject Status List<SubjectStatus> subjectStatusList = iArkCommonService.getSubjectStatus(); ChoiceRenderer<SubjectStatus> subjectStatusRenderer = new ChoiceRenderer<SubjectStatus>(Constants.NAME, Constants.SUBJECT_STATUS_ID); subjectStatusDdc = new DropDownChoice<SubjectStatus>(Constants.SUBJECT_STATUS, subjectStatusList, subjectStatusRenderer); subjectStatusDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { if (subjectStatusDdc.getModelObject().getName().equalsIgnoreCase("Archive")) { Biospecimen biospecimenCriteria = new Biospecimen(); biospecimenCriteria.setLinkSubjectStudy(containerForm.getModelObject().getLinkSubjectStudy()); biospecimenCriteria.setStudy(containerForm.getModelObject().getLinkSubjectStudy().getStudy()); // check no biospecimens exist long count = iLimsService.getBiospecimenCount(biospecimenCriteria); if (count > 0) { error("You cannot archive this subject as there are Biospecimens associated "); target.focusComponent(subjectStatusDdc); } } processErrors(target); } }); // Marital Status Collection<MaritalStatus> maritalStatusList = iArkCommonService.getMaritalStatus(); ChoiceRenderer<MaritalStatus> maritalStatusRender = new ChoiceRenderer<MaritalStatus>(Constants.NAME, Constants.ID); maritalStatusDdc = new DropDownChoice<MaritalStatus>(Constants.PERSON_MARITAL_STATUS, (List) maritalStatusList, maritalStatusRender); // Container for preferredEmail (required when Email selected as preferred contact) wmcPreferredEmailContainer = new WebMarkupContainer("preferredEmailContainer"); wmcPreferredEmailContainer.setOutputMarkupPlaceholderTag(true); // Depends on preferredContactMethod setPreferredEmailContainer(); // Person Contact Method List<PersonContactMethod> contactMethodList = iArkCommonService.getPersonContactMethodList(); ChoiceRenderer<PersonContactMethod> contactMethodRender = new ChoiceRenderer<PersonContactMethod>( Constants.NAME, Constants.ID); personContactMethodDdc = new DropDownChoice<PersonContactMethod>(Constants.PERSON_CONTACT_METHOD, (List<PersonContactMethod>) contactMethodList, contactMethodRender); personContactMethodDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { // Check what was selected and then toggle setPreferredEmailContainer(); target.add(wmcPreferredEmailContainer); } }); initConsentFields(); attachValidators(); addDetailFormComponents(); deleteButton.setVisible(false); historyButtonPanel = new HistoryButtonPanel(containerForm, arkCrudContainerVO.getEditButtonContainer(), arkCrudContainerVO.getDetailPanelFormContainer()); }
From source file:au.org.theark.study.web.component.subject.SearchResultListPanel.java
License:Open Source License
public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider) { DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) { @Override//w w w .j av a 2 s.c o m protected void populateItem(final Item<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.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.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 . jav a2 s. com*/ 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.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// ww w .ja v a 2s .co m 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.subjectUpload.SearchResultListPanel.java
License:Open Source License
/** * // w w w . ja v a 2s . co m * @param iModel * @return the pageableListView of Upload */ @SuppressWarnings("unchecked") 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(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_ID, upload.getId().toString())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_ID, "")); } // / The filename if (upload.getFilename() != null) { // Add the id component here item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_FILENAME, upload.getFilename())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_FILENAME, "")); } // File Format if (upload.getFileFormat() != null) { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_FILE_FORMAT, upload.getFileFormat().getName())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_FILE_FORMAT, "")); } // UserId if (upload.getUserId() != null) { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_USER_ID, upload.getUserId())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_USER_ID, "")); } // Start time if (upload.getStartTime() != null) { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_START_TIME, upload.getStartTime().toString())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_START_TIME, "")); } // Finish time if (upload.getFinishTime() != null) { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_FINISH_TIME, upload.getFinishTime().toString())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_FINISH_TIME, "")); } // Finish time if (upload.getUploadStatus() != null && upload.getUploadStatus().getShortMessage() != null) { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME, upload.getUploadStatus().getShortMessage())); } else { item.add(new Label(au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME, "")); } // Download file link button item.add(buildDownloadButton(upload)); // Download upload report button item.add(buildDownloadReportButton(upload)); // Delete the upload file // item.add(buildDeleteButton(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:by.parfen.disptaxi.webapp.etc.ChoicePage.java
License:Apache License
/** * Constructor.// www . j a v a 2 s . c o m */ public ChoicePage() { final City city = cityService.get(15L); List<Street> streetsList; streetsList = streetService.getAllByCity(city); for (Street streetItem : streetsList) { List<Point> pointsList = pointService.getAllByStreet(streetItem); List<String> pointNames = new ArrayList<String>(); for (Point pointItem : pointsList) { pointNames.add(pointItem.getName()); } pointsMap.put(streetItem.getName(), pointNames); } // pointsMap.put("", Arrays.asList("12", "22", "34")); // pointsMap.put("", Arrays.asList("2", "4", "45", "13", "78")); // pointsMap.put("", Arrays.asList("10", "12", "22", "4", "6")); IModel<List<? extends String>> makeChoices = new AbstractReadOnlyModel<List<? extends String>>() { @Override public List<String> getObject() { return new ArrayList<String>(pointsMap.keySet()); } }; IModel<List<? extends String>> modelChoices = new AbstractReadOnlyModel<List<? extends String>>() { @Override public List<String> getObject() { List<String> points = pointsMap.get(selectedStreetName); if (points == null) { points = Collections.emptyList(); } return points; } }; Form<Void> form = new Form<Void>("form"); add(form); final DropDownChoice<String> streets = new DropDownChoice<String>("streets", new PropertyModel<String>(this, "selectedStreetName"), makeChoices); final DropDownChoice<String> points = new DropDownChoice<String>("points", new Model<String>(), modelChoices); points.setOutputMarkupId(true); form.add(streets); form.add(points); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); add(feedback); form.add(new AjaxButton("go") { @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) { super.onAfterSubmit(target, form); info(" : " + streets.getModelObject() + " " + points.getModelObject()); target.add(feedback); } }); streets.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(points); } }); Form<Void> ajaxForm = new Form<Void>("ajaxForm"); add(ajaxForm); final AutoCompleteTextField<String> field = new AutoCompleteTextField<String>("ac", new Model<String>("")) { @Override protected Iterator<String> getChoices(String input) { if (Strings.isEmpty(input)) { List<String> emptyList = Collections.emptyList(); return emptyList.iterator(); } List<String> choices = new ArrayList<String>(10); List<Street> streetsList = streetService.getAllByCity(city); for (final Street streetItem : streetsList) { final String streetName = streetItem.getName(); if (streetName.toUpperCase().startsWith(input.toUpperCase())) { choices.add(streetName); if (choices.size() == 10) { break; } } } return choices.iterator(); } }; ajaxForm.add(field); final Label label = new Label("selectedValue", field.getDefaultModel()); label.setOutputMarkupId(true); ajaxForm.add(label); field.add(new AjaxFormSubmitBehavior(ajaxForm, "onchange") { @Override protected void onSubmit(AjaxRequestTarget target) { target.add(label); List<Street> streetList = streetService.getAllByCityAndName(city, label.getDefaultModelObjectAsString()); if (streetList.size() == 1) { setSelectedStreet(streetList.get(0)); } } @Override protected void onError(AjaxRequestTarget target) { } }); }
From source file:com.asptt.plongee.resa.model.AdherentDataView.java
@Override protected void populateItem(final Item item) { final Adherent adherent = (Adherent) item.getModelObject(); item.add(new IndicatingAjaxLink("select") { @Override//from w w w . jav a2 s . c o m public void onClick(AjaxRequestTarget target) { GererAdherents.replaceModalWindowModif(target, item.getModel()); GererAdherents.getModalModif().show(target); } }); item.add(new IndicatingAjaxLink("suppAdh") { @Override public void onClick(AjaxRequestTarget target) { GererAdherents.replaceModalWindowSupp(target, item.getModel()); GererAdherents.getModalSupp().show(target); } }); item.add(new IndicatingAjaxLink("pwdAdh") { @Override public void onClick(AjaxRequestTarget target) { GererAdherents.replaceModalWindowPwd(target, item.getModel()); GererAdherents.getModalPwd().show(target); } }); item.add(new Label("license", adherent.getNumeroLicense())); item.add(new Label("nom", adherent.getNom())); item.add(new Label("prenom", adherent.getPrenom())); // Ds que le plongeur est encadrant, on affiche son niveau d'encadrement String niveauAffiche = adherent.getPrerogative(); item.add(new Label("niveau", niveauAffiche)); //add openPdf resouceLink with webResource pdf for visu Certificat mdical item.add(new UtilsFSpdf().createWebResourcePdf(adherent, null)); item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() { @Override public String getObject() { String cssClass; if (item.getIndex() % 2 == 1) { cssClass = "even"; } else { cssClass = "odd"; } if (!adherent.isActif()) { cssClass = cssClass + " inactif"; } return cssClass; } })); }
From source file:com.asptt.plongee.resa.model.ExterneDataView.java
@Override protected void populateItem(final Item item) { final Adherent externe = (Adherent) item.getModelObject(); item.add(new IndicatingAjaxLink("select") { @Override// w w w.ja va 2 s . c o m public void onClick(AjaxRequestTarget target) { GererExternes.replaceModalWindowModif(target, item.getModel()); GererExternes.getModalModif().show(target); } }); item.add(new IndicatingAjaxLink("suppAdh") { @Override public void onClick(AjaxRequestTarget target) { GererExternes.replaceModalWindowSupp(target, item.getModel()); GererExternes.getModalSupp().show(target); } }); item.add(new Label("license", externe.getNumeroLicense())); item.add(new Label("nom", externe.getNom())); item.add(new Label("prenom", externe.getPrenom())); // Ds que le plongeur est encadrant, on affiche son niveau d'encadrement String niveauAffiche = externe.getPrerogative(); item.add(new Label("niveau", niveauAffiche)); item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() { @Override public String getObject() { String cssClass; if (item.getIndex() % 2 == 1) { cssClass = "even"; } else { cssClass = "odd"; } return cssClass; } })); }
From source file:com.asptt.plongee.resa.ui.web.wicket.page.AccueilPage.java
public AccueilPage() { // // add the clock component // Clock clock = new Clock("clock", TimeZone.getTimeZone("Europe/Paris")); // add(clock); ///*w ww . j av a 2 s.c om*/ // // add the ajax behavior which will keep updating the component every 5 // // seconds // clock.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(20))); setPageTitle("Accueil"); Adherent adh = getResaSession().getAdherent(); // Si l'adhrent est identifi mais qu'il n'a pas chang son password (password = licence) if (getResaSession().getAdherent().getNumeroLicense() .equalsIgnoreCase(getResaSession().getAdherent().getPassword())) { setResponsePage(ModifPasswordPage.class); } IModel<Adherent> model = new Model<Adherent>(adh); add(new Label("hello", new StringResourceModel(CatalogueMessages.ACCUEIL_BIENVENUE, this, model, new Object[] { new PropertyModel<Adherent>(model, "prenom"), calculerDateCourante() }))); try { List<Message> messages = getResaSession().getAdherentService().rechercherMessage(); List<Message> msgSepares = new ArrayList(); Message ligne = new Message(); ligne.setLibelle(" "); if (!messages.isEmpty()) { for (Message msg : messages) { msgSepares.add(msg); msgSepares.add(ligne); } int ledernier = msgSepares.size(); msgSepares.remove(ledernier - 1); } MessageDataProvider pDataProvider = new MessageDataProvider(msgSepares); add(new DataView<Message>("listmessages", pDataProvider) { @Override protected void populateItem(final Item<Message> item) { final Message message = item.getModelObject(); item.add(new Label("libelle", message.getLibelle())); item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() { @Override public String getObject() { String cssClass; if (item.getIndex() % 2 == 1) { cssClass = "even"; } else { cssClass = "odd"; } return cssClass; } })); } }); //gestion du message pour le certificat medical perim String msgCertificat = ""; try { getResaSession().getPlongeeService().checkCertificatMedical(getResaSession().getAdherent(), null); } catch (ResaException e) { if (e.getKey().equalsIgnoreCase(CatalogueMessages.CM_PERIME)) { StringResourceModel srm = new StringResourceModel(CatalogueMessages.CM_PERIME, this, null); msgCertificat = srm.getString(); } else { String nbJour = e.getKey().substring(14); StringResourceModel srm = new StringResourceModel(CatalogueMessages.CM_A_RENOUVELER, this, model, new Object[] { new PropertyModel<Adherent>(model, "prenom"), nbJour }); msgCertificat = srm.getString(); } } add(new Label("certificat", msgCertificat)); //gestion du message pour le cotisation non renouvelle try { getResaSession().getAdherentService().checkAnneeCotisation(getResaSession().getAdherent()); } catch (ResaException e) { PageParameters pp = new PageParameters(); StringResourceModel msgCotisation = new StringResourceModel( CatalogueMessages.ACCUEIL_COTISATION_PERIME, this, new Model<Adherent>(adh)); pp.add("cotisation", msgCotisation.getString()); setResponsePage(new LoginPage(pp)); } } catch (TechnicalException e) { e.printStackTrace(); ErreurTechniquePage etp = new ErreurTechniquePage(e); setResponsePage(etp); } }