xhtml의 작동 방식에 대해 묻고 싶습니다.xhtml + jsf 컨트롤러 클래스에서 값 가져 오기
이 내 tablero.xhtml 파일입니다
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="Dak's Hangman"></h:outputText>
</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:head id="demo" >Opportunities: </h:head>
<h:outputText value="#{partidaController.getRemainingOp()}"/>
<br/>
<h:outputText value="#{partidaController.getNombreJugador()}"/>
<br/>
<c:forEach var="x" items="#{partidaController.getLetrasColocadas()}" >
<h:inputText disabled="true" size="1" value="${x}"/>
</c:forEach>
<br/>
<h:panelGrid>
<h:form>
<p:commandButton id="b1" style="height: 30px; width: 30px;" value="a" action="#{turnoController.createTurno('a')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b2" style="height: 30px; width: 30px;" value="b" action="#{turnoController.createTurno('b')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b3" style="height: 30px; width: 30px;" value="c" action="#{turnoController.createTurno('c')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b4" style="height: 30px; width: 30px;" value="d" action="#{turnoController.createTurno('d')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b5" style="height: 30px; width: 30px;" value="e" action="#{turnoController.createTurno('e')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b6" style="height: 30px; width: 30px;" value="f" action="#{turnoController.createTurno('f')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b7" style="height: 30px; width: 30px;" value="g" action="#{turnoController.createTurno('g')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b8" style="height: 30px; width: 30px;" value="h" action="#{turnoController.createTurno('h')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b9" style="height: 30px; width: 30px;" value="i" action="#{turnoController.createTurno('i')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b10" style="height: 30px; width: 30px;" value="j" action="#{turnoController.createTurno('j')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b11" style="height: 30px; width: 30px;" value="k" action="#{turnoController.createTurno('k')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b12" style="height: 30px; width: 30px;" value="l" action="#{turnoController.createTurno('l')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b13" style="height: 30px; width: 30px;" value="m" action="#{turnoController.createTurno('m')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b14" style="height: 30px; width: 30px;" value="n" action="#{turnoController.createTurno('n')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b15" style="height: 30px; width: 30px;" value="o" action="#{turnoController.createTurno('o')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b16" style="height: 30px; width: 30px;" value="p" action="#{turnoController.createTurno('p')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b17" style="height: 30px; width: 30px;" value="q" action="#{turnoController.createTurno('q')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b18" style="height: 30px; width: 30px;" value="r" action="#{turnoController.createTurno('r')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b19" style="height: 30px; width: 30px;" value="s" action="#{turnoController.createTurno('s')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b20" style="height: 30px; width: 30px;" value="t" action="#{turnoController.createTurno('t')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b21" style="height: 30px; width: 30px;" value="u" action="#{turnoController.createTurno('u')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b22" style="height: 30px; width: 30px;" value="v" action="#{turnoController.createTurno('v')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b23" style="height: 30px; width: 30px;" value="w" action="#{turnoController.createTurno('w')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b24" style="height: 30px; width: 30px;" value="x" action="#{turnoController.createTurno('x')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b25" style="height: 30px; width: 30px;" value="y" action="#{turnoController.createTurno('y')}" onclick="document.getElementById(this.id).disabled=true;"/>
<p:commandButton id="b26" style="height: 30px; width: 30px;" value="z" action="#{turnoController.createTurno('z')}" onclick="document.getElementById(this.id).disabled=true;"/>
<br />
</h:form>
<h:graphicImage value="../resources/images/hangman.jpg" width="480" height="400" />
<h:link outcome="/index" value="#{bundle.CreateJugadorIndexLink}"/>
</h:panelGrid>
</ui:define>
</ui:composition>
</html>
이 내가 내가 buttonCommand 클릭 할 때마다에게 전화 빈입니다 :
public String createTurno(String s) {
try {
Map<String, Object> sesionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
Integer id = (Integer) sesionMap.get("id_partida");
Partida p = new Partida();
p.setIdPartida(id);
current= new Turno();
current.setIdPartida(p);
current.setLetraTurno(s);
ejbFacade.create(current);
return "tablero";
} catch (Exception e) {
JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
return null;
}
}
를이 내가에 통화 할 방법
public List getLetrasColocadas()
{
String lc = getFacade().letrasColocadasById(current.getIdPartida());
ArrayList<String> lista = new ArrayList<String>();
int i;
for (i=0; i<lc.length(); i++){
String h = "" + lc.charAt(i) + "";
lista.add(h);
}
return lista;
}
partidaController.getLetrasColocadas()가 잘 작동 ... 항목을 업데이트 (나는 그것을 디버깅 한 그리고 그것은 내가 원하는 것을 해). 문제는 inputText 값이 일단 표시되면,이 xhtml 파일의 이름을 가진 문자열을 반환하는 bean을 호출하는 명령 버튼을 클릭하면 다시 업데이트되지 않는다는 것입니다. 항상 동일하게 유지됩니다.
내가 xhtml에 대해 알아야 할 마술 ???
우리가 도울 수 있도록 모델/관리 빈을 보여줘야합니다. – skuntsel