Question

I am using PrimeFaces 3.2 and want to export a dynamically created table as an .xls file. When i click on export, nothing seems to be happening.

Export Code

<h:commandLink id="Download_Excel_Format" ajax="false">  
<p:graphicImage value="/resources/Excel_Icon.jpg" height="25" width="25" />
<p:dataExporter type="xls" target="dataTable" fileName="SomeFileName"/>  
</h:commandLink>

dataTable

<p:dataTable id="dataTable" var="c" value="#{databaseSearch.customerList}"  
                                     paginator="true" rows="10" paginatorAlwaysVisible="false"
                                     paginatorTemplate="Page {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}  Rows per page {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15,30">  

                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Machine" />  
                                </f:facet>  
                                <p:commandButton id="basic" value="#{c.machine}" action="#{updateEntry.setMachine(c.machine)}" oncomplete="dlg1.show();" styleClass="ui-Machinebutton" update=":Update_Entry"/>
                                <p:tooltip for="basic" value="Update/Delete Database Entry" showEffect="fade" hideEffect="fade" />

                            </p:column>  

                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Company" />  
                                </f:facet>  
                                <h:outputText value="#{c.company}" />
                            </p:column>  

                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Contact" />  
                                </f:facet>  
                                <h:outputText value="#{c.contact}" />  
                            </p:column>  

                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Phone" />  
                                </f:facet>  
                                <h:outputText value="#{c.phone}" />  
                            </p:column>  

                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Email" />  
                                </f:facet>  
                               <!-- <h:outputText value="#{c.email}" />-->
                                <h:outputLink value="mailto:#{c.email}?Subject=Baseline Monitor Alert | Machine : #{c.machine}">#{c.email}</h:outputLink>
                            </p:column>  

                        </p:dataTable> 

Both the dataTable and the Export command are within one form, however the dataTable is in a output panel (within the form).

Form

<h:form prependId="false" id="Main_Form">
</h:form>

Output Panel

<p:outputPanel id="panel" autoUpdate="false">
</p:outputPanel>

I even updated to PrimeFaces 3.4.2 to see if the dataExporter would work, but no avail, as far as i remember 3.2 has a bug if the dataTable generates columns dynamically, but that is not the case here right? am i doing something wrong?

dataExporter option looks much simpler, but if there is an alternative which is simple enough i am up for it.

Update

I am using a GlassFish 3.1.2.2 (build 5) & NetBeans 7.2.1, i do not get any errors, just the page refresh's, has a '#' at the end of the URL and stops, no errors means that i am not lacking any dependencies either... so i am lost here ...

Was it helpful?

Solution

Ok, i found the answer ! Tricky one though ... i had a commandButton with the ID=submit...renamed it and that did the trick !

<p:commandButton id="xsubmit" icon="ui-icon-search" title="Search Database" update="panel" actionListener="#{databaseSearch.customerList}" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top