문자열 목록을 보유하고있는 빈을 가진 JSF 2.0 애플리케이션이 있습니다.JSF : 목록에 문자열 추가
문자열을 <h:inputText>/>
에서 내 목록에 추가하고 내 목록을 표시하고 싶습니다.
다음 코드는 내 목록에 참조를 넣었습니다. 그래서 내 목록의 모든 요소는 마지막 입력으로 설정됩니다. 여기
@ManagedBean
@ApplicationScoped
public class Bean {
private String name;
private ArrayList<String> test = new ArrayList<String>();
public Bean() {
}
public Bean(String name) {
this.name = name;
}
public String addtoList(String _name){
test.add(_name);
return "./index.xhtml";
}
/***************GETTER/SETTER/HASHCODE/EQUALS**************************/
...
}
내 index.xhtml의 일부 :
<h:inputText id="name"
value="#{bean.name}"
required="true">
</h:inputText>
<h:commandButton value="Post"
action="#{bean.addtoList(name)}"/>
<br/>
<h:dataTable var="bean"
value="#{bean.test}">
<h:column>
<h:outputText value="#{bean.name}"/>
</h:column>
</h:dataTable>
'공공 무효 addtoList (문자열 _name) { 테스트의 또 다른 이름이어야이라고했다 .add (_name); return "./index.xhtml"; }'컴파일해서는 안됩니다 ... 예외는 무엇입니까? –