-1

このアーキテクチャの Java アプリがあります: エンティティ + 永続性 + ビジネス + REST サービス。

ビューレイヤーをJSFなしで作りたい、つまりHTML+CSS+JS(JQuery+Ajax)だけを使いたい。

REST サービスにアクセスするための JavaScript クラスを作成するより良い方法は何ですか?

var Bookmark = function() {
this.id;
this.description;
this.link;
};

Bookmark.prototype._insert = function() {
// here should i put the JQuery Ajax Call?
}; 

Bookmark.prototype._delete = function() {
// here should i put the JQuery Ajax Call?
}

Bookmark.prototype._update = function() {
// here should i put the JQuery Ajax Call?
}

Bookmark.prototype._findById = function() {
// here should i put the JQuery Ajax Call?
}

Bookmark.prototype._findById = function() {
// here should i put the JQuery Ajax Call?
}

上記のフォーマットは受け入れられますか?

4

1 に答える 1

1

持っているものでOKです。遭遇する可能性のある問題は、サーバーとの対話が 1 つのモデル オブジェクトの領域に明確に分類されない場合、モデル レイヤーが乱雑になることです。

サーバー上で行っていることを実行して、サービス層を作成してみませんか?

App.API =  {

     login: function(onSuccess) {....}

     findBook: function(id, onSuccess) {....}


}
于 2013-05-08T16:58:29.463 に答える