Hi, I am trying to use the Struts2 s:select tag but the drop down value coming from the db is not being set to the drop down as selected value and the screen always shows the default first value in the list.
Can some one please help me. *JSP Code* <s:select name="diagnosisDTO.primaryDiagnosis" list="primaryDiagnosisTypes" listKey="dstLookupTypeId" listValue="lookupValue" multiple="false" headerKey="-1" headerValue="Please Select" size="1"/> *Action Class Code* *I have Disease Tracking as a Model object and inside that model I have DiagnosisDTO object where I have properties which are matched to the jsp select tag above* *This is the Model Object defined in the Action Class public DiseaseTracking getModel() { return this.diseasetracking; }* *DiseaseTracking Object with DiagnosisDTO property below * *private DiagnosisDTO diagnosisDTO; public DiagnosisDTO getDiagnosisDTO() { return diagnosisDTO; } public void setDiagnosisDTO(DiagnosisDTO diagnosisDTO) { this.diagnosisDTO = diagnosisDTO; }* *DiagnosisDTO Object with property **primaryDiagnosis **and getter and setter* * private int primaryDiagnosis; public int getPrimaryDiagnosis() { return primaryDiagnosis; }* * public void setPrimaryDiagnosis(int primaryDiagnosis) { this.primaryDiagnosis = primaryDiagnosis; }* *This method is a service call to get the disease tracking object* * public String getHepC() throws Exception { List allDstLookupTypes = GenCache.getListOfDstLookupType(user.getCurrentClientId()); setPrimaryDiagnosisTypes(this.getSpecificDstLookupTypes(Constants.DST_LOOKUP_GRP_CODE_ID_PRD, allDstLookupTypes)); DiseaseTrackingDelegate dstDelegate = new DiseaseTrackingDelegate(); int dstId = 20000048; //The below is the service call to db which will get the disease tracking object with some lists objects. diseasetracking = dstDelegate.getDSTById(user.getCurrentClientId(), dstId, null); //the below is the code to convert the list returned from service to another object Diagnosis DTO and set that back to Disease Tracking model object convertDiagnosisListToDiagnosisDTO(diseasetracking.getAlDstLookup()); return "success"; } public List<DstLookupType> getSpecificDstLookupTypes(String grpLookupTypeId, List<DstLookupType> allDstLookupTypes){ List<DstLookupType> lookupTypes = new ArrayList<DstLookupType>(); for(int i=0; i < allDstLookupTypes.size();i++) { if( allDstLookupTypes.get(i).getDstLookupGrpCodeId().equals(grpLookupTypeId)){ lookupTypes.add(allDstLookupTypes.get(i)); } } return lookupTypes;}* * public void convertDiagnosisListToDiagnosisDTO(List<DSTLookupDTO> alDstLookup) throws CpsEntException { DiagnosisDTO dt = null; try { if(alDstLookup != null && alDstLookup.size() != 0) { dt = new DiagnosisDTO(); for (final DSTLookupDTO dstLookup : alDstLookup) { if(dstLookup.getDstLookupGrpCodeId().equals(Constants.DST_LOOKUP_GRP_CODE_ID_PRD)) { dt.setPdDstLookupId(dstLookup.getDstLookupId()); //dt.setPrimaryDiagnosis(dstLookup.getDstLookupTypeId()); diseasetracking.setPrimaryDiagnosis(dstLookup.getDstLookupTypeId()); dt.setPdDstSubModuleRowId(dstLookup.getDstSubModuleRowId()); dt.setOtherPrimaryDiagnosis(dstLookup.getOtherValue()); } else if(dstLookup.getDstLookupGrpCodeId().equals(Constants.DST_LOOKUP_GRP_CODE_ID_GNT)) { dt.setGenoTypeDstLookupId(dstLookup.getDstLookupId()); dt.setGenoType(dstLookup.getDstLookupTypeId()); dt.setGenoTypeDstSubModuleRowId(dstLookup.getDstSubModuleRowId()); dt.setOtherGenoType(dstLookup.getOtherValue()); } else if(dstLookup.getDstLookupGrpCodeId().equals(Constants.DST_LOOKUP_GRP_CODE_ID_GNT2)) { dt.setGenoType2DstLookupId(dstLookup.getDstLookupId()); dt.setGenoType2(dstLookup.getDstLookupTypeId()); dt.setGenoType2DstSubModuleRowId(dstLookup.getDstSubModuleRowId()); dt.setOtherGenoType2(dstLookup.getOtherValue()); } else if(dstLookup.getDstLookupGrpCodeId().equals(Constants.DST_LOOKUP_GRP_CODE_ID_HVC)) { dt.setHivDstLookupId(dstLookup.getDstLookupId()); dt.setHivCoinfection(dstLookup.getDstLookupTypeId()); dt.setHivDstSubModuleRowId(dstLookup.getDstSubModuleRowId()); } else if(dstLookup.getDstLookupGrpCodeId().equals(Constants.DST_LOOKUP_GRP_CODE_ID_RNI)) { dt.setRenalDstLookupId(dstLookup.getDstLookupId()); dt.setRenalImpairment(dstLookup.getDstLookupTypeId()); dt.setRenalDstSubModuleRowId(dstLookup.getDstSubModuleRowId()); dt.setOtherRenalImpairment(dstLookup.getOtherValue()); } else if(dstLookup.getDstLookupGrpCodeId().equals(Constants.DST_LOOKUP_GRP_CODE_ID_SPLT)) { dt.setPostLiverDstLookupId(dstLookup.getDstLookupId()); dt.setPostLiverTransplant(dstLookup.getDstLookupTypeId()); dt.setPostLiverDstSubModuleRowId(dstLookup.getDstSubModuleRowId()); } } } } catch (Exception e) { e.printStackTrace(); throw new CpsEntException(e.getMessage()); } diseasetracking.setDiagnosisDTO(dt); } * Thanks