-
1. Re: Problem with RichFaces modalpanel and IE7
nbelaevski Mar 23, 2010 6:31 PM (in response to shobana)Hi,
Please post some page/beans code: modal panel code,link code, action Java code.
-
2. Re: Problem with RichFaces modalpanel and IE7
shobana Mar 24, 2010 7:58 AM (in response to nbelaevski)Hi Nick,
We have the following requirement.
In our JSF application, we have a xhtml page containing a table. The user has an option to export the data from tabel to an Excel.
We have written a custom component for this data exporter (Similar to DataExporter that PrimeFaces provides).
There is also a a4j:commandLink on the page, which opens up a rich:modalPanel.
The modalPanel opens correctly normally, but after the user clicks exports to excel, (the user is presented with a dialog box to open/Save the excel as attachment), the modalPanel doesn't open on clicking the a4j:commandLink.
Can you please help me out? I found someone else faced a similar issue too (http://forums.sun.com/thread.jspa?threadID=5381418), but there was no reply to it. Your help would be greatly appreciated. Please note that our XHTML which contains the modalPanel is inside an iframe.
I have pasted the xhtml code, and bean action for your reference.
XHTML code containing the modalPanel:
<ui:composition template="/templates/content.xhtml">
<ui:define name="body"><acsc:hForm id="promotionStatusForm" dirtyFlag="false">
<!--a4j:commandLink which opens the modalPanel-->
<acsc:rToolBar>
<acsc:rToolBarGroup>
<a4j:commandLink onclick="Richfaces.showModalPanel('addPromotionList')">
<acsc:hGraphicImage id="Add" value="/images/add.png"
alt="Add Power Coupons" />
<acsc:rSpacer width="5" />
<acsc:hOutputText value="#{ToolBarBundle.ADD}" />
</a4j:commandLink>
</acsc:rToolBarGroup>
</acsc:rToolBar>
<acsc:rDataTable id="tblPromtionStatusTable"
value="#{promotionStatusBean.promotionStatusDataList}"
var="promotionStatusDetails" reRender="dsForPromtionStatusTable" fileName="promotionStatus"
bundleFile="com.bally.acsc.patron.bundle.promotion_status_bundle" excludeColumns="0"><acsc:rColumn>
<f:facet name="header">
<acsc:hOutputText value="#{promotionStatusBundle.PROMOTION_ID}"
style="font-weight:bold;" />
</f:facet>
<acsc:hOutputText value="#{promotionStatusDetails.strPromotionID}"></acsc:hOutputText>
</acsc:rColumn><!-- Code for data table display -->
</acsc:rDataTable>
</acsc:hForm><!--ModalPanel code-->
<acsc:rModalPanel id="addPromotionList" width="500" left="175" top="125" autosized="true" onshow="setModalPanelFilterFocus();">
<f:facet name="header">
<acsc:hOutputLabel colonMark="false">
<acsc:hOutputText value="#{promotionStatusBundle.ADD_PROMOTIONS}"></acsc:hOutputText>
</acsc:hOutputLabel>
</f:facet><f:facet name="controls">
<span id="hidelink" style="cursor: pointer"
onclick="javascript:Richfaces.hideModalPanel('addPromotionList')">X</span>
</f:facet>
<acsc:hForm id="addPromotionForm">
<acsc:rDataTable rows="#{acscUserPreferenceBean.modalPanelMaxRows}" excludeColumns="0"
value="#{promotionStatusBean.addPromotionStatusDataList}"
id="addDataList" var="addPromoList" reRender="dsAddPromotionList" fileName="addPromotionStatusList"
bundleFile="com.bally.acsc.patron.bundle.promotion_status_bundle">
<acsc:rColumn>
<f:facet name="header">
<acsc:hOutputText value="#{labelResource.SELECT}" />
</f:facet>
<acsc:hDataTableRadio name="selectedRow1"
value="#{promotionStatusBean.selection}"
itemValue="#{addPromoList.index}" overrideName="true"></acsc:hDataTableRadio>
</acsc:rColumn><!--code for displaying table within modalPanel-->
</acsc:rDataTable>
</acsc:hForm></acsc:rModalPanel>
<script type="text/javascript">
<!--
function setModalPanelFilterFocus()
{
}
function setRadioSelID()
{
}
-->
</script></ui:define>
</ui:composition>
</html>
By default, we are setting an export to excel icon at the footer of the rich:datatable, clicking which, the user can export the excel using Open/Save as option.
I have attached the bean action for the export to excel code:
public String exportToExcelAction(){
try {
FacesContext facesContext = FacesContext.getCurrentInstance();
ACSCExporter exporter=null;
if(type !=null){
exporter= ACSCExporterFactory.getExporterForType(type);
}
//Some validation code goes here
if(fileName==null)
fileName="book";
if(table!=null && exporter !=null)
{
exporter.export(facesContext, table, fileName, excludeColumnsAr,excludeRowsArray, bundleFile);
facesContext.responseComplete();
}} catch (IOException e) {
throw new FacesException(e);
}
return "success";
}The export method which does the actual export to excel is:
public void export(FacesContext facesContext, UIData data, String filename,
List<String> excludedColumns, List<String> excludedRows, String bundleFile) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
/*Code for populating the excel with values from dattatable goes here
*/
writeExcelToResponse(((HttpServletResponse)facesContext.getExternalContext().getResponse()), wb, filename);}
private void writeExcelToResponse(HttpServletResponse response, HSSFWorkbook generatedExcel, String filename) throws IOException {
response.setContentType("application/vnd.ms-excel");
response.setHeader("Expires", "0");
response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
response.setHeader("Content-disposition", "attachment;filename="+ filename + ".xls");generatedExcel.write(response.getOutputStream());
}Note:Please let me know what could be wrong here. The problem seems to get solved, if I change the Content-disposition from attachment to inline, (in the writeExcelToResponse() given above) while saving