Archive for the ‘GWT’ Category
更新機能紹介(NEW)
株式会社ケネスー開発ノウハウー更新機能紹介
- (一)、更新パネルを作成
-
ソース:UserInfoPanelクラス FormPanel formPanel = new FormPanel(); formPanel.setFrame(true); formPanel.setTitle(""); formPanel.setWidth(250); formPanel.setLabelWidth(75); formPanel.setUrl("www.yahoo.co.jp"); (続きを読む...)
登録機能紹介(NEW)
株式会社ケネスー開発ノウハウー登録機能紹介
- (一)、登録パネルを作成
-
ソース:RegisterPanelクラス // 初期化 public RegisterPanel() { detailsFS = new FieldSet("登録"); detailsFS.setCollapsible(true); detailsFS.setAutoHeight(true); detailsFS.setCollapsed(true); (続きを読む...)
ログイン機能紹介(NEW)
- (一)、ログインパネルを作成
- (二)、ユーザーがログイン
-
1、ログインユーザー情報確認、データを取得 ソース:LoginPanelクラス:doLogin方法 OneMoreRemote.Util.getInstance().authenticate(_loginTextBox.getText(), _passwordTextBox.getText(), new DefaultCallback(){ public void onSuccess(Object result) { User user = (User) result; ApplicationParameters.getInstance().setUser(user); //掲示板情報取得 START OneMoreRemote.Util.getInstance().loadNoticeList(new DefaultCallback(){ public void onSuccess(Object result) { List noticeList = (List) result; ApplicationParameters.getInstance().setNoticeList(noticeList); //予定情報を取得 (続きを読む...)
ログインを設定(NEW)
株式会社ケネスー開発ノウハウーログインを設定
- 1.使用データベース:spring,使用表:user
- 2.設置Hibernate DAO:
-
<?xml version="1.0" encoding="UTF-8"?> < beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> < !-- User DAO --> < bean id="userDAO"> < property name="sessionFactory" ref="sessionFactory" /> </bean> < bean id="mailSetDAO"> < property name="sessionFactory" ref="sessionFactory" /> </bean> < bean id="noticeDAO"> < property name="sessionFactory" ref="sessionFactory" /> </bean> < bean id="eventdetailDAO"> < property name="sessionFactory" ref="sessionFactory" /> </bean> < bean id="receiveMailDAO"> < property name="sessionFactory" ref="sessionFactory" /> </bean> < bean id="sendMailDAO"> < property name="sessionFactory" ref="sessionFactory" /> </bean> </beans>
- 3.設置カレンダー表user対応クラスファイルと対応のXMLファイル
- ユーザー表対応のXMLファイル
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd> <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools --> < hibernate-mapping> < class name="jp.co.kenes.domain.User" table="user"> < id name="id" type="integer"> < column name="ID" /> </id> < property name="version" type="integer"> < column name="version" /> </property> < property name="login" type="string"> < column name="LOGIN" length="45" not-null="true" /> </property> < property name="firstName" type="string"> < column name="FIRST_NAME" length="45" not-null="true" /> </property> < property name="lastName" type="string"> < column name="LAST_NAME" length="45" not-null="true" /> </property> < property name="password" type="string"> < column name="PASSWORD" length="45" /> </property> </class> </hibernate-mapping> - ユーザー表対応クラス
-
package jp.co.kenes.server.dao.hibernate; import java.util.List; import jp.co.kenes.domain.User; import jp.co.kenes.server.dao.IUserDAO; import org.hibernate.Query; import org.hibernate.SessionFactory; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; /** * DAO for message beans. * This implementation use HQL to work seamlessly with all implementation of the Message domain class * (Java 1.4 _ stateful or stateless _ and Java5) * @author bruno.marchesson * */ public class UserDAO implements IUserDAO { //---- // Attributes //---- /** * The Hibernate session factory */ private SessionFactory _sessionFactory; //---- // Properties //---- /** * @return the Hibernate session factory */ public SessionFactory getSessionFactory() { return _sessionFactory; } /** * Sets the associated Hibernate session facgtory * @param factory */ public void setSessionFactory(SessionFactory factory) { _sessionFactory = factory; } //------------------------------------------------------------------------- // // Public interface // //------------------------------------------------------------------------- /** * Load the user with the argument ID */ @Transactional(propagation=Propagation.SUPPORTS) public User loadUser(Integer id) { // Create query // Query query = _sessionFactory.getCurrentSession().createQuery("from User user where user.id=:id"); query.setInteger("id", id); // Execute query // return (User) query.uniqueResult(); } /** * Load the user with the argument login */ @Transactional(propagation=Propagation.SUPPORTS) public User searchUserAndMessagesByLogin(String login) { // Create query // StringBuffer hqlQuery = new StringBuffer(); hqlQuery.append("from User user"); hqlQuery.append(" where user.login=:login"); // Fill query // Query query = _sessionFactory.getCurrentSession().createQuery(hqlQuery.toString()); query.setString("login", login); // Execute query // return (User) query.uniqueResult(); } /** * Load all the users */ @SuppressWarnings("unchecked") @Transactional(propagation=Propagation.SUPPORTS) public List loadAll() { // Create query // Query query = _sessionFactory.getCurrentSession().createQuery("from User user"); // Execute query // return (List) query.list(); } /** * Count all the users */ @Transactional(propagation=Propagation.SUPPORTS) public int countAll() { // Create query // Query query = _sessionFactory.getCurrentSession().createQuery("select count(*) from User user"); // Execute query // return ((Long) query.uniqueResult()).intValue(); } /** * Save the argument user * @param user the user to save or create */ @Transactional(propagation=Propagation.REQUIRED) public void saveUser(User user) { _sessionFactory.getCurrentSession().saveOrUpdate(user); } //削除処理 @Transactional(propagation=Propagation.REQUIRED) public void deleteUser(User user) { _sessionFactory.getCurrentSession().delete(user); } }
パネルの説明(NEW)
株式会社ケネスー開発ノウハウーパネルの説明
- 1、AbsolutePanel
-
パッケージ:com.google.gwt.user.client.ui AbsolutePanelクラス:絶対パネルにパネルを何個でも追加できる、追加したパネルには位置が固定されている。 絶対パネルサイズは変更がない。 例: AbsolutePanel panel = new AbsolutePanel(); Label label = new Label("ラベル"); panel.add(label, 50, 50); - 2、Panel
-
パッケージ:com.gwtext.client.widgets Panelクラス:すべてのパネルの拡張 基本的な使い方を提供、Panel上で多数のパネルが追加できる。 例: Panel panel = new Panel(); AbsolutePanel absolutePanel = new AbsolutePanel(); panel.add(panel); - 3、FocusPanel
-
パッケージ:com.google.gwt.user.client.ui FocusPanelクラス:フォーカスを取得。 マウスとキーのイベントを取得 例: FocusPanel focusPanel = new FocusPanel(); final Label label = new Label("山下"); panel.add(label); focusPanel.addClickListener(new ClickListener(){ public void onClick(Widget widget){ label.setText("佐藤"); } }); - 4、Grid
-
パッケージ:com.google.gwt.user.client.ui Gridクラス:多数の行列を表示されのグリッド、文字の追加、HTMLとコントロールができる。 例: Grid grid = new Grid(5, 5); Label label = new Label("ラベル"); for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ grid.setWidget(i,j,label); } } - 5、PopupPanel
-
パッケージ:com.google.gwt.user.client.ui PopupPanelクラス:パネルポップアップ,自動隠す(ユーザはほかの場所をクリックすると、ポップアップ自動隠す) 例: Panel panel = new Panel(); Button button = new Button("ポップ"); panel.add(button); button.addListener(new ButtonListenerAdapter(){ public void onClick(Button button, EventObject e) { PopupPanel popupPanel = new PopupPanel(); Panel panel1 = new Panel(); Label label = new Label("テスト"); panel1.add(label); popupPanel.setwidget(panel1); popupPanel.setPopupPosition(100,100); } }); - 6、HTML
-
パッケージ:com.google.gwt.user.client.ui HTMLクラス:htmlが追加できる。 cssを設定:.gwt-HTML { } 例: HTML html = new HTML("テスト"); Panel panel = new Panel(); panel.add(html); - 7、TabPanel
-
パッケージ:com.google.gwt.user.client.ui TabPanelクラス:切り替えタブ。タイトルをクリックするとパネル画面が表示され。 好きなデザインが自由作成 例: TabPanel panel = new TabPanel(); FlowPanel flowpanel; flowpanel = new FlowPanel(); flowpanel.add(new HTML(Framework.lorem(100, ParagraphStyle.HTML_DOUBLE))); panel.add(flowpanel, "一"); flowpanel = new FlowPanel(); flowpanel.add(new HTML(Framework.lorem(100, ParagraphStyle.HTML_DOUBLE))); panel.add(flowpanel, "二"); flowpanel = new FlowPanel(); flowpanel.add(new HTML(Framework.lorem(100, ParagraphStyle.HTML_DOUBLE))); panel.add(flowpanel, "三"); panel.selectTab(0);
- 8、FormPanel
-
パッケージ:com.google.gwt.user.client.ui FormPanelクラス:Htmlとのフォームが同じ、データをデータベースへ。 例: final FormPanel form = new FormPanel(); remotePagePanel.add(form, "デモ"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); form.setAction("php/rxf_logon.php"); VerticalPanel holder = new VerticalPanel(); form.add(holder); holder.add(new Label("ユーザーID")); TextBox userid = new TextBox(); userid.setName("userid"); holder.add(userid); holder.add(new Label("パスワード")); PasswordTextBox passwd = new PasswordTextBox(); passwd.setName("passwd"); holder.add(passwd); holder.add(new Button("提出", new ClickListener() { public void onClick(Widget sender) { form.submit(); } })); form.addFormHandler(new FormHandler() { public void onSubmit(FormSubmitEvent event) { } public void onSubmitComplete(FormSubmitCompleteEvent event) { if(event.getResults() == null) Window.alert("失敗"); else Window.alert("成功"); } } ); - 9、DisclosurePanel
-
パッケージ:com.google.gwt.user.client.ui DisclosurePanelクラス:タイトルとコンテンツの組み合わせパネルで、ユーザはタイトルをクリックする時、コンテンツが表示され。 例: Label label = new Label("テスト"); DisclosurePanel advancedDisclosure = new DisclosurePanel("クリック"); advancedDisclosure.setAnimationEnabled(true); advancedDisclosure.setContent(label);
Google Web Toolkit 参照
| Google Web Toolkit 参照 | |
| Google Web Toolkit で Async にデータを受け取るところのメモ。 結構苦労したので。 ここの通り、 として、、Eclipse で ここの通り、 sample/client の下に SampleService.java を作って、 import com.google.gwt.user.client.rpc.RemoteService; public interface SampleService extends RemoteService{ sample の下に server フォルダを作って、SampleServiceImpl.java を作って import com.google.gwt.user.server.rpc.RemoteServiceServlet; public class SampleServiceImpl extends RemoteServiceServlet implements sample/client の下に SampleServiceAsync.java を作って、 import com.google.gwt.user.client.rpc.RemoteService; public interface SampleServiceAsync{ DemoClient.java の中で DemoClient.gwt.xml に を追加する これで、Eclipse 上でテストして問題なければOK あと、Tomcat に Deploy するには、 DemoClient-compile.cmd sampleService sampleService を書く webapps/DemoClient/WEB-INF/classes の下に bin フォルダの中の com フォルダ以下を全部コピーして、 webapps/DemoClient/WEB-INF/classes/com/google の下に、gwt-user.jar を展開した com/google の中身を全部コピーして、 これで、tomcat を再起動して、うまく使えればOK! |
Google Web Toolkit 参照 (NEW)
株式会社ケネスーGoogle Web Toolkit 参照
Google Web Toolkit 参照
Google Web Toolkit で Async にデータを受け取るところのメモ。
結構苦労したので。
ここの通り、
projectCreator -eclipse MyProject
applicationCreator -eclipse MyProject com.sample.myProject.client.DemoClient
として、、Eclipse で
File → Import → Existing Projects into Workspace
としてインポートする。
ここの通り、 sample/client の下に SampleService.java を作って、
package com.sample.myProject.client;
import com.google.gwt.user.client.rpc.RemoteService;
public interface SampleService extends RemoteService{
String getString();
}
のように書く。
sample の下に server フォルダを作って、SampleServiceImpl.java を作って
package com.sample.myProject.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.sample.myProject.client.SampleService;
public class SampleServiceImpl extends RemoteServiceServlet implements
SampleService {
public String getString() {
return "This string is from server";
}
}
のように書く。
sample/client の下に SampleServiceAsync.java を作って、
package com.sample.myProject.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface SampleServiceAsync{
void getString(AsyncCallback callback);
}
のように書く。
DemoClient.java の中で
import com.sample.myProject.client.SampleServiceAsync;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
を書いて、
final SampleServiceAsync sampleService = (SampleServiceAsync)
GWT.create(SampleService.class);を書いて、
ServiceDefTarget target = (ServiceDefTarget)sampleService;
String staticResponseURL = GWT.getModuleBaseURL();
staticResponseURL += "/getStringService";
target.setServiceEntryPoint(staticResponseURL);
と初期化して、
非同期にデータを受け取りたいところで、(なんかのアクション(onKeyUp とかで))
sampleService.getString(new AsyncCallback() {
public void onSuccess(Object result) {
Label.setText((String) result);
}
public void onFailure(Throwable caught) {
Label.setText(caught.getMessage());
}
});
と書く。
DemoClient.gwt.xml に
を追加する
これで、Eclipse 上でテストして問題なければOK
あと、Tomcat に Deploy するには、
(Deployment と書いた方がヒット率上がるか?カタカナだと、ディプロイとか、デプロイとかか?)
DemoClient-compile.cmd
でコンパイルして javascript に変換して、
(もし、一度でもコンパイルしてたら www フォルダを全部消してから、実行しないとダメ。上書きしてくれない。ので、かなりハマった。^^;)
webapps の中に MyApplication フォルダを作って、
webapps/DemoClient の中に www フォルダの中のファイルを DemoClientフォルダにコピーして、
webapps/DemoClient/WEB-INF の下に web.xml を作って
sampleService
com.sample.myProject.server.SampleServiceImpl
sampleService
/getStringService
を書く
webapps/DemoClient/WEB-INF/classes の下に bin フォルダの中の com フォルダ以下を全部コピーして、
(classes/com.sample.myProject.server だけあればいい気がするけど)
webapps/DemoClient/WEB-INF/classes/com/google の下に、gwt-user.jar を展開した com/google の中身を全部コピーして、
(ホントは、ここに書かれてるとおり、webapps/DemoClient/WEB-INF/lib の中に、gwt-user.jar から
javax フォルダを消して再圧縮した gwt-user.jar を置けばいいみたいなのだけど。)
これで、tomcat を再起動して、うまく使えればOK!
GWT紹介
| GWT紹介 | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
Ext GWT 1.0登場、GWT2とは別の注目ライブラリ
| Ext GWT 1.0登場、GWT2とは別の注目ライブラリ |
| The Ext teamは7日(米国時間)、Ext GWTの最新版となる「Ext GWT 1.0」を公開した。Ext GWTはGWT向けに開発されたRIA開発のためのJavaライブラリ。高性能でカスタム可能なUIを提供しているほか、CSSに対応したテーマ機能の提供、外部ライブラリに依存することなくそれだけで使えるGWTソリューション、RPC/JSON/XMLのサポート、Java Genericや列挙型・可変引数などJava 1.5機能に対応といった特徴がある。ライセンスはオープンソースライセンスと商用ライセンスの両方が用意されている。
Ext GWT 1.0 – Ext JSサイトより抜粋 Ext GWT 1.0が対応しているのはGWT 1.5 RC1。気をつけるべきはGWT-Extとは違うということだろう。名前がよく似たものにGWT-Extがあり、こちらはGWTとExt JSをベースにして開発されたもので、配布ライセンスもExt GWTとは異なっている。どちらも開発は活発に続けられており、どっちに注目すべきかは難しいところだ。状況に応じて検討していく必要がありそうだ。 http://journal.mycom.co.jp/news/2008/07/09/029/index.html 参照 |
GWTとは
| GWTとは | |
| Google Web Toolkit(GWT)は、Javaを使ってウェブ用Ajaxアプリケーションを開発できるオープンソースのJavaソフトウェア開発フレームワークである。Apache License 2.0 でライセンスされている[1]。
GWT は再利用可能で効率的なAjaxソリューションであることを強調しており、すなわち非同期RPC、履歴管理、ブックマーク、ブラウザ間の移植性の良さなどを特徴とする。 GWTは単にインタフェースまわりの開発にとどまらず、JavaScript を使った任意の高機能クライアントを構築できる。GWT開発者は、GWTは単なるライブラリではなく、新たなAjaxライブラリの実装というだけではないことを強調する。そのオープンエンドの哲学は徹底しており、多くのアーキテクチャ上の決定がGWTを利用する開発者に委ねられている。GWTの目的を記した文書を見ると、GWTの役割と開発者の役割をわかりやすく解説している。例えば、履歴トークンはGWTが管理するが、履歴トークンがアプリケーションの状態とどう対応するかは開発者に委ねられている。 GWTアプリケーションは以下の2つのモードで動作する。 ホステッドモード: JavaのバイトコードとしてJava仮想マシン (JVM) 上で動作する。一般に開発途中で利用するモードで、コードのホットスワップやデバッグをサポートしている。 http://ja.wikipedia.org/wiki/Google_Web_Toolkit参照 |

