Expand my Community achievements bar.

DateTime Metadata Field not rendering on card view for AEM assets but will render elsewhere

Avatar

Level 2

Hello all! 

 

Im trying to customize some metadata that displays on the card view found here (keep in mind this is overlayed already just linking the actual path)

 

/libs/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp

 

Im able to retrieve metadata using the following jsp - which renders on the card view perfectly.

 

 

 

 

<%
ValueMap Metadata = Resource.getChild("jcr:content/metadata").getValueMap();
Object UsageParams = Metadata.get("xmpRights:usageParameters");

if (UsageParams != null) {
    if (UsageParams instanceof String[]) {
        String[] dummyBrands = (String[]) UsageParams;
        for (String dummyBrand : dummyBrands) {
            // Replace hyphens with spaces
            dummyBrand = dummyBrand.replace("-", " ");
            out.println(dummyBrand + "<br>");
        }
    } else if (UsageParams instanceof String) {
        // Replace hyphens with spaces
        String dummyBrand = ((String) UsageParams).replace("-", " ");
        out.println(dummyBrand + "<br>");
    } else {
        out.println("No brands represented");
    }
} else {
    out.println("No brands represented");
}
%>

 

 

 

When I try to grab a custom datetime field expiration wise using this same logic (of course im aware object is not for date fields so I use calendar instead) I cant for the life of me get the date expiration field to appear. For some reason propertylist.jsp does not want to take in the custom_assetexpirationdate metadata field. 

 

I was able to successfully do this on reorder.jsp for the list view field but no matter how I apply it, still wont render. Here is the list view code where it works with date metadata

 

 

 

<%@ page import="org.apache.sling.api.resource.ValueMap" %>
<%@ page import="org.apache.sling.api.resource.Resource" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0"%>


<%
    final String ASSET_RES_TYPE = "dam/gui/coral/components/admin/contentrenderer/row/asset";
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");


    Resource assetResource = resource;
    String eaemTitle = "";
    String formattedDate = "";
	String codedDate = "";

    if (assetResource != null && ASSET_RES_TYPE.equals(assetResource.getResourceType())) {
        Resource metadataResource = assetResource.getChild("jcr:content/metadata");

        if (metadataResource != null) {
            ValueMap vm = metadataResource.getValueMap();
            eaemTitle = vm.get("custom_assetexpirationdate", "");
            if (!eaemTitle.isEmpty()) {
				 try {
                     codedDate = eaemTitle.replaceAll("-", "").split("T")[0];



                } catch (Exception e) {
                    // do nothing
                }
            }
            if (!eaemTitle.isEmpty()) {
                try {
                    Date date = dateFormat.parse(eaemTitle.split("T")[0]);
                    formattedDate = dateFormat.format(date);

                } catch (Exception e) {
                    // do nothing
                }
            }
        }
    }
%>

<%
request.setAttribute("formattedDate", formattedDate);
request.setAttribute("codedDate", codedDate);
%>

 

 

 

Does anyone have any idea what im doing wrong here? Any guidance would be insanely helpful. Thanks! 

1 Reply

Avatar

Level 2

This has been solved...

 

SimpleDate wasnt working on this propertylist.jsp I had to manually extract the values from the valuemap.