2014-06-12 2 views
0

Tapestry5를 사용하여 웹 응용 프로그램을 개발 중입니다. 내 응용 프로그램에서는 다국어 개념을 통합하고자합니다. 나는 app_it.properties와 app_fr.properties라는 두 개의 속성 파일을 가지고있다. 그러나 가치가 없으면 열쇠 만 있습니다.태피스 트리 5의 다국어 개념

app_it.properties

aboutus= 
termsandcondns= 
privacy= 

app_fr.properties

aboutus= 
termsandcondns= 
privacy= 

은 여기 런타임에 키 값을 설정합니다. 해당 키의 값은 국가 코드를 기반으로 데이터베이스에서 가져옵니다. 설정할 수 있습니까?

도와주세요. 당신이 완전히 프로퍼티 파일 기반 기능을 제거하려면

답변

1

이 태피스트리, 모든 서비스는이 경우 tapestry IOC

를 통해 재정의, 당신은 당신 것, ComponentMessagesSource

의 사용자 정의, 데이터베이스 기반 구현을 제공 할 것입니다 override the ComponentMessagesSource. 그렇지 않은 경우 decorate 기존 서비스를 사용하고 속성 파일과 데이터베이스 값의 조합을 사용하십시오.

0

자신 만의 org.apache.tapestry5.ioc.Resource 구현을 제공 할 수 있습니다. 이로 인해 Tapestry의 내부 API를 사용할 필요가 없습니다.

@Contribute(ComponentMessagesSource.class) 
public static void provideMessages(OrderedConfiguration<Resource> configuration) { 
    configuration.add("DBMessages", new Resource() { 
     // implement interface methods 
    }); 
} 

당신은 물론, 자원 인스턴스가 데이터베이스 연결 또는 당신이 무엇에서 메시지를 얻으려면와 자원을 제공하는 별도의 서비스 내에서 구성 할 수 있습니다. 까다로운 점은 파일/디렉토리 구조를 위해 명확하게 설계된 메소드를 구현하는 방법이 될 수 있습니다.

/** 
* Returns a Resource based on a relative path, relative to the folder containing the resource. Understands the "." 
* (current folder) and ".." (parent folder) conventions, and treats multiple sequential slashes as a single slash. 
* <p/> 
* Virtual resources (resources fabricated at runtime) return themselves. 
*/ 
Resource forFile(String relativePath); 

또는

/** 
* Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the 
* Resource. 
*/ 
String getFolder(); 

글쎄, 난 당신이 태피스트리의 소스 코드를 들여다을하는 방법과 기존 자원의 구현 작업을보고해야 할 것 같아요.

관련 문제