0

I have an object with these attributes:

public final class CaseNote {

    private final Long caseNoteId;
    private final Long subGroupId;
    private final String title;
    private final String caseNoteTypeCode;
    private final Date contactDate;
    private final Date completedDateTime;
    private final Long personVisitId;
    private final Date createdDateTime;
    private final Long createdByWorkerId;
    private final Long createdByTeamId;
    private final List<CaseNoteDetailsDTO> noteDetails = new ArrayList<CaseNoteDetailsDTO>();
    private final List<GroupMemberDetailsDTO> selectedMembers = new ArrayList<GroupMemberDetailsDTO>();
    private final ReferenceProvider referenceProvider;
    private final Date timeOutDate;


    public CaseNote(final CaseNotesDTO caseNoteDto, final List<CaseNoteDetailsDTO> noteDetails,
                    final List<GroupMemberDetailsDTO> selectedMembers, final ReferenceProvider referenceProvider) {

        this.caseNoteId = caseNoteDto.getCaseNoteId();
        this.subGroupId = caseNoteDto.getSubGroupId();
        this.title = caseNoteDto.getTitle();
        this.caseNoteTypeCode = caseNoteDto.getCaseNoteTypeCode();
        this.contactDate = caseNoteDto.getContactDateTime();
        this.completedDateTime = caseNoteDto.getCompletedDateTime();
        this.personVisitId = caseNoteDto.getPersonVisitId();
        this.createdDateTime = caseNoteDto.getCreatedDateTime();
        this.createdByWorkerId = caseNoteDto.getCreatedByWorkerId();
        this.createdByTeamId = caseNoteDto.getCreatedByTeamId();
        this.timeOutDate = caseNoteDto.getTimeOutDate();

        this.noteDetails.clear();
        this.selectedMembers.clear();
        this.noteDetails.addAll(noteDetails);
        Collections.sort(this.noteDetails, new CaseNoteDetailCreatedDateComparator());
        this.selectedMembers.addAll(selectedMembers);

        this.referenceProvider = referenceProvider;
    }

    private class CaseNoteDetailCreatedDateComparator implements Comparator<CaseNoteDetailsDTO> {

    @Override
    public int compare(final CaseNoteDetailsDTO firstCaseNoteDetail, final CaseNoteDetailsDTO secondCaseNoteDetail) {
        return firstCaseNoteDetail.getCreatedDateTime().compareTo(secondCaseNoteDetail.getCreatedDateTime());
    }
}

    public Long getCaseNoteId() {
        return caseNoteId;
    }

    public Long getSubGroupId() {
        return subGroupId;
    }

    public String getTitle() {
        return title;
    }

    public String getCaseNoteTypeCode() {
        return caseNoteTypeCode;
    }

    public Date getContactDate() {
        return contactDate;
    }

    public Date getCompletedDateTime() {
        return completedDateTime;
    }

    public Long getPersonVisitId() {
        return personVisitId;
    }

    public Date getCreatedDateTime() {
        return createdDateTime;
    }

    public Long getCreatedByWorkerId() {
        return createdByWorkerId;
    }

    public Long getCreatedByTeamId() {
        return createdByTeamId;
    }

    public List<CaseNoteDetailsDTO> getNoteDetails() {
        return Collections.unmodifiableList(noteDetails);
    }

    public List<GroupMemberDetailsDTO> getSelectedMembers() {
        return Collections.unmodifiableList(selectedMembers);
    }

    public boolean isSignificant() {
        boolean significantEvent = false;
        for (final CaseNoteDetailsDTO detail : this.getNoteDetails()) {
            significantEvent = significantEvent || detail.isSignificantEvent();
        }
        return significantEvent;
    }

    public String getCaseNoteTypeDescription() {
        return referenceProvider.provide(ReferenceDomain.CASENOTE_TYPE, getCaseNoteTypeCode());
    }

    public CaseNoteDetailsDTO getRootNoteDetails() {
        validateCaseNoteDetailsExists();
        return getNoteDetails().get(0);
    }

    public List<CaseNoteDetailsDTO> getAppendments() {
        validateCaseNoteDetailsExists();
        return getNoteDetails().subList(1, getNoteDetails().size());
    }

    private void validateCaseNoteDetailsExists() {
        if (getNoteDetails() == null || getNoteDetails().isEmpty()) {
            throw new IllegalStateException("No case note details found");
        }
    }

    public List<String> getMemberNames() {
        final List<String> memberNames = new ArrayList<String>();
        final List<GroupMemberDetailsDTO> selectedMembers = getSelectedMembers();
        for (final GroupMemberDetailsDTO memberDetails : selectedMembers) {
            memberNames.add(memberDetails.getName());
        }
        return memberNames;
    }

    public Date getTimeOutDate() {
        return timeOutDate;
    }

    public boolean isTimedOut() {
        return completedDateTime == null && new Date().after(this.timeOutDate);
    }

}

From a JSP file, I would like to print the attribute 'createdWorkerId', but it's not working. I tried to print the title and it works, but not with the createdWorkerId. The line is the following:

<span class="highlighted"><%=noteClassDescription%>:&nbsp;<c:out value="${casenote.createdByWorkerId}"/> </span>

Should I parse the createdWorkerId to a String before or the problem is other? Any help appreciated.

Thanks.

stack man
  • 2,303
  • 9
  • 34
  • 54
  • 1
    Have you stored `casenote` in any [variable scope](http://stackoverflow.com/q/16619015/1065197) for JSP? – Luiggi Mendoza Nov 18 '14 at 12:57
  • 1
    Have you checked if createdByWorkerId is empty or not using `Is not empty` ont he jsp.Maybe the object from the controller does not have any value that's why it is blank – Navish Sharma Nov 18 '14 at 13:00
  • I tried your if but is not working. Even that, is very useful, thanks! I am not using variable scopes. – stack man Nov 18 '14 at 13:48
  • The member `createdByWorkerId` is private. Shouldn't it be `casenote.getCreatedByWorkerId()`? – developerwjk Nov 18 '14 at 21:05

0 Answers0