Get html output from a jcr node in CQ5 -


i wanted know if there way rendered html output of page node in cq5 without hitting actual url. have page node , want rendered html output of page node programmatically in java , store in string without hitting page url.

any appreciated, in advance!

node it's data. sling framework responsible rendering data. use bunch of rules determine how data should rendered.sling script resolution cheet sheet sling web framework renders data via http requests.

to emulate request in cq/aem suggest use com.day.cq.contentsync.handler.util.requestresponsefactory service

import org.apache.sling.engine.slingrequestprocessor; import com.day.cq.contentsync.handler.util.requestresponsefactory;  @reference private requestresponsefactory requestresponsefactory;  @reference private slingrequestprocessor requestprocessor;  public string dostuff(){     httpservletrequest request = requestresponsefactory.createrequest("get", "/path/to/your/node.html");     request.setattribute(wcmmode.request_attribute_name, wcmmode.disabled);      bytearrayoutputstream out = new bytearrayoutputstream();     httpservletresponse response = requestresponsefactory.createresponse(out);      requestprocessor.processrequest(request, response, resourceresolver);             return out.tostring(response.getcharacterencoding()); } 

hope helps.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -