datatable rowSelectListener does not fire the event

UI Components for JSF
Post Reply
byrdiablo
Posts: 1
Joined: 18 Jan 2011, 07:08

18 Jan 2011, 07:25

Hi.. I tried to navigate to another page by selecting (double-click) a row in the datatable. I followed the sample in the ShowCases http://www.primefaces.org/showcase/ui/d ... nstant.jsf, but somehow, it does not invoke the method for rowSelectListener. However, the row is indicated as selected when I double clicked on the row.

JSF 2.0
PrimeFaces-2.2.RC2

Code: Select all

<?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:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        
        <h:form id="form1">
            <p:panel header="#{msgs.standardName}">
                <h:panelGrid columns="2">
                    <h:outputLabel value="id" />
                    <h:inputText value="#{stdAuditMastController.record.id}" />

                    ....

                    <p:commandButton value="#{msgs.reset}" type="reset" />
                    <p:commandButton value="#{msgs.add}" update="stdauditmast_id" action="#{stdAuditMastController.insert}">
                        <p:collector value="#{stdAuditMastController.record}" addTo="#{stdAuditMastController.records}" />
                    </p:commandButton>
                </h:panelGrid>
            </p:panel>
            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="../#{msgs.ajaxLoading}" />
		</f:facet>

		<f:facet name="complete">
                    <h:outputText value="" />
		</f:facet>
            </p:ajaxStatus>

            <p:outputPanel id="stdauditmast_id">
                <p:dataTable value="#{stdAuditMastController.records}" var="record" paginator="true" rows="10"
                             selection="#{stdAuditMastController.selectedRow}"
                             rowSelectListener="#{stdAuditMastController.onRowSelectNavigate}"
                             dblClickSelect="true">  
                    <f:facet name="header">
                        In-Cell Editing
                    </f:facet>
                    <p:column headerText="ID">

                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{record.id}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{record.id}" style="width: 100px" />
                            </f:facet>

                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="#{msgs.auditCode}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{record.auditCode}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{record.auditCode}" style="width: 100px" />
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                     ...

                    <p:column headerText="Options">
                        <p:rowEditor />
                    </p:column>
                </p:dataTable>

            </p:outputPanel>
        </h:form>

    </h:body>
</html>

Code: Select all


import com.fellows.dot.hibernate.dao.tat_plugged.Stdauditmast;
import com.fellows.dot.hibernate.impl.tat_plugged.StdauditmastImpl;
import java.io.Serializable;
import java.util.ArrayList;

import java.util.List;
import javax.faces.bean.ViewScoped;

import javax.faces.context.FacesContext;

import org.primefaces.event.RowEditEvent;
import org.primefaces.event.SelectEvent;


/**
 *
 * @author Administrator
 */
@ViewScoped
public class StdAuditMastController implements Serializable {

    private StdauditmastImpl stdAuditmastImpl;

    private Stdauditmast selectedRow;

    private Stdauditmast record = new Stdauditmast();
    private List<Stdauditmast> records = new ArrayList<Stdauditmast>();



    /** Creates a new instance of StdAuditMastController */
    public StdAuditMastController() {
        initialize();
        selectedRow = new Stdauditmast();
    }

    private void initialize() {
        record = new Stdauditmast();
        stdAuditmastImpl = new StdauditmastImpl();
        records = stdAuditmastImpl.getAllRecord();
    }
    
    public Stdauditmast getRecord() {
        return record;
    }

    public void setRecord(Stdauditmast record) {
        this.record = record;
    }

    public List<Stdauditmast> getRecords() {
        return records;
    }

    public void setRecords(List<Stdauditmast> records) {
        this.records = records;
    }

    public Stdauditmast getSelectedRow() {
        return selectedRow;
    }

    public void setSelectedRow(Stdauditmast selectedRow) {
        this.selectedRow = selectedRow;
    }

    public String insert() {
        System.out.println("StdAuditMast.insert()");
        return null;
    }

    public String remove() {
        System.out.println("StdAuditMast.remove()");
        return null;
    }

    //DataTable Event Handlers
    public String onRowSelectNavigate(SelectEvent event) {
        System.out.println("onrowSelectNavigate");
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedStdauditmast", event.getObject());
        return "stdlist?faces-redirect=true";
    }



SoleilNoir
Posts: 1
Joined: 22 Jan 2011, 13:43

22 Jan 2011, 13:47

HI, i have the same problem as you! but my compiler says that he doesn find the methode!? do you might know what the problem is??

JSF 2.0 Morjarra 2.0.3-FCs
PrimeFaces-2.2.RC2

Code: Select all

	<h:form>

	   <p:dataTable value="#{searchRoute.routeList}" var="item"
	   	 		selection="#{searchRoute.selectedRoute}" rows="10" 
	   	 		rowSelectListener="#{searchRoute.onRowSelection}"
	   	 		dblClickSelect="true"
	   	 		selectionMode="single" >
				   <p:column>
                  <!--     <f:facet name="">
                        </f:facet>
                        <h:selectManyCheckbox>
                        	<f:selectItem itemValue="#{item.id}"/>
                        </h:selectManyCheckbox>
                       -->  
                        	

                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Name"/>
                        </f:facet>
                        <h:outputText value="#{item.name}"/>
                    </p:column>
	         
                    <!-- Length number -->
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Length"/>
                        </f:facet>
                        <h:outputText value="#{item.length}"/>
                    </p:column>
	       </p:dataTable>
</h:form>

Code: Select all

	
public void onRowSelection(SelectEvent event) {  
	      FacesMessage msg = new FacesMessage("Route Selected", ((Route) event.getObject()).getName());  
	      this.selectedRoute = (Route) event.getObject();
	      FacesContext.getCurrentInstance().addMessage(null, msg);  
	} 
	

wanted.alive
Posts: 10
Joined: 17 Dec 2010, 19:21

09 Jun 2011, 04:07

Hey guys... I don't know if you got solved this problem, but I think that it's about the p:cellEditor.
If you remove it, at least for me, it backs to work.

But do you have another fix for this???

Thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests