2013-05-08 197 views
0

我對Java很新,所以請耐心等待。我試圖檢索一個子節點的屬性。比如我試圖檢索與圖像屬性相關聯的所有屬性:檢索子節點的屬性

/content 
    /foo 
     /jcr:content 
      /page 
       /page_child 
        /image <----- 

目前我的腳本檢索從page_child所有的屬性,但我怎麼得到的「形象」

public void setPageContext(PageContext context) { 
    ValueMap properties = (ValueMap) context.getAttribute("properties"); 
    closeText = properties.get("closeText", ""); 
    imageURL = properties.get("fileReference", ""); 
} 

public String getCloseText() { return closeText; } 
public String getCloseText() { return imageURL; } 
屬性

回答

0

看看/ libs/foundation/components/adaptiveimage

在JSP中,他們使用圖像文件的jcr:content創建一個新的資源。

Resource fileJcrContent = resource.getChild("file").getChild("jcr:content"); 
if (fileJcrContent != null) { 
    ValueMap fileProperties = fileJcrContent.adaptTo(ValueMap.class); 
    String mimeType = fileProperties.get("jcr:mimeType", "jpg"); 
    extension = mimeType.substring(mimeType.lastIndexOf("/") + 1); 
} 

從那裏,所有的屬性將可以通過fileProperties訪問。