im new to using wcm library in jsp files and am a little stuck. I created a new element ("Publication Date") in the authoring templates im using and a custom jsp component which i am referencing from the atom call to generate the "updated date" field. What im trying to do is simply check to see if the element i added is present is not null, if it is then use the updated date field, if its not then use the "Publication Date" element.
I have tried:
DocumentIdIterator docIdsIter = workspace.findContentByPath(request.getRequestURI());
if (docIdsIter.hasNext()) {
Document doc = (Document)workspace.getById(docIdsIter.nextId());
// Cast to Content to retrieve the Publication date from the date component
Content myContent = (Content)doc;
// Get the Publication date
if (myContent.hasComponent("Publication Date")){
out.write("I am getting here");
DateComponent dateComponent = (DateComponent)myContent.getComponent("Publication Date");
if (dateComponent != null){
out.write(dateComponent.toString());
} else {
//out.write(last modified date);
}
} else {
//out.write(last modified date);
}
But im not even getting inside the first if condition. I feel that the has goto be an easier way to simply check if a element exists, any help would be appreceated.