简体   繁体   English

将API公开给Tapestry Web应用程序

[英]Exposing an API to a Tapestry web application

I am working on a Tapestry 5 based web application that should expose an API to iPhone and Android devices. 我正在开发一个基于Tapestry 5的Web应用程序,它应该向iPhone和Android设备公开API。 Currently the API is implemented using the built in MVC capabilities of tapestry. 目前,API是使用tapestry的内置MVC功能实现的。 Eg all the services are handler methods that return JSON strings in Tapestry page classes dedicated to mobile access. 例如,所有服务都是处理程序方法,它们在专用于移动访问的Tapestry页面类中返回JSON字符串。 Authentication is done with Spring Security and every user is bound to a session. 使用Spring Security进行身份验证,并且每个用户都绑定到会话。 I'm rather new to this stuff, so correct me if I'm wrong, but this doesn't seem like a very clean solution. 我对这些东西比较新,所以如果我错了,请纠正我,但这似乎不是一个非常干净的解决方案。

What are possible drawbacks to this solutions? 这个解决方案有哪些可能的缺点? What are significiant advantages when using a REST-API instead? 使用REST-API时有什么显着优势? What would be best practice in such a case? 在这种情况下最佳做法是什么?

For SeeSaw.com we have similar requirements to expose feeds from our T5 web application and have tried a number of different approaches. 对于SeeSaw.com,我们有类似的要求来公开来自我们的T5 Web应用程序的提要,并尝试了许多不同的方法。

For read only data we expose write a T5 page/component that renders XML (or JSON) as a feed. 对于只读数据,我们公开了一个T5页面/组件,它将XML(或JSON)呈现为一个feed。 For read/write data we implement tapestry OnXXX events via JSON. 对于读/写数据,我们通过JSON实现tapestry OnXXX事件。 By splitting it out this way you get a more efficient site (as the read only stuff can be cached). 通过这种方式将其拆分,您可以获得更高效的站点(因为可以缓存只读的内容)。

Maybe this will help ... 也许这会有所帮助......

Template Skinning 模板剥皮

To quote from the article 引用文章

In this article I want to share with you a new awesome Tapestry feature introduced in 5.3. 在本文中,我想与您分享5.3中引入的一个新的令人敬畏的Tapestry功能。 This feature allows you to provide different skins for a single page by creating several templates. 此功能允许您通过创建多个模板为单个页面提供不同的外观。 These different templates are used by Tapestry to render the same page in a special way for different clients. Tapestry使用这些不同的模板以特殊方式为不同的客户端呈现相同的页面。 For example, when developing a web application for both standard and mobile clients you might need to render the same page different depending on the current client. 例如,在为标准客户端和移动客户端开发Web应用程序时,您可能需要根据当前客户端呈现不同的页面。 So, you need to create two different templates for each page and choose one of them depending on the user agent sent by the client. 因此,您需要为每个页面创建两个不同的模板,并根据客户端发送的用户代理选择其中一个模板。

This might be the "clean solution" you are looking for? 这可能是您正在寻找的“清洁解决方案”? Cheers! 干杯!

Murray... 穆雷...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Tapestry 5 Web应用程序中编辑复杂的Java对象 - Editing a complex Java object in a Tapestry 5 web application 如何使用Tapestry在Web应用程序中返回文件 - How to return a file in web application using Tapestry 在Tapestry Web应用程序中处理域异常的最佳方法是什么? - What is the best way to handle domain exceptions in Tapestry web application? 使用Tapestry和Hibernate的Web应用程序在调用persist()时引发异常 - Web application using Tapestry and Hibernate throws Exception when calling persist() 通过HTTP调用公开简单的Java应用程序方法(不是Web应用程序) - Exposing simple Java application methods through HTTP calls (Not a web application) 挂毯页面和API - Tapestry page and API 通过Internet仅公开Web应用程序的某些部分 - Exposing only certain part of the web application over internet 通过ISAPI或URL重写通过IIS公开Java Web应用程序 - Exposing Java web application via IIS through ISAPI or URL rewrite 创建用于内部应用程序的Web服务并将其公开给其他人 - Creating a web service for use in an internal application and exposing it to others Java Tapestry Web应用程序中的基本图像编辑器(打开文件,裁剪,保存到新文件) - Basic image editor (open file, crop, save to new file) in a Java Tapestry web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM