이 블로그 검색

2012년 1월 28일 토요일

@UiField(provided = true)

@UiField(provided = true)
 : UiBinder.createAndBindUi()호출 전에 해당하는 위젯을 new로 생성해서 설정해 놓을 수 있다.
   false로 해 놓으면 UiBinder.createAndBindUi()호출 전에 new로 생성해 놓더라도 반영되지 않는다.
   true로 해 놓고 위젯을 초기화 해 놓지 않으면  UiBinder.createAndBindUi()호출 시 null에러 남

If true, the field must be filled before UiBinder.createAndBindUi is called. If false, UiBinder.createAndBindUi will fill the field, usually by calling com.google.gwt.core.client.GWT.create.

2012년 1월 27일 금요일

requestFactory + Editor에서 get, set

requestFactory + Editor에서
가져온 필드는 setter도 있어야함.

삭제처리할때도 없으니깐 오류 발생함

uibinder

<g:FlowPanel>안에는 위젯만 가능함. div태그 등 html태그는 사용못함

2012년 1월 24일 화요일

requestFactory에서 relation으로 연결된 bean도 함께 가져오기

When querying the server, RequestFactory does not automatically populate relations in the object graph. To do this, use the with() method on a request and specify the related property name as a String:
Request findReq = requestFactory.personRequest().find(personId).with("address");

defaultFetchGroup = "true"

@Persistent(defaultFetchGroup = "true")

자식값도 기본으로 가져오게 하기 위한 설정

If you want to load the child, you can either "touch" it before closing the PersistenceManager (e.g. by calling getContactInfo() in the above example) or explicitly add the child field to the default fetch group so it's retrieved and loaded with the parent:

2012년 1월 17일 화요일

날짜 포맷팅

import com.google.gwt.i18n.shared.DateTimeFormat;
import com.google.gwt.i18n.client.DateTimeFormat;는 
서버단에서 사용할 수 없음

  SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    String s = formatter.format(date);

2012년 1월 16일 월요일

AppPlaceHistoryMapper.java

AppPlaceHistoryMapper에 Tokennizer을 등록해 놓지 않으면 페이지 이동시 url에 #token이
추가되지 않는다. 페이지 이동은 모두 되지만 단지 history에 등록되지 않아 뒤로 버튼이 되지 않을 것이다.

org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed

  • 리스트를 가져온후 곧바로 guestList.size()를 사용했을 경우 나는 오류
  • List<GuestBookTable> detached = pm.detachCopy(guestBookList); if(detached.size()>0)...이렇게 사용
  • 해결책이 이것이 아닌 것 같음 일단 보류...
While learning to use JDO with datanucleus for a project to be run in app engine I tried to implement a method that gets a collection of persistant objects from the database. Trying to test the results I used the size()method on the collection. The result was following exception:

org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed
at org.datanucleus.ObjectManagerImpl.assertIsOpen(ObjectManagerImpl.java:3816)
at org.datanucleus.ObjectManagerImpl.findObjectUsingAID(ObjectManagerImpl.java:2073)
....

The solution is simple. To iterate throw the objects of the collection, they have to be in a detached state, not in persistant state.

So the code in the dao class would look like:
public Collection getAllValueObjects() {
Collection results = Collections.checkedCollection(getJdoTemplate().find(ValueObject.class), ValueObject.class);
 
// To iterate the collection it has to be detached
getPersistenceManager().detachCopyAll(results);
 
return results;
}

http://127.0.0.1:8888/_ah/admin/

gwt관리자 페이지

http://127.0.0.1:8888/_ah/admin/

request factory + jdo

jdo객체의 키
 - relation을 사용할 경우 : 인코딩된 스트링을 써야 함.
                                      (Key타입은 request factory에서 지원하지 않음,
                                        long타입은 jdo에서 reation을 지원하지 않음)
 - relation이 없을 경우 : long타입 또는 인코딩된 스트링을 사용하면 됨
                                   (인코딩되지 않은 스트링도 사용가능 할 것같음)

request factory 주의 사항
  - proxy 객체이 사용가능한 type이 정해 져 있음
  - 서버측에서 구현해야하는 필수 메소드를 구현해야함(getId,getVersion등)

2012년 1월 15일 일요일

in a portable manner

in a portable manner : 이식가능한 방식(프로그래밍에서 유닉스에서 윈동우 등으로)

appengine

Error in meta-data for com.google.gwt.homepage.lovelicense.server.GuestBookAnswerTable.id: Cannot have a java.lang.Long primary key and be a child object (owning field is com.google.gwt.homepage.lovelicense.server.GuestBookTable.answer).

1:n관계등을 표현할 때는 Key or 인코딩된 Key만 사용가능하다.

appengine datastore

an entity : 한 행
kind : 테이블


1:n등의 관계를 사용할려면 키는  Key, or a Key value encoded as a string

2012년 1월 14일 토요일

RequestFactory 오류

 Deferred binding failed for 'com.google.gwt.homepage.lovelicense.shared.LoveLicenseRequestFactory' (did you forget to inherit a required module?)

