0
매우 간단한 JSF 2.0 프로젝트가 있습니다.메시지 묶음에 대한 동적 호출?
나는 Mount Rushmore의 그림을 보여주기 위해 index.xhtml 파일을 가지고있다. 이 페이지에서 그림을 클릭하면 "president.xhtml"로 이동합니다. 아무런 문제가 없습니다. 간단한 행동 = "대통령"...
내 문제는 내 메시지 번들 파일 (messages.properties)는 정적 키와 값으로 설정되어 있는지 :
jeffersonPageTitle=Thomas Jefferson
rooseveltPageTitle=Theodore Roosevelt
lincolnPageTitle=Abraham Lincoln
washingtonPageTitle=George Washington
그리고 내에서 전입니다 " .xhtml "파일을 열었을 때 클릭 한 항목에 따라이 제목을 표시하고 싶습니다. 코드에서
<h:form>
<span class="presidentPageTitle">#{msgs['rushmore.president'],PageTitle}</span>
<br />
<h:graphicImage library="images" name="jefferson.jpg" styleClass="leftImage" />
<span class="presidentDiscussion">#{msgs.washingtonDiscussion}</span>
<br />
<h:commandLink action="index" styleClass="backLink">${msgs.indexLinkText}</h:commandLink>
</h:form>
두 번째 라인은 위의 내 문제입니다 - 내 자바 코드에서 Get-방법을 참조하는 방법을 모르겠어요. 코드는 여기에 있습니다 : 어떤 도움이 많이 주시면 감사하겠습니다
@ManagedBean // or @Named
@RequestScoped
public class Rushmore {
private String outcome = null;
private Rectangle washingtonRect = new Rectangle(70, 30, 40, 40);
private Rectangle jeffersonRect = new Rectangle(115, 45, 40, 40);
private Rectangle rooseveltRect = new Rectangle(135, 65, 40, 40);
private Rectangle lincolnRect = new Rectangle(175, 62, 40, 40);
public Rushmore() {}
public void handleMouseClick(ActionEvent e) {
FacesContext context = FacesContext.getCurrentInstance();
String clientId = e.getComponent().getClientId(context);
Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap();
int x = new Integer((String) requestParams.get(clientId + ".x")).intValue();
int y = new Integer((String) requestParams.get(clientId + ".y")).intValue();
outcome = null;
if (washingtonRect.contains(new Point(x, y))) {
outcome = "washington";
}
if (jeffersonRect.contains(new Point(x, y))) {
outcome = "jefferson";
}
if (rooseveltRect.contains(new Point(x, y))) {
outcome = "roosevelt";
}
if (lincolnRect.contains(new Point(x, y))) {
outcome = "lincoln";
}
System.out.println(requestParams.keySet());
}
public String getPresident() {
return outcome;
}
public String navigate() {
if(outcome != null) {
return "president";
}
else return null;
}
}
그것은 내가 president.xhtml 파일에 도달하기 위해 노력하고있어 getPresident 방법입니다 ...
:
다음 예와 다른 점은 무엇입니까? IIRC는 Cay Horstmanns 사례 중 하나입니다. –