dataModel dataModelSelection first row
yacin00 May 19, 2008 9:51 AMHi, i'm trying to delete a row from a datatable, but always the first row is removed.
registerActionBean:
@Stateful
@Scope(ScopeType.SESSION)
@Name("registration")
public class RegisterActionBean implements RegisterActionLocal {
@In
private EntityManager em;
@In(create=true)
@Out
private Customer customer;
@DataModel(value="conta")
private List<Contact> contacts;
@DataModelSelection("conta")
private Contact selectedContact;
@In(create=true,required=false)
@Out(required = false)
private Contact contact;
@In
private FacesMessages facesMessages;
public void addContact() {
contacts = (contacts==null)? new ArrayList<Contact>():contacts;
contacts.add(contact);
contact = null;
}
public void deleteContact (){
contacts.remove(selectedContact);
}
@Remove
public void destroy() {}
}contact.xhtml
<ui:composition 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:s="http://jboss.com/products/seam/taglib"
xmlns:a="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="#{theme['template.pageClassic']}">
<ui:define name="pageContent">
<h:form>
<rich:panel>
<f:facet name="header">
<h:outputText value="#{messages['Registration']}"/>
</f:facet>
<s:validateAll>
<h:panelGrid columns="3">
<h:outputText value="#{messages['contact']}#{messages['mail']}"/>
<h:inputText label="contact" id="Contact" value="#{contact.email}" required="true" >
<a:support event="onblur"/>
<f:validator validatorId="mailValidator"/>
</h:inputText>
<rich:message for="Contact">
<f:facet name="passedMarker">
<h:graphicImage value="#{theme.img}passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="#{theme.img}error.gif" />
</f:facet>
</rich:message>
</h:panelGrid>
</s:validateAll>
</rich:panel>
<h:dataTable id="contacts" value="#{conta}" var="cont" rendered="#{conta.size > 0}">
<h:column>
<f:facet name="header">#{messages['Mail']}</f:facet>
#{cont.email}
</h:column>
<h:column>
<s:link id="delete" value="#{messages['Delete']}" action="#{registration.deleteContact}"/>
</h:column>
</h:dataTable>
<h:commandButton action="add" value="#{messages['addContact']}"/>
</h:form>
<h:form>
<h:commandButton action="prev" value="#{messages['back']}"/>
<h:commandButton action="next" value="#{messages['continue']}" rendered="#{conta.size > 0}" />
</h:form>
</ui:define>
</ui:composition>