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; }
4

1 に答える 1

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 を介してすべてのプロパティにアクセスできるようになります。

于 2013-09-10T16:34:54.047 に答える