即時通訊使用wcm庫在jsp文件中,我有點卡住了。我在創作模板im中創建了一個新元素(「發佈日期」),並使用了我從原子調用引用的自定義jsp組件來生成「更新日期」字段。我試圖做的只是檢查,看看我添加的元素是否爲空,如果它然後使用更新的日期字段,如果它不是然後使用「發佈日期」元素。簡單的jsp文件使用wcm庫
我曾嘗試:
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);
}
,但林甚至沒有第一,如果條件內進入。我覺得這已經成爲一種簡單的方法來簡單地檢查一個元素是否存在,任何幫助都會被解密。