0

I am a new developer in Play world! For a project I need to have a mobile and desktop version. But I don't know how to!!

  • Create 2 applications, share the model..;
  • Create a mobile controller to separate the desktop views against the mobile views

I have no idea of how to make this properly. I know the responsive design but I can't use it on this project.

Thanks

PS: Sorry for my english

4

2 回答 2

0

根据用例,我会看一下Twitter Bootstrap之类的框架。使用 twitter 引导程序,您可以为桌面和移动设备使用一组视图模板。还有一个称为Kickstrap的框架和其他一些框架。

但另一方面,如果你想开发某种“后端”或“管理”应用程序(你仍然可以使用 twitter 引导程序,但你可能会看看 Sencha(EXT JS 和 Touch)或 Kendo UI 之类的框架。

无论您选择什么,Play 都将使您能够按照应有的方式开发服务器端(RESTful),因此前端的选择可以及时改变,但您的应用程序架构会很好:-)

于 2012-05-06T19:17:54.080 回答
0

任何一个都可以。因为它们本质上是相同的东西,2 组路由/控制器/视图加上 1 组域模型。

如果您使用的是我的 play clone,那么您可以将其简化为 1 组域模型 + 1 组路由/控制器 + 2 组视图,您可以执行以下操作:

public class Application extends Controller {
   ...
   @OnApplicationStart
   public static class ViewRouter extends Job {
        Controller.registerTemplateNameResolver(new ITemplateNameResolver(){
            @Override
            public String resolveTemplateName(String templateName) {
                return UserAgent.isMobile() ? "mobile/" + templateName : templateName;
            }
        });
   }
}

因此,您只需将您的移动视图放在下面app/views/mobile,而所有其他视图仍保留在 中app/views,模板将根据请求的用户代理动态加载,如果它来自移动设备,则app/views/mobile/..加载版本,否则将加载普通视图。

于 2012-05-06T20:09:26.950 回答