Primefaces

inside a Dialog is not Working in I

2019-08-23 06:52发布

问题:

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).

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!

How to fix this issue ?

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 ?

My Code:

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>

Updated:

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

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

Solved :

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?

回答1:

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-->

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