등의 뜬금없는 오류가 날경우 사용가능하지 않는 타입의 변수를 RequestFactory로 사용하고 있지 않는지 체크

uibinder오류

uibinder 관련 알수 없는 오류가 발생했을때 해결방법
  - 그 소스뿐만아니라 거기서 호출하는 세부 view페이지의 uibinder에 문제가 있어서 그럴 수
    있으므로 일단 그 페이지는 주석처리하고 실행하면 문제가 발생한 페이지의 세부 오류를 볼
    수 있다.

SimplePanel

 SimplePanel can only contain one child widget

serializable versions of Text

I currently have some time before starting with my Master thesis project which will bring me back to Android programming. So to make use of that, I started to develop a project I already wanted to implement a couple of years ago, but due to my Master studies I didn't have the time to. I'll need some beta testers soon, so keep track of my blog here to catch the moment when everything goes online.
What I can reveal so far is that it will be a web application, using Google's GWT and it will be hosted on Google's cloud computing platform App Engine.

Today I was finishing the implementation of the basic CRUD operations, using JDO and App Engine's DataNucleus DataStore. Now the app possibly needs to store large strings surely more than 255 characters. You'd think that shouldn't be a problem, but App Engine's DataStore has some implications one should be aware of. Beside these, there are some well defined core value types, under which there is the restriction that you have to use thecom.google.appengine.api.datastore.Text instead of the String datatype if you plan to store more than 255 character strings. Ok, that shouldn't be a problem for us, should it? Well...not exactly. If you plan to use App Engine together with plain old JSP or whatever view technology that it won't be a problem, but if you use GWT you have to keep in mind that you're implementing a client-server system. The difference: the GWT client lives within the browser. So the data has to be transferred between the two end-points and has to be serializable accordingly.com.google.appengine.api.datastore.Text isn't serializable though. This means youcannot share your POJOs between your GWT client app and server-side code. Now you have different possibilities. Some that come to my mind right now are..
  • using DTOs (Data Transfer Objects) which isn't that comfortable 'cause it causes a lot of boilerplate code
  • writing a serializable version of com.google.appengine.api.datastore.Text data class.
Fortunately a guy has already implemented such a serializable version of Text and provides it for free. I just tried it out and it works seamlessly, without writing a single additional line of code. Here some steps on how to use it (available descriptions on the web are really bad).
  1. Download the necessary jar files from http://www.resmarksystems.com/code/:
    appengine-utils-client-1.0.jar
    appengine-utils-server-1.0.jar
  2. Include the appengine-utils-client-1.0.jar in your build path. Copy the appengine-utils-server-1.0.jar to your WEB-INF/lib folder.
  3. On your GWT module file add the following:

    <inherits name="com.resmarksystems.AppEngineDataTypes"/>
    
  4. Restart your GWT app or compile it and everything should work as expected.
Resmarksystem's version doesn't just provide serializable versions of Text but also for Key,ShortBlobBlobLinkUser.
If you get exceptions like
java.lang.ClassCastException: java.lang.String cannot be cast to com.google.appengine.api.datastore.Text
or
An IncompatibleRemoteServiceException was thrown while processing this call. 
then it's probably because you didn't correctly include the jar files as mentioned in step 2 above.

place

화면에 어떤 상태값이 필요하면,
Place에 변수로 설정해서, presenter에 전달할 정보들을 담으면 된다.

lovelicense 화면 추가 개발 순서

서버단 프로그램 개발

View개발 : view, mobileView, ShellMobile.java
factory 개발 : view 생성 부분
Presenter개발

Place, placeMapper 개발
Activity
ActivityMapper,
App.java








구글 gwt request factory 페이지 참고

2012년 1월 13일 금요일

Tokenizer

 @Prefix("edit")
  public static class Tokenizer implements PlaceTokenizer<TaskPlace> {

    private static final String NO_ID = "create";

    public TaskPlace getPlace(String token) {
      try {
        // Parse the task ID from the URL.
        Long taskId = Long.parseLong(token);
        return new TaskPlace(taskId, null);
      } catch (NumberFormatException e) {
        // If the ID cannot be parsed, assume we are creating a task.
        return TaskPlace.getTaskCreatePlace();
      }
    }

    public String getToken(TaskPlace place) {
      Long taskId = place.getTaskId();
      return (taskId == null) ? NO_ID : taskId.toString();
    }
  }




http://gwt-cloudtasks.appspot.com/#edit:create

prefix는 #뒤에 나오는 edit
getToken은 :뒤에 나오는 create

2012년 1월 3일 화요일

구글코드 이용하기

1. 오픈소스 프로젝트를 생성
2. 이클립스에서 svn연결 : window-show view-other-svn repositoryes
3. svn repositories에서 로컬에 있는 프로젝트 import
    - 폴더를 하나 생성한 후 거기에 프로젝트를 올리면 여러프로젝트를 이용할 수 있음
4. svn repositories에서 해당 url우클릭후 check out으로 프로젝트 내려받기
    - Check out a aproject in the workspace를 선택후 프로젝트 이름 넣고 확인
      (새로운 프로텍트가 생성됨