Strange things happends to my datatable
chris__ Jun 7, 2006 6:30 AMf got an datatable:
When i visit the page, everything works fine. I get 2 different board links with 2 different ids.
----------------
ID NAME Commands
10 neuboard
11 testboard
------------------
after clicking on: the testboard link i get:
------------------------------
ID NAME Commands
11 testboard
11 testboard
------------------------------
I checked the datamodel. This is correct. even on the 2. call. So JSF mixed it up. The c:forEach output displays both times the correct data (neuboard,testboard).
i really dont understand what i am doing wrong.
Used MyFaces 1.1.3
thanks for help.
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
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/jstl/core">
<jsp:text>
<ui:composition template="/templates/emptyone.jsp">
<ui:define name="content">
<h:form>
<h:dataTable id="table1" border="1" var="board" value="#{boardList}" >
<h:column id="col1">
<f:facet name="header">
<h:outputText value="ID" />
</f:facet>
<h:outputText value="#{board.id}" />
</h:column>
<h:column id="col2">
<f:facet name="header">
<h:outputText value="NAME" />
</f:facet>
<h:commandLink value="#{board.name}" action="#{boardManager.select}"/>
</h:column>
<h:column id="col3" >
<f:facet name="header">
<h:outputText value="Commands" />
</f:facet>
<h:commandButton value="Edit" action="#{boardManager.edit}" />
<h:commandButton value="Delete" action="#{boardManager.delete}" />
</h:column>
</h:dataTable>
<c:forEach items="#{boardManager.boards}" var="b" >
#{b.name} <br />
</c:forEach>
</h:form>
</ui:define>
</ui:composition>
</jsp:text>
</jsp:root>
@Stateful
@Scope(ScopeType.SESSION)
@Name("boardManager")
public class BoardManagerBean implements BoardManagerLocal,Serializable {
@EJB BoardFacadeRemote facadeRemote;
@DataModelSelection("boardList")
@Out(required=false)
private Board board;
@DataModel(scope=ScopeType.PAGE)
List<Board> boardList;
@DataModel
List<Category> categories;
public String saveBoard() {
for(Board b : boardList) {
System.out.println(b.getName());
}
return "success";
}
public void select() {
}
@Factory("boardList")
public void findBoards() {
boardList = facadeRemote.getAllBoards();
}
@Factory("categories")
public void findCateogries() {
if(board==null) {
categories= new ArrayList<Category>();
} else {
categories = board.getSubCategories();
}
}
public void delete() {
// TODO Auto-generated method stub
}
public void edit() {
// TODO Auto-generated method stub
}
public List<Board> getBoards() {
return boardList;
}
@Remove @Destroy
public void destroy() {}
}