我使用的是primefaces 3.5并希望将我的数据表导出为pdf或xml。我没有得到任何错误,但它不起作用。当我点击按钮时,页面只会自我刷新。另外我添加了poi-3.9.jar和itextpdf,但我得到了相同的结果。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title> Cem Yeniçeri</title>
</h:head>
<h:body>
<h:form id="AraçBilgileriPaneli2">
<p:graphicImage id="savronik_image" value="/savronik.png" width="500" height="150"/>
<p:panel id="panel" header="Araç Bilgileri">
<h:panelGrid id="grid" columns="5" style="margin-bottom:10px">
<h:outputLabel value="Araç Seçiniz : "/>
<p:inputText value="#{json_vehicle.arac_id}" />
<p:commandButton value="Seçilen Aracın Bilgilerini Getir"
actionListener="#{json_vehicle.aracBilgileriniYukle(actionEvent)}" update="datatbl"/>
<p:commandButton value="Tüm Araçların Bilgilerini Getir"
actionListener="#{json_vehicle.aracBilgileriniYukle2(actionEvent)}" update="datatbl"/>
<p:commandButton value="Tablo Sil"
actionListener="#{json_vehicle.tabloSil(actionEvent)}" update="datatbl"/>
</h:panelGrid>
<p:messages id="messages3" showDetail="true" autoUpdate="true" closable="true" />
</p:panel>
<br/><br/>
<p:dataTable id ="datatbl" var="v" value="#{json_vehicle.vehicles}">
<p:column headerText="Araç No">
<h:outputText value="#{v.vehicle_id}"/>
</p:column>
<p:column headerText="Araç Adı">
<h:outputText value="#{v.vehicle_name}" />
</p:column>
<p:column headerText="Tarih">
<h:outputText value="#{v.record_date}" />
</p:column>
<p:column headerText="Araç Sahibi">
<h:outputText value="#{v.owner}"/>
</p:column>
<p:column headerText="Araç Tipi">
<h:outputText value="#{v.vehicle_type}" />
</p:column>
<p:column headerText="Tahsis Yeri">
<h:outputText value="#{v.allocated_region}" />
</p:column>
</p:dataTable>
<p:panel header="Export All Data">
<h:commandLink>
<p:graphicImage value="xml.png" />
<p:dataExporter type="xml" target="datatbl" fileName="myxml" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="pdf.png" />
<p:dataExporter type="pdf" target="datatbl" fileName="mypdf" />
</h:commandLink>
</p:panel>
</h:form>
</h:body>
</html>
答案 0 :(得分:2)
尝试使用此依赖项:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
</dependency>
如果您不使用maven,请手动下载。 另外,请确保在p:commandLink中使用'ajax = false'属性。
答案 1 :(得分:0)
请尝试以下代码。你必须ajax = false。我建议使用primefaces commandlink,但这是可选的。
<p:commandLink ajax="false">
<p:graphicImage value="xml.png" />
<p:dataExporter type="xml" target="datatbl" fileName="myxml" />
</p:commandLink>
答案 2 :(得分:0)
试试这个;的即时=&#34;真&#34; 强>
<p:commandLink ajax="false" immediate="true">
<p:graphicImage value="xml.png" />
<p:dataExporter type="xml" target="datatbl" fileName="myxml" />
</p:commandLink>
答案 3 :(得分:-1)
我认为您的问题出在commandLink中,试试这个:
$cart = Mage::getSingleton('checkout/cart');
$cart->addProduct($product, 1); // 1 = qty. Pass your qty and params.
$item = $cart->getQuote()->getItemByProduct($product);
$item->setCustomPrice(0); // or some other value
$item->setOriginalCustomPrice(0); // or some other value
$item->getProduct()->setIsSuperMode(true); // this is crucial
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);