use of org.apache.tapestry5.util.TextStreamResponse in project tapestry-5 by apache.
the class ComponentLibraries method generateJSONDescription.
@OnEvent("json")
Object generateJSONDescription(String libraryName) {
for (LibraryMapping mapping : componentClassResolver.getLibraryMappings()) {
if (libraryName.equalsIgnoreCase(mapping.libraryName)) {
this.libraryMapping = mapping;
break;
}
}
JSONObject object = new JSONObject();
object.put("libraryName", libraryName);
object.put("rootPackage", libraryMapping.getRootPackage());
final ComponentLibraryInfo info = getInfo();
if (info != null) {
JSONObject infoJsonObject = new JSONObject();
putIfNotNull("description", info.getDescription(), infoJsonObject);
putIfNotNull("homepage", info.getHomepageUrl(), infoJsonObject);
putIfNotNull("documentationUrl", info.getDocumentationUrl(), infoJsonObject);
putIfNotNull("javadocUrl", info.getJavadocUrl(), infoJsonObject);
putIfNotNull("groupId", info.getGroupId(), infoJsonObject);
putIfNotNull("artifactId", info.getArtifactId(), infoJsonObject);
putIfNotNull("version", info.getVersion(), infoJsonObject);
putIfNotNull("sourceBrowseUrl", info.getSourceBrowseUrl(), infoJsonObject);
putIfNotNull("sourceRootUrl", info.getSourceRootUrl(), infoJsonObject);
putIfNotNull("issueTrackerUrl", info.getIssueTrackerUrl(), infoJsonObject);
putIfNotNull("dependencyInfoUrl", info.getDependencyManagementInfoUrl(), infoJsonObject);
if (info.getTags() != null) {
for (String tag : info.getTags()) {
infoJsonObject.accumulate("tags", tag);
}
}
object.put("info", infoJsonObject);
}
addClasses("components", filter(componentClassResolver.getComponentNames()), Type.COMPONENT, info, object);
addClasses("pages", filter(componentClassResolver.getPageNames()), Type.PAGE, info, object);
addClasses("mixins", filter(componentClassResolver.getMixinNames()), Type.MIXIN, info, object);
return new TextStreamResponse("text/javascript", object.toString());
}
use of org.apache.tapestry5.util.TextStreamResponse in project tapestry-5 by apache.
the class TestableResponseImplTest method action_link.
@Test
public void action_link() {
Document document = tester.renderPage(TestPageForActionLinkWithStream.class.getSimpleName());
Element link = document.getElementById("mylink");
assertNotNull(link);
TestableResponse response = tester.clickLinkAndReturnResponse(link);
assertEquals(response.getOutput(), "<html><body>Rendered with TextStreamResponse</body></html>");
}
Aggregations