We are using Tridion 2013 SP1 with DXA 1.5 java. One of our requirement we want to serve the JSON formated data file( apple-app-site-association ) in my web site.
My component schema has only one rich text field (without Rich Text Formatting) and Only one component presentation is enough for the page. I have published the page in to broker DB. I built the page in CM (apple-app-site-association.json) but When I request the page (http://localhost:9080/apple-app-site-association) without extension.
Note: The page response content type should be "Content-Type: application/json
"
The page response should be like this:
http://localhost:9080/apple-app-site-association (without page .json extension)
{
"applinks": {
"apps": [],
"details": [
{
"appID": "xxx.com.xx.AccidentToolkit",
"paths": [
"/cp/mobile/*"
]
}
]
}
}
Updated:
I have created a schema "CodeSchema" with only one rich text field name "code"(without Rich Text Formatting) I created a component for this shcema it's has JSON data. I have created a page(JSON PT and only one component presentation for my component) I published the page. it's in broker DB.
I'm trying to get the page/component data through my custom controler then return it to my view (jsp):
RegisteredViewModel:
@RegisteredViewModel(viewName = "CodeJSONPage", modelClass = CodeComponentModel.class, controllerName = "AppleAppSiteAssociationController")
Model:
@SemanticEntity(entityName = "Code", vocabulary = SDL_CORE, prefix = "c")
public class CodeComponentModel extends AbstractEntityModel {
@JsonProperty("code")
@SemanticProperty("c:code")
private RichText code;
public RichText getCode() {
return code;
}
public void setCode(RichText code) {
this.code = code;
}
}
Controller:
@Controller
@RequestMapping(method = RequestMethod.GET, value="/apple-app-site-association", headers="content-type=application/json")
public class AppleAppSiteAssociationController extends EntityController {
private static final Logger LOG = LoggerFactory.getLogger(AppleAppSiteAssociationController.class);
@RequestMapping()
public String GetAppleAppSiteAssociationJSON(@RequestHeader("Content-Type") String ContentType, @RequestHeader("Accept") String acceptType, ModelMap modelMap, HttpServletRequest request) {
// Am trying to get the getCode() data here
//modelMap.put("entity", jObjects);
return "Nationwide/Page/CodeJSONPage";
}
}