0

I am working with jsf 2.0 et Primefaces. i have a selectOneMenu that have dynamic values of datas that correspond to the user connected. I want that when i choose a data and click on the button view the list of emails related to the data selected will be shown on the dataTable.

<p:panel>
    <p:selectOneMenu id="data" value="#{mailMB.database}" styleClass="auto" required="true" effect="fade" >  
        <f:selectItem itemLabel="Select Data" itemValue="" />  
        <f:selectItems value="#{dataMB.datas}" var="data" itemLabel="#{data.keyword}" itemValue="#{data.keyword}"/>                         
    </p:selectOneMenu>                           
    <p:commandButton value="View" action="#{mailMB.grabemails()}" ajax="true" update="datas" icon="ui-icon-circle-check" styleClass="ui-priority-primary" />           
</p:panel>
<p:panel id="panelform" header="Emails List"  >
    <p:dataTable value="#{mailMB.emailsByData}" var="item" id="datas"  rowsPerPageTemplate="5,10,15,20,25,30" 
                 paginator="true" rows="10" 
                 selectionMode="single"  filteredValue="#{mailMB.filteredMails}" rowKey="#{item.id}" 
                 selection="#{mailMB.selectedMail}">
        <p:ajax event="rowSelect" update=":form:dataView , :form:confirmDelete, :form:viewButton" listener="#{dataMB.onRowSelect}"/>
        <p:ajax event="rowToggle"  />  
        <p:column style="width:2%" exportable="false">  
            <p:rowToggler />  
        </p:column> 
        <p:column sortBy="#{item.email}" filterBy="#{item.email}">
            <f:facet name="header">
                <h:outputText value="Email"/>
            </f:facet>
            <h:outputText value="#{item.email}"/>
        </p:column>                   
    </p:dataTable>  
</p:panel>

and this is my method in the managed Bean that returns the list of emails by data using the named query:

public List<Email> getEmailsByData() {
    System.out.println("the database" + getDatabase());
    return emailsByData = mailBusinessLocal.mails(getDatabase());
}

public List<Email> grabemails() {
    return emailsByData = mailBusinessLocal.mails(database);
}

when i choose a data and click view nothing happens and the databate return null as it shown on the glassfish log.

Joffrey Hernandez
  • 1,809
  • 3
  • 21
  • 39
junior developper
  • 448
  • 2
  • 19
  • 40
  • See if the update is really going to panelform:datas, try to change the update to @form. Maybe you have to prepend some IDs of the JSF elements you are not showing in your code. Is the AJAX event of the commandButton firing? is it sending the right data? Are your MB methods being called at all? – Mindwin Remember Monica Nov 28 '13 at 17:21

1 Answers1

0

You need to put your <p:selectOneMenu> inside a <h:form>. That's my first guess.

VulfCompressor
  • 1,390
  • 1
  • 11
  • 26