Primefaces< p:printer>在Dialog中不能在IE中工作? [英] Primefaces <p:printer> inside a Dialog is not Working in IE?

查看:204
本文介绍了Primefaces< p:printer>在Dialog中不能在IE中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSF 2.0,Primefaces 3.5& JBoss Application Server 7.0 ..

I am using JSF 2.0 ,Primefaces 3.5 & JBoss Application Server 7.0..

在我的在线购物应用程序中,我正在尝试打印订单的详细信息(我的代码)。

In my Online Shopping Application, i am trying to print the details of the Order(My Code).

在Chrome和FireFox中一切正常,但在IE9及以上版本中,它会抛出错误Internet Stopped Working并且打印失败!

Everything is working fine in Chrome and FireFox, but in IE9 and above it is throwing an error "Internet Stopped Working" and the print is been failed!

如何解决此问题?

怀疑:问题是因为使用了对话框。或者它是浏览器兼容性问题。
有没有其他方法可以实现这个目标?

Doubt: Is the issue because of using a Dialog Box. Or is it a Browser compatibility Issue. Is there any Other Way to Achieve this ?

我的代码:

MyController

    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    import java.io.Serializable;

    @ManagedBean
    @SessionScoped
    public class MyController implements Serializable {

        private static final long serialVersionUID = 1L;
        public void generateOrderList(){

        //Generates the List of Ordered Items 

            RequestContext.getCurrentInstance().execute("printOrderDetails.show();");
        }
    }

orderDetails.xhtml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



  <ui:composition xmlns="http://www.w3.org/1999/xhtml" 
                  xmlns:f="http://java.sun.com/jsf/core"   
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:p="http://primefaces.org/ui">

            <h:form id="orderForm">

                <h:body class="bgcolor">

<p:panel id="printPnl">
    <h4>Print Order Details</h4>
            <p:row>
                <p:column>

                    <div class="left-panel">
                        <p:commandButton id="orderListCmdBtn" value="Order List" update=":orderForm:printDialog"
                            action="#{myController.generateOrderList()}" />
                    </div>
                </p:column>
            </p:row>
</p:panel>

    <p:dialog id="printDialog" header="Get Print" widgetVar="printOrderDetails">

            <div>
                <h:commandButton id="printCmdBtn" value="Print" type="button" icon="ui-icon-print" style="width:50px;float:right">  
                    <p:printer  target="printListPnl"  />
                </h:commandButton> 
            </div>

        <p:panel id="printListPnl">
        <p:panelGrid id="packingListPnlGrd" styleClass="panelgridTable" style="width:100% !important" >
            <p:row>                             
                <p:column styleClass="talign-top" style="width:37%;">
                    To: <br />#{myController.toAddress}&nbsp;
                </p:column>
                <p:column styleClass="talign-top" style="width:37%;">
                    From: <br />#{myController.fromAddress}&nbsp;
                </p:column>

            </p:row>                            
        </p:panelGrid>

        <p:dataTable id="orderDtble" var="order" value="#{myController.orderDetails}" >
            <p:columnGroup type="header">
                <p:row>
                    <p:column headerText="Order Name"></p:column>
                    <p:column headerText="Order"></p:column>
                    <p:column headerText="Order Date"></p:column>
                    <p:column headerText="Remark"></p:column>                                   
                </p:row>
            </p:columnGroup>
            <p:column>
                <h:outputText id="orderNameOutTxt" value="#{order.name}" />
            </p:column>
            <p:column>
                <h:outputText id="orderIdOutTxt" value="#{order.orderId}" />
            </p:column>
            <p:column>
                <h:outputText id="orderDateOutTxt" value="#{order.orderDate}">
                    <f:convertDateTime pattern="MM/dd/yyyy" type="date" />
                </h:outputText>
            </p:column>
            <p:column>
                <h:outputText id="orderRemarksOutTxt" value="#{order.remarks}" />
            </p:column>                         
        </p:dataTable>
        </p:panel>
    </p:dialog>

    </h:body>

    </h:form>
</ui:composition>

更新:

这就是我在Primefaces中找到改变Jquery版本的方法。
@BalusC

This is how i had found the way to change the Jquery Version in Primefaces. @BalusC.

但我仍然不知道为什么< p:printer> 没有是否支持IE9及以上版本,仅仅是因为JQuery?

But i still don't know why the <p:printer> doesn't support the IE9 and above, is it just because of JQuery?

已解决:

Solved :

我解决了这个问题,使用 window.open(); 并拥有 window.print( ); 关于需要打印并被 CSS 文件忽略的内容。然后我的打印目的就解决了。

I had Solved this issue, using a window.open(); and Having a window.print(); on the content which needs to be printed and ignored by a CSS file.Then my Purpose of Print is solved.

但我对这个问题的答案不是那个!我在找哪个?

But my answer for this Question is not that! Which i am looking for?

推荐答案

我的建议是篡改发送到的 HTTPHeader 页面。

My suggestion would be to tamper with the HTTPHeader being sent to the page.

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" > <!--Top of Page in head-->

如果 edge 不起作用,请尝试模拟不同版本的IE(例如 EmulateIE7 ),我遇到与 inputCalendar 相同的问题。

If edge doesn't work try emulating different versions of IE (e.g. EmulateIE7), I had the same problem with inputCalendar.

这篇关于Primefaces&lt; p:printer&gt;在Dialog中不能在IE中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